@mylasertools/kerfscript 0.10.0 → 0.11.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/CHANGELOG.md +207 -0
  2. package/LANGUAGE.md +90 -42
  3. package/dist/assembly.d.cts +20 -1
  4. package/dist/assembly.d.ts +20 -1
  5. package/dist/cli.js +2265 -383
  6. package/dist/colors.d.cts +4 -0
  7. package/dist/colors.d.ts +4 -0
  8. package/dist/effects.d.cts +2 -2
  9. package/dist/effects.d.ts +2 -2
  10. package/dist/evaluator.d.cts +9 -1
  11. package/dist/evaluator.d.ts +9 -1
  12. package/dist/export/mesh.d.cts +16 -3
  13. package/dist/export/mesh.d.ts +16 -3
  14. package/dist/export/model.d.cts +8 -3
  15. package/dist/export/model.d.ts +8 -3
  16. package/dist/export/pages.d.cts +23 -0
  17. package/dist/export/pages.d.ts +23 -0
  18. package/dist/geometry.d.cts +20 -0
  19. package/dist/geometry.d.ts +20 -0
  20. package/dist/hardware.d.cts +2 -0
  21. package/dist/hardware.d.ts +2 -0
  22. package/dist/highlight.cjs +1 -1
  23. package/dist/highlight.js +1 -1
  24. package/dist/index.cjs +1319 -83
  25. package/dist/index.d.cts +4 -2
  26. package/dist/index.d.ts +4 -2
  27. package/dist/index.js +1319 -83
  28. package/dist/instructions.d.cts +27 -0
  29. package/dist/instructions.d.ts +27 -0
  30. package/dist/language.cjs +1288 -54
  31. package/dist/language.js +1288 -54
  32. package/dist/libraries.cjs +1269 -40
  33. package/dist/libraries.js +1269 -40
  34. package/dist/lights.d.cts +38 -0
  35. package/dist/lights.d.ts +38 -0
  36. package/dist/png.d.cts +14 -0
  37. package/dist/png.d.ts +14 -0
  38. package/dist/render.d.cts +5 -0
  39. package/dist/render.d.ts +5 -0
  40. package/dist/signatures.cjs +75 -4
  41. package/dist/signatures.js +75 -4
  42. package/dist/text.d.cts +23 -0
  43. package/dist/text.d.ts +23 -0
  44. package/dist/verify/types.d.cts +6 -0
  45. package/dist/verify/types.d.ts +6 -0
  46. package/docs/3d-files.md +34 -13
  47. package/docs/cli.md +12 -1
  48. package/docs/customizer.md +13 -0
  49. package/docs/javascript.md +6 -1
  50. package/docs/layers.md +24 -1
  51. package/docs/library.md +462 -18
  52. package/docs/parts-and-sheets.md +205 -28
  53. package/docs/verification.md +1 -1
  54. package/docs/versions.md +2 -2
  55. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,212 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.11.1 (2026-11-27)
