Constraint built-ins
Constraints relate Float expressions; the solver finds geometry that satisfies them.
float
float() -> Float
Creates a new solver variable.
Use it for a value you want to name now and constrain later.
Returns Float. A variable with no constraints on it yet.
let center = float();
eq(center, (bounds.x0 + bounds.x1) / 2.);
eq
eq(left: Float, right: Float) -> ()
Constrains two linear expressions to be equal.
| Argument | Type | Requirement | Description |
|---|---|---|---|
left | Float | Required, positional | One side of the equality: a literal, parameter, geometry field, or linear combination of them. |
right | Float | Required, positional | The other side. |
Returns (). Nothing; the constraint is added to the current cell.
eq(inner.x0, outer.x0 + inset);
eq(inner.w, outer.w - 2. * inset);
Conflicting constraints are reported when the cell runs.
dimension
dimension(p: Float, n: Float, value: Float, coord: Float, pstop: Float, nstop: Float, horizontal: Bool) -> ()
Adds an equality constraint together with the dimension label the GUI draws for it.
| Argument | Type | Requirement | Description |
|---|---|---|---|
p | Float | Required, positional | Coordinate on the positive side of the measurement. |
n | Float | Required, positional | Coordinate on the negative side. |
value | Float | Required, positional | The constraint: p - n must equal this. |
coord | Float | Required, positional | Where the dimension line sits, on the perpendicular axis. |
pstop | Float | Required, positional | Where the extension line on the positive side ends. |
nstop | Float | Required, positional | Where the extension line on the negative side ends. |
horizontal | Bool | Required, positional | true for a horizontal measurement, false for vertical. |
Returns (). Nothing; the constraint and its label are added to the current cell.
Prefer the GUI for dimensions
The Dimension tool fills in the orientation and label-placement arguments from the edges you click. In hand-written source, use eq unless you want a visible dimension.