Primitive Geometries
Primitive geometries are the building blocks of sketches — lines, arcs, and curves. They follow a "pen" model: each command starts from where the last one ended.
circle
circle() takes a diameter (not radius):
import { sketch } from 'fluidcad/core';
import { circle } from 'fluidcad/core';
sketch("xy", () => {
circle(50)
circle([30, 20], 40)
})

line
sketch("xy", () => {
line([0, 0], [100, 0]) // from [0,0] to [100,0]
line([100, 50]) // continues to [100, 50]
line([0, 0]) // back to start, closing the shape
})
Directional lines
import { sketch } from 'fluidcad/core';
import { line, vLine, hLine } from 'fluidcad/core';
sketch("xy", () => {
line([0, 0], [50, 0])
vLine(40)
hLine(-50)
line([0, 0])
})

hLine(distance)— horizontal line (positive = right, negative = left)vLine(distance)— vertical line (positive = up, negative = down)aLine(angle, distance)— line at an angle (degrees) for a given distance
sketch("xy", () => {
line([0, 0], [50, 0])
aLine(60, 40) // 60° angle, 40 units long
line([0, 0])
})
arc
sketch("xy", () => {
arc(50, 0, 90) // radius 50, from 0° to 90°
})
Tangent arcs
tArc() draws an arc that is tangent to the previous line or arc — the arc starts in the same direction the pen is currently pointing (shown by the orange arrow in the viewport). This creates smooth, continuous curves:
import { sketch } from 'fluidcad/core';
import { vLine, tArc } from 'fluidcad/core';
sketch("front", () => {
vLine(100)
tArc(50, 180)
tArc(80, -270)
})

bezier
Draws bezier curves through control points:
sketch("xy", () => {
bezier([0, 0], [50, 100], [100, 0]) // quadratic bezier (1 control point)
})
The last point is the endpoint. Points in between are control points:
- 2 points = straight line
- 3 points = quadratic bezier (1 control point)
- 4 points = cubic bezier (2 control points)
Interactive mode
Call bezier() with no arguments to enter interactive mode. Click in the viewport to place control points with a live preview of the curve. Use Ctrl+click to drag existing points, and Escape to undo.