4
+
5
+ Fixes:
6
+
7
+ - 3MF files open in OrcaSlicer, Bambu Studio and the slicers based on them
8
+ with each colour on its own filament, so the engraving and scoring print
9
+ in their colours instead of all on the first filament.
10
+
11
+ ## 0.11.0 (2026-11-18)
12
+
13
+ Language:
14
+
15
+ - `part(paint = "red")` paints a part: the 3D view, the 3D files and the
16
+ print layout show it in that colour, while it stays on the sheet of its
17
+ material. `layer(name, mode = "paint", color)` paints areas of a part,
18
+ shown the same way and never in the files for the laser. The parts list
19
+ says which parts are painted.
20
+ - Translucent materials: a part of vellum, tracing paper, parchment, rice
21
+ paper, frosted acrylic or paper shows translucent in the 3D view, so a
22
+ light behind it shows through, and GLB files make it partly transparent
23
+ with transmission. `hardware("vellum")` is new, and `hardware("paper")`
24
+ is translucent.
25
+ - A customizer menu can come from a library: `// [figure_names("easter")]`
26
+ or any function call in the brackets is run with the program's built-in
27
+ libraries, each item of the list a choice. `size_list(kind)` in
28
+ `kerf/sizes` lists a table's names for one.
29
+ - A layer's colour can be a name, as `"red"`, as well as a hex colour.
30
+ - `$stands = true` checks that a model meant to stand does: it warns when
31
+ its weight's centre is not over the outline of its lowest points. Parts
32
+ weigh as plywood (`$density`), and `hardware(..., mass = 60)` counts an
33
+ egg or bottle it holds.
34
+ - Parts too big for the bed: `part(split = true)` cuts a part into
35
+ pieces that fit the sheet (or `split = [w, h]`), along lines that cross
36
+ the least material and keep off engraving, joined by jigsaw knobs
37
+ (`$knob`, `$knob_clearance`). Each piece is a part of its own in its
38
+ place, and the parts list says which pieces it joins.
39
+ - Copies that differ: inside `part(qty = n)`, `$copy` is the copy being
40
+ drawn, 0 to n - 1, so a set of tags takes a name each. Copies that come
41
+ out alike stay one part; the parts list says which copies each part is.
42
+ - Hanging parts: `part(hang = [x, y], cord = 20)` hangs a part from a
43
+ point on it, at `at`, on a cord, ring or pin, swung in its own plane
44
+ until its weight is straight below, as a shelf sitter's legs; the cord
45
+ is listed as hardware.
46
+ - Folds along any line for card and paper: `part(fold = [from, to,
47
+ angle])`, or a list of them, folds the part's panels in the assembled
48
+ view and its 3D files, cut lines inside it (a pop-up's slits) parting
49
+ the panels too; `fold_open` opens every fold part of the way, for a
50
+ card shown half open. A fold that divides nothing warns.
51
+ `foldPanels()` and `panelMarks()` give a viewer of your own the panels.
52
+ - Welded text: `text(name, size, weld = true)` slides each word's letters
53
+ together until each overlaps the one before, so a name cuts out in one
54
+ piece; `underline = h` adds a bar under it joining the words. A piece
55
+ still loose, as an i's dot, warns.
56
+ - Text in lines: a `"\n"` in `text()` breaks a line, and
57
+ `text(t, fit = [w, h], lines = 2)` breaks a long name at a space when
58
+ two lines let it be bigger than one. `line_spacing` sets the distance
59
+ between lines.
60
+ - Text on a path: `text(t, size, path = points)` lays the text along a
61
+ path, each letter turned to it, and `text(t, size, arc = r)` round a
62
+ circle, over the top or (r less than 0) along the bottom. Cut, engraved
63
+ or bridged, as any text. A text longer than its path warns.
64
+ - `part(pieces = 2)` or `pieces = "any"` makes a part of loose pieces, as
65
+ a pair of eyes, without the warning that it cuts into separate pieces.
66
+ - Light sources: `hardware("tealight", at)` stands a tealight whose flame
67
+ flickers, LEDs (a strip when longer than 20 mm) and bulbs give off light,
68
+ and `light(at, color, lumens)` adds a light with nothing to show for it.
69
+ The 3D view lights the model with them, with "Dim the room" to see them
70
+ glow, `render()` returns them as `lights`, and GLB files carry them as
71
+ point lights with LEDs and flames emissive.
72
+
73
+ Command line:
74
+
75
+ - `kerf instructions -o out.pdf` writes the assembly instructions as a
76
+ PDF, and `-o out.png` as a picture of each page: the parts, then a page
77
+ for each step with the model as it stands, its new parts in orange and
78
+ what it adds. No browser is needed. Folded parts are drawn folded.
79
+
80
+ Libraries:
81
+
82
+ - `kerf/inlay`: `inlaid()` cuts inlay shapes through a part, or engraves
83
+ them as pockets, and cuts each again as an insert a press fit bigger, of
84
+ its own stock or painted. `part(press_fit = true)` with `glue` lets an
85
+ insert overlap the part it presses into without a collision warning.
86
+ - `kerf/sphere`: `ball()` makes a slot-together ball or dome of half-disc
87
+ fins round an upright axis held by rings with halving joints, hollow
88
+ with a floor and a rail for a scene inside if asked, and with holes for
89
+ a ribbon to hang it by.
90
+ - `kerf/layered`: `layered()` makes multilayer art from its children, the
91
+ layers back to front: each a part glued on the one behind and painted,
92
+ grown to hold up everything in front of it with a rim, with an optional
93
+ shadow layer and a hole through every layer to hang it by.
94
+ - `symbol(name, size, min_width = 1.6)` in `kerf/symbols` grows every
95
+ line narrower than `min_width` to that width, so a symbol drawn small
96
+ can be cut.
97
+ - `kerf/drawers`: `drawers()` makes a carcass of numbered sliding drawers
98
+ in a grid, as for an advent calendar, with the numbers in order, from a
99
+ list or shuffled, a notch or hole to pull each by, and a façade of any
100
+ shape with the drawers' openings cut through it.
101
+ - `kerf/scene` for scene boxes and dioramas: `scene_floor()` and
102
+ `scene_rails()` cut rows of rails, `standee()` gives a drawing feet that
103
+ stand in any rail (with a mound under a narrow one, and clipped to a
104
+ case if asked), `scene_figure()` stands a layered figure in a rail,
105
+ `figure_base()` puts one on a base of its own, and `drip_edge()` and
106
+ `wave_edge()` draw snow, icing and water edges.
107
+ - `kerf/figures`: 31 layered characters in five casts (Christmas, Easter,
108
+ Halloween, nativity and animals). `figure_parts()` builds one as a
109
+ backer, coloured pieces glued on it and details on those, each colour a
110
+ painted part; `figure()` cuts one from a single sheet with the pieces
111
+ scored and the details engraved; `figure_layer()` gives the shapes of
112
+ any layer.
113
+ - `kerf/sizes`: `note_size()` gives banknote sizes (US, Canadian, euro,
114
+ pound and Australian notes), `card_size("gift card")`, and
115
+ `part_size()` has tealights, a maxi tealight, an LED tealight and puck,
116
+ a fairy-light battery box, hen and chocolate eggs, a wine bottle, disc
117
+ magnets, a key ring, AA battery boxes, a coin cell holder, a key fob and
118
+ tissue boxes, with a `diameter` and `height` for round things and a
119
+ `hole` to stand or press them in.
120
+ - `wall(outline, depth)` in `kerf/hinge`: a front plate, a back plate and
121
+ a strip between them bent on living hinges round a closed outline, tabbed
122
+ into slots in both plates where it runs straight. The seam goes where
123
+ `join` asks, and a strip longer than `max_length` is cut into pieces that
124
+ fit the bed. `wall_path()`, `wall_pieces()` and `path_part()` go with it.
125
+
126
+ 3D files:
127
+
128
+ - The print layout, `--print` or `layout: "print"`, makes each part with
129
+ everything glued on it (`glue =` and the layers of a `stack`) one object,
130
+ each layer where the assembly puts it and in its own colour, lying on
131
+ its lowest face. Marks show only where nothing covers them. `--print`
132
+ laid the parts out flat and apart before.
133
+ - A layer's colour comes from a colour named in its material (green, blue,
134
+ yellow, orange, purple, pink, grey, gold, brown) or a `#rrggbb` in it.
135
+ - `result.assembly` entries say which entry each is glued on (`glued`).
136
+
137
+ Changes to the output of existing programs, each a fix:
138
+
139
+ - A child of `intersection()` that makes nothing at all, as OpenSCAD
140
+ counts it (an `if` whose condition is false and that has no `else`, an
141
+ `echo()` or `assert()` with no children), no longer empties the
142
+ intersection; in `difference()` it is not the shape cut from, the next
143
+ child is.
144
+ - `flex_strip()` and `strip_bends()` keep a curve whose radius changes as
145
+ several bends, one for each stretch of much the same radius, instead of
146
+ one bend of the average radius. The cut file is unchanged; the bent strip
147
+ in the 3D view, the exported models, the collision checks and the slots it
148
+ cuts follow the path.
149
+ - A path given to `flex_strip()` or `strip_bends()` that repeats a point,
150
+ as where a straight run and an arc share their end, bends where the arc
151
+ starts; the repeated point had started the hinge and the bend a few mm
152
+ early, on the straight.
153
+ - `flex_strip()` rounds each sharp corner of its path to the arc the strip
154
+ bends round, radius `r` inside, and is as long as that rounded path, so
155
+ it ends where the path ends; it ran on past it by about 1.6 mm a corner
156
+ before, and was cut that much too long. `strip_path()`, `strip_loop()`
157
+ and `strip_corner()` give the rounded path.
158
+ - Closed cuts on a sheet go deepest first: a part nested in another part's
159
+ hole is cut before that hole, and a hole before the outline round it.
160
+ Holes of every part used to come before every outline, so a part nested
161
+ in a hole could be cut after the hole had freed the stock under it.
162
+ - With `$layout = "none"`, parts of different materials or thicknesses go
163
+ on separate sheets, as when packed. They shared one sheet, labelled with
164
+ the first part's material.
165
+ - A tab that only dips into a part, less than 1 mm or half its thickness,
166
+ is not cut as a slot because another tab of its part goes deep enough:
167
+ each piece that enters the part is judged on its own depth, and the
168
+ shallow one is reported as a collision.
169
+ - A part glued to a stack (`glue =` a part with `stack = n`) goes on the
170
+ stack's top layer, or under its bottom one, not on its first layer inside
171
+ the stack; with as many copies as the stack has, one goes on each copy
172
+ of the stack, not all on the first.
173
+ - A bent part inside `translate()`, `scale()` or `mirror()` bends where its
174
+ drawing went; its bends stayed where they were drawn. Turning one with
175
+ `rotate()` is an error: turn it with `part(rotate = ...)`.
176
+ - `measure()` counts what any layer of mode `"cut"` cuts, and leaves out
177
+ any layer of mode `"guide"`; it went by the names `cut` and `guide`, so
178
+ a custom cut layer was left out of `$area` and `$centroid`.
179
+ - `text(fit = w)` is no wider than `w` where a glyph reaches past its
180
+ advance, as a `q`'s tail does; it was fitted by the advance alone.
181
+ - `pattern()` clips each tile that an edge of the area crosses. A tile with
182
+ its corners inside the area and none of the area's corners inside it was
183
+ kept whole, over a rib or a strip of the area running through it.
184
+
185
+ Fixes:
186
+
187
+ - A part with nothing in it warns: `Part "P" is empty`.
188
+ - `slots = []` asks for no slots, without a warning that none pass through.
189
+ - `flex_strip()` along a path with no curve or corner makes a straight
190
+ strip; it stopped with "bend must be [x0, x1, angle]". `bend = []` is no
191
+ bend.
192
+ - A `$kerf` or `$thickness` that is not a finite number, as `0/0` or
193
+ `1/0` gives, is an error; a NaN kerf was taken as 0 and an infinite
194
+ thickness accepted.
195
+ - A layer set again with `layer()` after marks went on its back face sets
196
+ its back the same way, mode, colour and order; the back kept the first
197
+ settings. Making it a cut layer then is an error.
198
+ - A library path in `use <...>` or `include <...>` may hold any character
199
+ a folder name has, as `(`, `#` or `é`.
200
+ - The back-face docs say the back job is turned over within the file's
201
+ width, and how far to move it on stock wider than the file.
202
+ - A stack whose layers take different blind slots, and so become a part
203
+ each (`"top, layer 1"`), is still found by its own name for `halving`,
204
+ and still prints as one stack with `--print`.
205
+ - `wall()` never cuts a piece longer than `max_length`; a cut it could not
206
+ put on a straight could leave one longer. Without `join`, its seam is in
207
+ the middle of the outline's longest side, not at its first point, which
208
+ is often a corner.
209
+
3
210
  ## 0.10.0 (2026-11-16)
