/** * Functional API wrapper for moicad * * Provides functional-style API as an alternative to the fluent/OOP API. * Each function creates and returns Shape instances. * * @example Functional style * ```typescript * import { cube, sphere, translate, union } from 'moicad'; * * export default union( * cube(10), * translate([15, 0, 0], sphere(5)) * ); * ``` * * @example Fluent style (primary) * ```typescript * import { Shape } from 'moicad'; * * export default Shape.cube(10) * .union(Shape.sphere(5).translate([15, 0, 0])); * ``` */ import { Shape } from './shape'; import type { PrimitiveOptions, TextOptions, SurfaceOptions, LinearExtrudeOptions, RotateExtrudeOptions, OffsetOptions, ProjectionOptions, Color, Vector3, Vector2 } from './types/javascript-types'; /** * Create a cube or box. * * @example * cube(10) // 10x10x10 cube * cube([20, 10, 5], true) // Centered box */ export declare function cube(size: number | Vector3, center?: boolean): Shape; /** * Create a sphere. * * @example * sphere(5) * sphere(5, { $fn: 64 }) */ export declare function sphere(radius: number, options?: PrimitiveOptions): Shape; /** * Create a cylinder. * * @example * cylinder(20, 5) * cylinder(20, [5, 3], { center: true }) */ export declare function cylinder(height: number, radius: number | [number, number], options?: PrimitiveOptions): Shape; /** * Create a cone. * * @example * cone(20, 10) * cone(20, 10, 5, { center: true }) */ export declare function cone(height: number, radiusBottom: number, options?: PrimitiveOptions): Shape; /** * Create a pyramid with N-sided polygonal base. * * @example * pyramid(20) // Square pyramid * pyramid([30, 20, 15]) // Rectangular pyramid * pyramid(20, { sides: 3 }) // Triangular pyramid * pyramid(20, { sides: 6, center: true }) // Centered hexagonal pyramid */ export declare function pyramid(size: number | Vector3, options?: PrimitiveOptions & { sides?: number; }): Shape; /** * Create a polyhedron from vertices and faces. * * @example * polyhedron([[0,0,0], [10,0,0], [5,10,0]], [[0,1,2]]) */ export declare function polyhedron(points: number[][], faces: number[][]): Shape; /** * Create a 2D circle. * * @example * circle(10) * circle(10, { $fn: 64 }) */ export declare function circle(radius: number, options?: PrimitiveOptions): Shape; /** * Create a 2D square or rectangle. * * @example * square(10) * square([20, 10], true) */ export declare function square(size: number | Vector2, center?: boolean): Shape; /** * Create a 2D polygon from points. * * @example * polygon([[0,0], [10,0], [5,10]]) */ export declare function polygon(points: Vector2[]): Shape; /** * Create 3D text (async operation). * * @example * await text('Hello') * await text('moicad', { size: 20, halign: 'center' }) */ export declare function text(text: string, options?: TextOptions): Promise; /** * Create a surface from heightmap data. * * @example * surface([[0,1,0], [1,2,1], [0,1,0]], 3, 3) */ export declare function surface(data: number[][] | Float32Array | number[], width: number, depth: number, options?: SurfaceOptions): Shape; /** * Translate (move) a shape. * * @example * translate([10, 0, 0], cube(10)) */ export declare function translate(offset: Vector3, shape: Shape): Shape; /** * Rotate a shape. * * @example * rotate([45, 0, 0], cube(10)) */ export declare function rotate(angles: Vector3, shape: Shape): Shape; /** * Scale a shape. * * @example * scale(2, cube(10)) * scale([2, 1, 0.5], cube(10)) */ export declare function scale(factors: number | Vector3, shape: Shape): Shape; /** * Mirror a shape across a plane. * * @example * mirror([1, 0, 0], cube(10)) */ export declare function mirror(normal: Vector3, shape: Shape): Shape; /** * Apply a transformation matrix. * * @example * multmatrix([[1,0,0,10], [0,1,0,0], [0,0,1,0], [0,0,0,1]], cube(10)) */ export declare function multmatrix(matrix: number[][], shape: Shape): Shape; /** * Apply color to a shape. * * @example * color('red', cube(10)) * color([1, 0, 0], cube(10)) */ export declare function color(color: Color, shape: Shape): Shape; /** * Union (combine) multiple shapes. * * @example * union(cube(10), sphere(5), cylinder(20, 3)) */ export declare function union(...shapes: Shape[]): Shape; /** * Subtract shapes from a base shape (difference operation). * * @example * difference(cube(20), sphere(8)) */ export declare function difference(base: Shape, ...shapes: Shape[]): Shape; /** * Intersect multiple shapes. * * @example * intersection(cube(10), sphere(8)) */ export declare function intersection(...shapes: Shape[]): Shape; /** * Compute convex hull of multiple shapes. * * @example * hull(sphere(5), cube(10).translate([20, 0, 0])) */ export declare function hull(...shapes: Shape[]): Shape; /** * Compute Minkowski sum of two shapes. * * @example * minkowski(cube(10), sphere(2)) */ export declare function minkowski(a: Shape, b: Shape): Shape; /** * Extrude a 2D shape linearly. * * @example * linearExtrude(20, circle(10)) * linearExtrude(30, square(10), { twist: 180, scale: 0.5 }) */ export declare function linearExtrude(height: number, shape: Shape, options?: LinearExtrudeOptions): Shape; /** * Revolve a 2D shape around the Z-axis. * * @example * rotateExtrude(polygon([[10,0], [15,0], [15,20], [10,20]])) * rotateExtrude(circle(5), { angle: 180 }) */ export declare function rotateExtrude(shape: Shape, options?: RotateExtrudeOptions): Shape; /** * Offset a 2D shape. * * @example * offset(5, square(20)) * offset(-2, circle(10)) */ export declare function offset(delta: number, shape: Shape, options?: OffsetOptions): Shape; /** * Project a 3D shape to 2D. * * @example * projection(sphere(10)) * projection(cube(20), { cut: true }) */ export declare function projection(shape: Shape, options?: ProjectionOptions): Shape; /** * Initialize plugins and extend the functional API with plugin functions. * This should be called once during application startup to make plugin functions available. */ export declare function initializePlugins(): Promise; /** * Get all available plugin primitives. */ export declare function getPluginPrimitives(): Record Shape>; /** * Get all available plugin transforms. */ export declare function getPluginTransforms(): Record Shape>; /** * Register a plugin primitive function. */ export declare function registerPrimitive(name: string, func: (...args: any[]) => Shape): void; /** * Register a plugin transform function. */ export declare function registerTransform(name: string, func: (shape: Shape, ...args: any[]) => Shape): void; //# sourceMappingURL=functional.d.ts.map