4
211
 
5
212
  Language version 0.3, as in 0.9.0: programs run as before, except that
package/LANGUAGE.md CHANGED
@@ -193,26 +193,31 @@ module hang_hole(d = 5) {
193
193
 
194
194
  ## Special variables
195
195
 
196
- | Name | Default | Meaning |
197
- | ----------------- | ------------- | ----------------------------------------------------------------------------- |
198
- | `$thickness` | `3` | material thickness, used by joinery and stored on parts |
199
- | `$kerf` | `0` | beam width; cut outlines are offset by half of it |
200
- | `$material` | `"material"` | material name; parts are packed per material and thickness |
201
- | `$sheet` | `[600, 400]` | sheet size for packing |
202
- | `$gap` | `3` | space between packed parts and around the sheet edge |
203
- | `$layout` | `"pack"` | `"pack"` packs parts onto sheets, `"none"` keeps your placement |
204
- | `$fn` `$fa` `$fs` | `0` `2` `0.2` | curve resolution: fixed segment count, or max angle and max segment length |
205
- | `$font` | | default font name for `text()` |
206
- | `$mirrored` | `false` | set inside a mirrored part and on the back face: `text()` reads right |
207
- | `$scale` | `1` | the model's scale: `140cm` is 1400 mm divided by `$scale` |
208
- | `$nest` | `false` | pack small parts into the holes of bigger ones |
209
- | `$registration` | `false` | print-and-cut marks in three corners of every sheet |
210
- | `$label_parts` | `false` | engrave each part's number on its back face, as in the parts list and steps |
211
- | `$join_lines` | `false` | join lines that meet end to end and order them nearest first, for less travel |
212
- | `$min_width` | `1.5` | warn where a part's material is narrower than this; `0` turns it off |
213
- | `$bounds` | | set by `measure()` for the children after the one it measures |
214
- | `$area` | | set by `measure()`: the area of material the measured child cuts |
215
- | `$centroid` | | set by `measure()`: the measured child's balance point `[x, y]` |
196
+ | Name | Default | Meaning |
197
+ | ----------------- | ------------- | ------------------------------------------------------------------------------------------------------ |
198
+ | `$thickness` | `3` | material thickness, used by joinery and stored on parts |
199
+ | `$kerf` | `0` | beam width; cut outlines are offset by half of it |
200
+ | `$material` | `"material"` | material name; parts are packed per material and thickness |
201
+ | `$sheet` | `[600, 400]` | sheet size for packing |
202
+ | `$gap` | `3` | space between packed parts and around the sheet edge |
203
+ | `$layout` | `"pack"` | `"pack"` packs parts onto sheets, `"none"` keeps your placement |
204
+ | `$fn` `$fa` `$fs` | `0` `2` `0.2` | curve resolution: fixed segment count, or max angle and max segment length |
205
+ | `$font` | | default font name for `text()` |
206
+ | `$mirrored` | `false` | set inside a mirrored part and on the back face: `text()` reads right |
207
+ | `$copy` | | inside `part(qty = n)`: the copy being drawn, 0 to n - 1; copies that differ become parts of their own |
208
+ | `$scale` | `1` | the model's scale: `140cm` is 1400 mm divided by `$scale` |
209
+ | `$nest` | `false` | pack small parts into the holes of bigger ones |
210
+ | `$registration` | `false` | print-and-cut marks in three corners of every sheet |
211
+ | `$label_parts` | `false` | engrave each part's number on its back face, as in the parts list and steps |
212
+ | `$join_lines` | `false` | join lines that meet end to end and order them nearest first, for less travel |
213
+ | `$min_width` | `1.5` | warn where a part's material is narrower than this; `0` turns it off |
214
+ | `$knob` | `12` | the size of the jigsaw knobs joining the pieces of a split part |
215
+ | `$stands` | `false` | `true` for a model meant to stand: it warns if its weight's centre is not over what it stands on |
216
+ | `$density` | `0.6` | the parts' density in g/cm³ for that check, plywood's by default |
217
+ | `$knob_clearance` | `0.15` | the room between a knob and its socket |
218
+ | `$bounds` | | set by `measure()` for the children after the one it measures |
219
+ | `$area` | | set by `measure()`: the area of material the measured child cuts |
220
+ | `$centroid` | | set by `measure()`: the measured child's balance point `[x, y]` |
216
221
 
217
222
  ## Layers
218
223
 
@@ -231,7 +236,9 @@ layer("pocket", mode = "fill", color = "#00aa00") ...
231
236
  ```
232
237
 
233
238
  Use `layer(name, mode, color)` to define a custom layer. Its mode is
234
- `"cut"`, `"line"`, `"fill"` or `"guide"`.
239
+ `"cut"`, `"line"`, `"fill"`, `"guide"` or `"paint"`; a paint layer is
240
+ never cut or engraved, only shown in 3D views and the print layout. Its
241
+ colour is a hex colour or a name, as `"red"`.
235
242
 
236
243
  Marks can go on a part's **back face** too: `engrave(side = "back")`,
237
244
  `score(side = "back")` or `layer(name, side = "back")`. Draw them where
@@ -288,6 +295,10 @@ material(thickness = 4, kerf = 0.12, name = "birch") {
288
295
  - More about a part, all named:
289
296
  - `material = "red acrylic"`: the part's material, as `material(name =
290
297
  ...)` would set `$material` round it.
298
+ - `pieces = 2` or `pieces = "any"`: the part is meant to cut into that
299
+ many separate pieces, so it does not warn that it is in pieces.
300
+ - `paint = "red"`: the part's colour in 3D views and the print
301
+ layout, painted after cutting; it stays on the sheet of its material.
291
302
  - `stack = n`: n layers glued at each placement, one thickness apart
292
303
  along the part's z. The parts list says how many make a stack.
293
304
  - `mirror = true`: the part is cut mirrored left to right (x becomes
@@ -299,9 +310,27 @@ material(thickness = 4, kerf = 0.12, name = "birch") {
299
310
  - `bend = [x0, x1, angle]`, or a list of them: a living hinge from x0 to
300
311
  x1 along the part's x bends it by `angle` degrees in the assembled
301
312
  view, folding the far end up towards its top face (down for a negative
302
- angle). The hinge's middle layer keeps its length.
313
+ angle). The hinge's middle layer keeps its length. An empty list is
314
+ no bend.
315
+ - `fold = [from, to, angle]`, or a list of them: folds along any line
316
+ in the assembled view, as for card. The folds (and cut lines inside
317
+ the part, as a pop-up's slits) cut it into panels; the one at the
318
+ origin stays flat and each other turns about the folds between,
319
+ towards the top face for an angle more than 0. `fold_open` (1) scales
320
+ every fold's angle, 0 lying flat. A fold that divides nothing warns.
321
+ - `split = true`, or `[w, h]`: a part too big for the bed is cut into
322
+ pieces that fit the sheet (less its margins) or that size, joined by
323
+ jigsaw knobs `$knob` mm across; the parts list says which pieces each
324
+ joins.
325
+ - `hang = [x, y]`, `cord = 0`: the part hangs from that point on it, at
326
+ `at`, and swings in the plane `rotate` gives until its weight is
327
+ straight below; `cord` hangs it that much lower on a cord, listed as
328
+ hardware.
303
329
  - `on = "name"`: the part is glued to that bent part, and moves with the
304
330
  run of it under its centre.
331
+ - `press_fit = true` with `glue`: the part is pressed into the one it is
332
+ glued to, as an inlay, so the two overlap on purpose and are not
333
+ checked against each other.
305
334
  - `glue = "name"`, `face = "top"`: the part is glued flat on that part's
306
335
  top (or bottom) face; its `at` and `rotate` are measured on the face,
307
336
  and the parts list says what it is glued to. With as many copies as
@@ -345,7 +374,14 @@ material(thickness = 4, kerf = 0.12, name = "birch") {
345
374
  to 128. `shape = "ball"` (or `sides = 0`) is a ball of diameter `size`
346
375
  midway between `from` and `to`; `to` may be left out. It comes back with
347
376
  `sides = 0` and `from` and `to` both at its centre. `render()` returns it
348
- as `hardware`, and `kerf check` lists it.
377
+ as `hardware`, and `kerf check` lists it. A `"tealight"` stands at
378
+ `from`, 39 mm across and 16 mm high unless `to` and `size` say
379
+ otherwise; tealights, LEDs and bulbs give off light.
380
+ - `light(at, color = "warm white", lumens = 20, to, flicker = false,
381
+ label)` is a light source with nothing to show for it, at a point or,
382
+ with `to`, all along a strip. `render()` returns every light, those of
383
+ tealights, LEDs and bulbs too, as `lights`; the 3D view lights the model
384
+ with them and GLB files carry them.
349
385
  - Shapes outside any part form one part named `part`.
350
386
  - `material(thickness, kerf, name) { ... }` sets those special variables for
351
387
  its children.
@@ -364,25 +400,29 @@ export examples.
364
400
 
365
401
  ### Shapes
366
402
 
367
- | Module | Notes |
368
- | ---------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------- |
369
- | `rect(size, center = false, r = 0)` | `size` is a number or `[w, h]`; `r` rounds the corners. `square` is an alias |
370
- | `circle(r)` or `circle(d = ...)` | |
371
- | `ellipse([rx, ry])` or `ellipse(d = [w, h])` | radii, or the width and height |
372
- | `regular_polygon(n, r)` | corner radius `r` |
373
- | `star(n, r, inner)` | |
374
- | `polygon(points, paths)` | even-odd fill, `paths` lists point indexes per outline |
375
- | `path(d, fill = "evenodd", close = false)` | SVG path data; closed subpaths become shapes, open ones lines unless `close` |
376
- | `text(text, size = 10, font, halign, valign, spacing = 1)` | `halign`: left, center, right; `valign`: baseline, top, center, bottom, or cap (capitals centred on y = 0) |
377
- | `text(text, size, fit = width)` | no wider than `fit`: the size shrinks to fit, never above `size` if given |
378
- | `text(text, size, fit = [w, h])` | no wider than `w`, capitals no taller than `h`; either may be `undef` |
379
- | `text(text, size, weight = "bold")` | strokes thickened by 3.5% of the size, or by a number of mm (less than 0 thins) |
380
- | `text(text, size, bridge = w)` | every island (an i's dot, an accent, a stencil's counter) joined to the rest by a strip `w` wide, for cut-out and stencil lettering |
381
- | `line(from, to)` | a line, not an area |
382
- | `line(from, to, width)` | a strip `width` wide between the points, an area |
383
- | `spline(points, width, steps = 8, closed = false)` | a smooth curve through the points; with `width`, an area along it |
384
- | `polyline(points, closed = false)` | |
385
- | `arc(r, start = 0, end = 90)` | arc line, angles in degrees |
403
+ | Module | Notes |
404
+ | ---------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
405
+ | `rect(size, center = false, r = 0)` | `size` is a number or `[w, h]`; `r` rounds the corners. `square` is an alias |
406
+ | `circle(r)` or `circle(d = ...)` | |
407
+ | `ellipse([rx, ry])` or `ellipse(d = [w, h])` | radii, or the width and height |
408
+ | `regular_polygon(n, r)` | corner radius `r` |
409
+ | `star(n, r, inner)` | |
410
+ | `polygon(points, paths)` | even-odd fill, `paths` lists point indexes per outline |
411
+ | `path(d, fill = "evenodd", close = false)` | SVG path data; closed subpaths become shapes, open ones lines unless `close` |
412
+ | `text(text, size = 10, font, halign, valign, spacing = 1)` | `halign`: left, center, right; `valign`: baseline, top, center, bottom, or cap (capitals centred on y = 0) |
413
+ | `text(text, size, fit = width)` | no wider than `fit`: the size shrinks to fit, never above `size` if given |
414
+ | `text(text, size, fit = [w, h])` | no wider than `w`, capitals no taller than `h`; either may be `undef` |
415
+ | `text(text, size, weight = "bold")` | strokes thickened by 3.5% of the size, or by a number of mm (less than 0 thins) |
416
+ | `text(text, size, bridge = w)` | every island (an i's dot, an accent, a stencil's counter) joined to the rest by a strip `w` wide, for cut-out and stencil lettering |
417
+ | `text(text, size, weld = true)` | each word's letters slid together until each overlaps the one before (by a tenth of the size and at least 1.5 mm, or by `weld` mm when it is a number), so a name cuts out in one piece, as script names on key rings and toppers are; `underline = h` adds a bar `h` high under the baseline that joins the words; what is still loose, as an i's dot, warns |
418
+ | `text(text, size, lines = n)` | a block of lines: a `"\n"` in the text breaks a line, and the text breaks at spaces into up to `n` lines in all, as even as they go; with `fit`, as many lines as let the text be biggest, so a long name fills a tag in two; `line_spacing = 1` sets the distance between lines; `halign` aligns each line and `valign` the block |
419
+ | `text(text, size, path = points)` | laid along the path through the points, each letter turned to it, its baseline on the path; centred on the path, or `halign` puts the start or end there; a warning if it runs past an end |
420
+ | `text(text, size, arc = r)` | round a circle of radius `r` about the origin: centred over the top, reading round it, or with `r` less than 0 along the bottom, reading left to right |
421
+ | `line(from, to)` | a line, not an area |
422
+ | `line(from, to, width)` | a strip `width` wide between the points, an area |
423
+ | `spline(points, width, steps = 8, closed = false)` | a smooth curve through the points; with `width`, an area along it |
424
+ | `polyline(points, closed = false)` | |
425
+ | `arc(r, start = 0, end = 90)` | arc line, angles in degrees |
386
426
 
387
427
  Supply geometry as children of a shape-processing module, for example
388
428
  `translate([10, 0]) circle(d = 5);`. Fonts used by `text()` must be supplied
@@ -425,6 +465,14 @@ playground, the command line and `kerfscript.wasm` have `Atkinson`
425
465
  | `stroke(width)` | turns lines into areas of that width, for cutting single line art |
426
466
  | `outline()` | turns areas into their outline lines |
427
467
 
468
+ As in OpenSCAD, a child that makes nothing at all is left out of
469
+ `difference()` and `intersection()`: an `if` whose condition is false and
470
+ that has no `else`, an `echo()` or `assert()` with no children, or a child
471
+ switched off with `*`. It neither empties an intersection nor becomes the
472
+ shape a difference cuts from. Any other child counts even when it draws
473
+ nothing, such as a `for` over an empty list or an empty `union()`, and
474
+ then empties an intersection.
475
+
428
476
  ### Joinery
429
477
 
430
478
  | Module | Notes |
@@ -1,4 +1,4 @@
1
- import { type Bend, type Poly } from './geometry.cjs';
1
+ import { type Bend, type Fold, type Poly } from './geometry.cjs';
2
2
  export type Vec3 = [number, number, number];
3
3
  export interface Placement {
4
4
  at: Vec3;
@@ -10,12 +10,16 @@ export interface AssemblyPart {
10
10
  copy: number;
11
11
  thickness: number;
12
12
  material?: string;
13
+ paint?: string;
13
14
  matrix: number[];
14
15
  outline: Poly[];
15
16
  placed: boolean;
16
17
  bends?: Bend[];
18
+ folds?: Fold[];
17
19
  step?: number;
18
20
  stack?: number;
21
+ glued?: number;
22
+ pressFit?: boolean;
19
23
  marks?: Mark[];
20
24
  }
21
25
  export interface Mark {
@@ -45,6 +49,21 @@ export declare function bendRuns(bends: Bend[], t: number): number[][];
45
49
  export declare function bendPoint(bends: Bend[], t: number, p: Vec3): Vec3;
46
50
  export declare function runOf(bends: Bend[], x: number): number;
47
51
  export declare function bentPieces(p: AssemblyPart): AssemblyPart[];
52
+ /** A folded part's panels, each its outline and the 4 x 4 matrix that
53
+ * folds it, in the part's own coordinates. The folds cut the part into
54
+ * panels; the panel at the origin (else the biggest) stays flat, and each
55
+ * other one turns about the folds between it and that one, towards the
56
+ * top face for an angle more than 0, hinged on the face it folds towards.
57
+ * `unused` lists the folds that do not divide the part. */
58
+ export declare function foldPanels(outline: Poly[], folds: Fold[], thickness: number): {
59
+ outline: Poly[];
60
+ matrix: number[];
61
+ }[] & {
62
+ unused?: number[];
63
+ };
64
+ /** The marks on one panel of a folded part: fills clipped to it, lines
65
+ * (and the outlines of line marks) cut where they leave it */
66
+ export declare function panelMarks(marks: Mark[], panel: Poly[]): Mark[];
48
67
  /** The most bands a part's bends are cut into for a 3D view */
49
68
  export declare const MAX_BENT_BANDS = 2000;
50
69
  export declare function meshPieces(regions: Poly[], bends?: Bend[], step?: number): Poly[][];
@@ -1,4 +1,4 @@
1
- import { type Bend, type Poly } from './geometry.js';
1
+ import { type Bend, type Fold, type Poly } from './geometry.js';
2
2
  export type Vec3 = [number, number, number];
3
3
  export interface Placement {
4
4
  at: Vec3;
@@ -10,12 +10,16 @@ export interface AssemblyPart {
10
10
  copy: number;
11
11
  thickness: number;
12
12
  material?: string;
13
+ paint?: string;
13
14
  matrix: number[];
14
15
  outline: Poly[];
15
16
  placed: boolean;
16
17
  bends?: Bend[];
18
+ folds?: Fold[];
17
19
  step?: number;
18
20
  stack?: number;
21
+ glued?: number;
22
+ pressFit?: boolean;
19
23
  marks?: Mark[];
20
24
  }
21
25
  export interface Mark {
@@ -45,6 +49,21 @@ export declare function bendRuns(bends: Bend[], t: number): number[][];
45
49
  export declare function bendPoint(bends: Bend[], t: number, p: Vec3): Vec3;
46
50
  export declare function runOf(bends: Bend[], x: number): number;
47
51
  export declare function bentPieces(p: AssemblyPart): AssemblyPart[];
52
+ /** A folded part's panels, each its outline and the 4 x 4 matrix that
53
+ * folds it, in the part's own coordinates. The folds cut the part into
54
+ * panels; the panel at the origin (else the biggest) stays flat, and each
55
+ * other one turns about the folds between it and that one, towards the
56
+ * top face for an angle more than 0, hinged on the face it folds towards.
57
+ * `unused` lists the folds that do not divide the part. */
58
+ export declare function foldPanels(outline: Poly[], folds: Fold[], thickness: number): {
59
+ outline: Poly[];
60
+ matrix: number[];
61
+ }[] & {
62
+ unused?: number[];
63
+ };
64
+ /** The marks on one panel of a folded part: fills clipped to it, lines
65
+ * (and the outlines of line marks) cut where they leave it */
66
+ export declare function panelMarks(marks: Mark[], panel: Poly[]): Mark[];
48
67
  /** The most bands a part's bends are cut into for a 3D view */
49
68
  export declare const MAX_BENT_BANDS = 2000;
50
69
  export declare function meshPieces(regions: Poly[], bends?: Bend[], step?: number): Poly[][];