@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
@@ -73,6 +73,7 @@ The URL should point to a font file provided by your application.
73
73
  | `assembly` | One entry per copy of a part with `name`, `copy`, `thickness`, `material`, `outline`, a 4 × 4 `matrix` and `placed`, for showing the design put together. Parts without `at` or `rotate` have `placed: false`. A bent part has `bends`; a part in a step has `step`; `marks` holds what is engraved and scored on it, front and back |
74
74
  | `steps` | The text of each assembly step, in order; a part's `step` counts from 1 |
75
75
  | `hardware` | Each `hardware()`: `kind`, `from`, `to`, `size`, `up`, `sides`, `step` and `label` |
76
+ | `lights` | Each light, from a tealight, LED, bulb or `light()`: `from` and `to` (the same point unless it is a strip), `color`, `lumens`, `flicker`, `source`, `step` and `label` |
76
77
  | `paths` | Layer paths with `name`, `mode`, `color`, `d`, `regions` and `lines` |
77
78
  | `layers` | Layer definitions in output order |
78
79
  | `warnings` | Problems that did not stop the render |
@@ -164,10 +165,14 @@ Write the model in 3D, as [3D files](3d-files.md) describes:
164
165
  import { render, toModel } from '@mylasertools/kerfscript';
165
166
 
166
167
  const glb = toModel(render(source), 'glb');
167
- const print = toModel(render(source), '3mf', { layout: 'flat', markHeight: 0.6 });
168
+ const print = toModel(render(source), '3mf', { layout: 'print', markHeight: 0.6 });
168
169
  ```
169
170
 
170
171
  The format is `"glb"`, `"3mf"` or `"stl"`, and the result a `Uint8Array`.
172
+ `layout` is `"assembled"` (the default), `"flat"` (every part side by side,
173
+ front up) or `"print"` (each part with what is glued on it as one object of
174
+ coloured layers). Each entry of `result.assembly` with `glued` gives the
175
+ index of the entry it is glued on.
171
176
  `meshBodies(result, options)` gives the solid bodies (positions and
172
177
  triangles in millimetres, z up) for a viewer of your own; `toGlb()`,
173
178
  `to3mf()` and `toStl()` write a list of them. `result.flat` lists every copy
package/docs/layers.md CHANGED
@@ -97,7 +97,8 @@ engrave() translate([40, 20]) circle(d = 12);
97
97
 
98
98
  The rectangle and circle use separate engraving layers. You can assign each
99
99
  a different power in your laser software. Supported modes are `"cut"`,
100
- `"line"`, `"fill"` and `"guide"`.
100
+ `"line"`, `"fill"`, `"guide"` and `"paint"`. The colour is a hex colour
101
+ or a colour's name, as `"red"`.
101
102
 
102
103
  ## The back face
103
104
 
@@ -128,6 +129,28 @@ part("tile") {
128
129
  A child given the layer `""` is left out, but still covers the ones
129
130
  before it: a bare patch.
130
131
 
132
+ ## Painted areas
133
+
134
+ A layer with `mode = "paint"` marks areas painted by hand after cutting.
135
+ They are never in the files for the laser, but the 3D view and the print
136
+ layout show them in the layer's colour, on the part's own sheet:
137
+
138
+ ```kerf
139
+ layer("red", mode = "paint", color = "red");
140
+ layer("white", mode = "paint", color = "white");
141
+ part("mushroom", paint = "cream") {
142
+ circle(d = 60);
143
+ paint(["red", "white"]) {
144
+ translate([0, 8]) circle(d = 50);
145
+ for (p = [[-10, 18], [8, 22], [0, 4]]) translate(p) circle(d = 8);
146
+ }
147
+ }
148
+ ```
149
+
150
+ Paint is clipped to the part, and a paint layer with `side = "back"`
151
+ paints the face underneath. `part(paint = colour)` paints the whole part;
152
+ see [Parts and sheets](parts-and-sheets.md).
153
+
131
154
  ## Printing on parts
132
155
 
133
156
  To print on the parts and then cut them, `layer(name, mode = "fill",
package/docs/library.md CHANGED
@@ -22,7 +22,7 @@ show each module's description when you hover over it.
22
22
  | [`kerf/box`](#boxes) | Finger-jointed boxes and dividers that slide into them |
23
23
  | [`kerf/tabs`](#tabs-and-slots) | Tabs on one panel and the slots in another that they go into |
24
24
  | [`kerf/stand`](#stands) | A sign or photo standing in a base, upright or leaning back |
25
- | [`kerf/hinge`](#living-hinges) | Living hinges that bend flat sheet, and a box with round sides |
25
+ | [`kerf/hinge`](#living-hinges) | Living hinges that bend flat sheet, round boxes and bent walls |
26
26
  | [`kerf/dividers`](#dividers) | Dividers that slot into each other like an egg crate |
27
27
  | [`kerf/hanging`](#hanging) | Keyholes, holes and loops for hanging things on a wall |
28
28
  | [`kerf/enclosure`](#enclosures) | Boxes with a screwed-on lid, cutouts for ports and vents |
@@ -264,17 +264,123 @@ Wrap it in `place()` with the plate's placement, put the other plate
264
264
  `width` away, and give both plates `slots`: they cut the slots for the
265
265
  tabs where the strip passes through them. Segments of the path shorter
266
266
  than `straight` are taken as curve; a sharp corner bends round radius
267
- `r`, two thicknesses by default. `narrow` uses `narrow_hinge()`.
267
+ `r`, two thicknesses by default, and the strip follows the rounded
268
+ corner: it is as long as the path with its corners rounded, and ends
269
+ where the path ends. A path with no curve or corner makes a straight
270
+ strip. Sample a curve with segments shorter than `straight`: a curve
271
+ sampled more coarsely is cut as straight runs with a sharp bend at each
272
+ point. `narrow` uses `narrow_hinge()`.
273
+
274
+ ### `wall(outline, depth, name = "wall", join, max_length = 400, rim, seam = 0.3, tabs = true, straight = 10, r, spacing = 1.5, bridge = 3, narrow = false, at = [0, 0, 0], rotate = [90, 0, 0])`
275
+
276
+ A wall round a closed outline, as for a lantern, a light box or a round
277
+ case: a front plate, a back plate `depth` behind it, and a strip between
278
+ them that follows the outline, made by `flex_strip()`. The strip bends on
279
+ living hinges where the outline curves and has tabs where it runs
280
+ straight, and both plates cut the slots for them.
281
+
282
+ ```kerf
283
+ use <kerf/hinge>
284
+
285
+ // A lantern: two straights and two round ends, the seam at the bottom
286
+ outline = concat(
287
+ [for (a = [-90:5:90]) [100, 40] + 40 * [cos(a), sin(a)]],
288
+ [for (a = [90:5:270]) [40, 40] + 40 * [cos(a), sin(a)]]
289
+ );
290
+ wall(outline, 50, name = "lantern", join = [70, 0], max_length = 200) {
291
+ difference() {
292
+ offset(delta = 5) polygon(outline);
293
+ translate([70, 40]) circle(d = 40);
294
+ }
295
+ }
296
+ ```
297
+
298
+ - The strip's ends meet at the point of the outline nearest `join`: put
299
+ the seam on a straight, or where a cap or a foot will hide it. Without
300
+ `join` they meet in the middle of the longest side.
301
+ - Sharp corners of the outline are rounded as the strip bends round
302
+ them, radius `r` inside: the strip follows `strip_loop(outline)`.
303
+ - A strip longer than `max_length` is cut into pieces no longer, so each
304
+ fits the bed, split on a straight where one is near. The pieces meet
305
+ `seam` apart, so that bent on their hinges they don't press on each
306
+ other.
307
+ - The first child is the front plate, drawn as the outline is, with the
308
+ windows or art you cut in it; the second is the back plate. Without
309
+ them, each plate is the outline grown by `rim`, half a thickness and
310
+ 3 mm.
311
+ - The parts are `"<name> front"`, `"<name> back"` and `"<name> strip"`, or
312
+ `"<name> strip 1"`, `"<name> strip 2"` and so on for a strip in pieces.
313
+ `wall_pieces(outline, max_length, join, straight, r)` says how many
314
+ pieces there will be.
315
+ - It stands upright with the outline seen from the front, the back plate
316
+ behind it; `at` and `rotate` place it.
317
+
318
+ Sample the outline's curves with segments shorter than `straight`, as for
319
+ `flex_strip()`.
320
+
321
+ ### `wall_path(outline, join)`
322
+
323
+ A closed outline as the path round it from the point of it nearest
324
+ `join` all the way round to it again; without `join`, from the middle of
325
+ its longest side. `wall()` follows `wall_path(strip_loop(outline), join)`.
326
+
327
+ ### `path_part(path, s0, s1)`
328
+
329
+ The part of a path from `s0` to `s1` along it, its ends where those fall.
330
+
331
+ ### `wall_strip_names(name, pieces)`
332
+
333
+ The names of the strip's parts for a wall named `name` in that many
334
+ pieces, as `slots` lists them: `wall_strip_names("lantern", 2)` is
335
+ `["lantern strip 1", "lantern strip 2"]`.
336
+
337
+ ### `wall_splits(L, n, max_length, mids, halves)`
338
+
339
+ Where `wall()` splits a strip `L` long into `n` pieces no longer than
340
+ `max_length`: near even spacing, at a point of `mids` (the middles of the
341
+ straight runs) where one is near, else at one of `halves` (the middles of
342
+ the path's segments, where its bends end).
343
+
344
+ ### `strip_path(path, straight = 10, r)`
345
+
346
+ The path a strip bent along `path` follows: each sharp corner, where
347
+ two segments at least `straight` long meet, rounded to an arc whose
348
+ inside radius is `r` (two thicknesses by default), the middle of the
349
+ sheet tangent to both segments. A corner too tight for the segments
350
+ beside it rounds to the radius that fits half of each. `flex_strip()` is
351
+ as long as this path.
352
+
353
+ ### `strip_loop(outline, straight = 10, r)`
354
+
355
+ A closed outline with its sharp corners rounded as `strip_path()` rounds
356
+ a path's, each corner judged by its whole sides.
357
+
358
+ ### `strip_corner(a, p, b, straight = 10, r)`
359
+
360
+ The points of the rounded corner at `p`, coming from `a` and going on to
361
+ `b`, as `strip_path()` and `strip_loop()` round it: the arc, or `[p]`
362
+ where the corner is not sharp.
268
363
 
269
364
  ### `strip_bends(path, straight = 10, r)`
270
365
 
271
- The bends `flex_strip()` makes, as `[s0, s1, angle]` along the path:
366
+ The bends `flex_strip()` makes, as `[s0, s1, angle]` along the path with
367
+ its corners rounded by `strip_path()`:
272
368
  where each curve starts and ends and how far it turns, left positive.
273
- Give them to `part(bend = ...)` for a strip of your own.
369
+ A curve whose radius changes, such as a tight fillet running into a wide
370
+ arc, gives several bends end to end, one for each stretch of much the
371
+ same radius, so the bent strip follows the path. Give them to
372
+ `part(bend = ...)` for a strip of your own.
373
+
374
+ ### `strip_join(list)`
375
+
376
+ Joins bends that touch or overlap where they turn the same way at much
377
+ the same rate, within a quarter of each other; `strip_bends()` uses it.
378
+ Two that overlap but turn differently meet halfway through the overlap.
274
379
 
275
380
  ### `strip_merge(list)`
276
381
 
277
- Joins bends from `strip_bends()` that touch into one.
382
+ Joins bends that touch into one, whatever their radius: the stretches
383
+ `flex_strip()` cuts its hinges over.
278
384
 
279
385
  ## Dividers
280
386
 
@@ -713,10 +819,16 @@ The sector's `[outer radius, inner radius, angle, slant length]`.
713
819
 
714
820
  A lock with a key, for boxes, diaries and money boxes. A flat key turns an
715
821
  eccentric cam that slides a bolt; half a turn throws its nose out past the
716
- lock's top edge into a notch in whatever it locks. It is three layers of
822
+ lock's top edge into a slot in whatever it locks. It is three layers of
717
823
  the current material: a base, a frame with the cam and the bolt, and a
718
824
  plate with the keyhole.
719
825
 
826
+ A bolt only holds against a pull across its travel. Set the lock so the
827
+ bolt moves across the way the locked part opens, sideways for a lid that
828
+ lifts, and cut the slot as a pocket with wood on the side the part pulls
829
+ from, not a notch open that way. `examples/lock-box.kerf` shows both: the
830
+ bolt slides sideways into a pocket in a keeper under the lid.
831
+
720
832
  ### `cam_lock(throw = 7, locked = true, name = "Lock", key = true, ring = true)`
721
833
 
722
834
  The lock's parts, lying flat with the key's axis on the z axis and the
@@ -727,7 +839,7 @@ cover. `throw` is how far the bolt moves; `locked` shows it thrown;
727
839
  ### `lock_bounds(throw = 7)`, `lock_nose(throw = 7)`
728
840
 
729
841
  The lock's outline as `[x0, y0, x1, y1]` round the key's axis, and the
730
- bolt's nose as `[width, y of its tip when locked]`: cut a notch a little
842
+ bolt's nose as `[width, y of its tip when locked]`: cut a pocket a little
731
843
  wider than the nose where it goes.
732
844
 
733
845
  ### `lock_key(t = $thickness, ws = 5)`, `lock_dims(throw)`
@@ -891,8 +1003,9 @@ centred on the origin, `shape_centre(points)` centres them, and
891
1003
 
892
1004
  `use <kerf/sizes>`
893
1005
 
894
- Paper, card and photo sizes in millimetres, for holders, folders, frames
895
- and boxes made to fit them.
1006
+ Paper, card, photo and banknote sizes in millimetres, and the sizes of
1007
+ bought parts and everyday things, for holders, folders, frames and boxes
1008
+ made to fit them.
896
1009
 
897
1010
  ### `paper_size(name)`, `card_size(name)`, `photo_size(name)`
898
1011
 
@@ -900,21 +1013,46 @@ and boxes made to fit them.
900
1013
  `"B4"` to `"B6"`, `"C4"` to `"C6"`, `"DL"`, `"letter"`, `"legal"`,
901
1014
  `"tabloid"`, `"half letter"`, `"executive"`, `"pocket"` and `"traveler"`,
902
1015
  standing; cards `"business"`, `"us business"`, `"credit"`, `"japan"`,
903
- `"playing"`, `"bridge"`, `"tarot"`, `"postcard"` and `"us postcard"`, and
1016
+ `"playing"`, `"bridge"`, `"tarot"`, `"postcard"`, `"us postcard"` and
1017
+ `"gift card"`, and
904
1018
  photos `"4x6"`, `"5x7"`, `"8x10"`, `"10x15"`, `"13x18"` and the instant
905
1019
  film sizes `"instant mini"`, `"instant square"`, `"instant wide"` and
906
1020
  `"instant classic"`, lying down. An unknown name stops with the list of
907
1021
  known ones.
908
1022
 
1023
+ ### `note_size(name)`
1024
+
1025
+ A banknote's `[width, height]`, lying down: `"usd"` (every US note is the
1026
+ same size), `"cad"` (every Canadian note), `"eur 5"` to `"eur 200"`,
1027
+ `"gbp 5"` to `"gbp 50"` and `"aud 5"` to `"aud 100"`. For a wallet or a
1028
+ money gift holder, fit the largest note it is for.
1029
+
909
1030
  ### `part_size(name)`
910
1031
 
911
- A bought part's sizes as a record: `body = [width, depth, height]`, and
912
- for a part with a shaft its diameter `shaft`, the `shaft_length` it stands
913
- out of the body and the `hole` to cut for it. `"music-18"` is an 18-note
914
- wind-up music box movement (its shaft is the winding key's), and
915
- `"quartz-clock"` a 56 mm quartz clock movement with the 16.5 mm shaft, for
916
- dials up to `dial = 8` mm thick. `"marble-16"` and `"marble-25"` are
917
- marbles. These are common retail sizes, which vary: measure yours.
1032
+ The sizes of a bought part or an everyday thing as a record: `body =
1033
+ [width, depth, height]`; for a round one its `diameter` and `height` (an
1034
+ egg's `length`); for one with a shaft its diameter `shaft`, the
1035
+ `shaft_length` it stands out of the body; and the `hole` to cut for it,
1036
+ where there is one.
1037
+
1038
+ | Name | What it is |
1039
+ | ------------------------------------------------ | -------------------------------------------------------------------------------- |
1040
+ | `"music-18"` | an 18-note wind-up music box movement; its shaft is the winding key's |
1041
+ | `"quartz-clock"` | a 56 mm quartz clock movement with the 16.5 mm shaft, for dials up to `dial = 8` |
1042
+ | `"tealight"`, `"maxi tealight"` | 39 × 16 and 59 × 24, with a `hole` to stand one in |
1043
+ | `"led tealight"`, `"led puck"` | battery lights, 38 × 36 with the flame and 70 × 25 |
1044
+ | `"fairy lights"` | the battery box of a string of them, and its `wire` |
1045
+ | `"hen egg"`, `"chocolate egg"` | 44 and 40 across, 57 and 60 long |
1046
+ | `"wine bottle"` | 76 across and 300 high, its `neck` 30 across |
1047
+ | `"magnet 6x2"`, `"magnet 10x3"`, `"magnet 12x3"` | disc magnets, with a `hole` to press one into |
1048
+ | `"key ring 25"` | a 25 mm split key ring |
1049
+ | `"battery box 2aa"`, `"battery box 3aa"` | closed battery boxes with a switch |
1050
+ | `"coin cell holder"` | a holder for a CR2032 cell |
1051
+ | `"key fob"` | a car key fob |
1052
+ | `"tissue box"`, `"tissue cube"` | tissue boxes, long and cube |
1053
+ | `"marble-16"`, `"marble-25"` | marbles |
1054
+
1055
+ These are common retail sizes, which vary: measure yours.
918
1056
 
919
1057
  ```kerf
920
1058
  use <kerf/sizes>
@@ -923,6 +1061,19 @@ m = part_size("quartz-clock");
923
1061
  part("dial") difference() { circle(d = 160); circle(d = m.hole); }
924
1062
  ```
925
1063
 
1064
+ ```kerf
1065
+ use <kerf/sizes>
1066
+
1067
+ egg = part_size("hen egg");
1068
+ // A ring an egg sits in, a little over half its width
1069
+ part("egg cup") difference() { circle(d = egg.diameter + 16); circle(d = egg.diameter * 0.75); }
1070
+ ```
1071
+
1072
+ ### `size_list(kind)`
1073
+
1074
+ The names in one table, as a list, for a customizer menu: `"paper"`,
1075
+ `"card"`, `"photo"`, `"note"` or `"part"`, as `// [size_list("note")]`.
1076
+
926
1077
  ### `landscape(size)`, `portrait(size)`
927
1078
 
928
1079
  A size turned to lie wider than tall, or to stand taller than wide.
@@ -932,6 +1083,294 @@ A size turned to lie wider than tall, or to stand taller than wide.
932
1083
  The size of a name in a table of `[name, size]`, the names in it, and the
933
1084
  name an older name stands for in a table of `[old, new]`.
934
1085
 
1086
+ ## Drawers
1087
+
1088
+ `use <kerf/drawers>`
1089
+
1090
+ A carcass of small numbered drawers in a grid, as for an advent calendar,
1091
+ behind a façade of any shape: a finger-jointed box open at the front,
1092
+ shelves and walls halved into each other inside it, and a drawer in each
1093
+ cell with its number engraved on the front.
1094
+
1095
+ ```kerf
1096
+ use <kerf/drawers>
1097
+
1098
+ $thickness = 3;
1099
+ // 24 drawers, numbered in a shuffled order, behind a house front
1100
+ drawers(4, 6, [40, 30], 60, shuffle = 7) {
1101
+ polygon([[-10, -5], [185, -5], [185, 200], [87.5, 260], [-10, 200]]);
1102
+ }
1103
+ ```
1104
+
1105
+ ### `drawers(cols = 4, rows = 6, cell = [40, 30], depth = 60, numbers, shuffle, pull = "notch", ease = 0.8, clearance = 0.15, open = 0, font_size, label = "")`
1106
+
1107
+ `cols` by `rows` drawers, each cell `[w, h]` inside and the carcass `depth`
1108
+ deep, its front left bottom corner at the origin and the drawers facing
1109
+ -y. Drawers run on the shelves `ease` mm clear all round, and pull out
1110
+ `open` of their depth in the assembled view. `pull` is `"notch"` (a dip in
1111
+ the front's top edge), `"hole"` (a finger hole) or `"none"`. The numbers
1112
+ go row by row from the top left: 1 up, a list of your own in `numbers`
1113
+ (text works too), shuffled by a seed in `shuffle`, or none with `numbers
1114
+ = false`. Children are a façade, drawn on the carcass's front from its
1115
+ bottom left corner: the drawers' openings are cut through it, and it goes
1116
+ on in a step of its own. The parts are named after `label`, and the
1117
+ assembly is in steps: the carcass, the shelves and walls, the façade, the
1118
+ drawers.
1119
+
1120
+ ### `drawers_size(cols, rows, cell, depth)`, `drawers_numbers(n, numbers, shuffle)`
1121
+
1122
+ The carcass's outer `[width, height, depth]`, for drawing a façade round
1123
+ it, and the numbers on the drawers.
1124
+
1125
+ ## Figures
1126
+
1127
+ `use <kerf/figures>`
1128
+
1129
+ Layered characters for ornaments, standees, scenes and cards, drawn for
1130
+ this library:
1131
+
1132
+ | Cast | Figures |
1133
+ | ------------- | ------------------------------------------------------------------------------------------------ |
1134
+ | `"christmas"` | `santa`, `elf`, `gnome`, `angel`, `reindeer`, `gingerbread`, `snowman` |
1135
+ | `"easter"` | `bunny`, `chick`, `lamb` |
1136
+ | `"halloween"` | `ghost`, `witch`, `pumpkin`, `bat`, `skeleton` |
1137
+ | `"nativity"` | `mary`, `joseph`, `baby`, `shepherd`, `caspar`, `melchior`, `balthasar`, `ox`, `donkey`, `sheep` |
1138
+ | `"animals"` | `bear`, `fox`, `cat`, `dog`, `owl`, `deer` |
1139
+
1140
+ A figure is built in layers, as layered wood art is. The **outline** is a
1141
+ backer of its whole silhouette, standing `border` mm proud of the rest.
1142
+ On it lie the coloured pieces of its **clothes** (an animal's coat) and its
1143
+ **face** (skin, bellies, beaks, ears) side by side, `gap` mm apart, so the
1144
+ backer shows between them as lines. On those lie the **details**: eyes,
1145
+ noses, buttons. Each layer comes in one or more colours.
1146
+
1147
+ ```kerf
1148
+ use <kerf/figures>
1149
+
1150
+ $thickness = 3;
1151
+ figure_parts("bunny", 80, at = [0, 0, 0], rotate = [90, 0, 0]);
1152
+ figure_parts("chick", 80, at = [70, 0, 0], rotate = [90, 0, 0]);
1153
+ ```
1154
+
1155
+ ### `figure_parts(name, height = 100, at = [0, 0, 0], rotate = [0, 0, 0], label, border = 2, gap = 0.6, qty = 1)`
1156
+
1157
+ The figure as layered parts, its outline `height` mm tall: the outline
1158
+ placed at `at` and turned by `rotate` (`[90, 0, 0]` stands it up), the
1159
+ clothes and face glued on it and the details on those. Each colour of each
1160
+ layer is a part of its own, painted that colour, so the 3D view and the
1161
+ print layout show the figure in colour and the sheets keep one wood. The
1162
+ parts are named after `label`, the figure's name unless given: `"bunny
1163
+ outline"`, `"bunny face pink"`, `"bunny details black"`. A detail too small to cut at that height, under `min_width` of
1164
+ `figure_layer()`, is left out.
1165
+
1166
+ ### `figure(name, height = 100, border = 2, gap = 0.6)`
1167
+
1168
+ The figure from one sheet: its outline cut, the lines between its coloured
1169
+ pieces scored, and its details engraved. Put it inside a `part()`.
1170
+
1171
+ ### `figure_layer(name, layer, height = 100, color, border = 2, gap = 0.6, min_width = 1.6)`
1172
+
1173
+ One layer of the figure as shapes: `"outline"`, `"clothes"`, `"face"` or
1174
+ `"details"`, every colour of it or only `color`. The outline is `height` mm
1175
+ tall, standing on y = 0 and centred on x = 0. Each piece loses what the
1176
+ pieces after it cover, `gap` wider, and any sliver narrower than
1177
+ `min_width`; details stay on the clothes and face.
1178
+
1179
+ ### `figure_names(cast)`, `figure_casts()`, `figure_layers(name)`
1180
+
1181
+ The names of the figures, all or those of one cast; the casts; and the
1182
+ parts a figure is built of, as `[layer, colour]` from the outline up, as
1183
+ `figure_parts()` makes them.
1184
+
1185
+ ### `figure_details(name, height, base, qty = 1, border = 2, gap = 0.6, k = 0)`
1186
+
1187
+ The figure's details as painted parts named after `base`, glued on the
1188
+ first of its clothes and face parts that is big enough to cut at that
1189
+ height, as `figure_parts()` and `scene_figure()` make them.
1190
+
1191
+ ### `figure_entry(name)`, `figure_shapes(shapes)`, `figure_unique(list)`
1192
+
1193
+ A figure's entry, `[name, cast, outline colour, pieces]`; the shapes of one
1194
+ of its pieces drawn, in the figure's own units; and a list without its
1195
+ repeats. Each figure is drawn 100 units tall as a list of pieces in
1196
+ painter's order, each `[layer, colour, shapes]`, the shapes circles,
1197
+ ellipses, round-ended strokes, rounded rectangles, polygons and smooth
1198
+ closed curves, as the library's comments describe.
1199
+
1200
+ ## Inlays
1201
+
1202
+ `use <kerf/inlay>`
1203
+
1204
+ Inlays of another wood, stock or colour: shapes cut out of one part, or
1205
+ engraved into it as pockets, and cut again as inserts that press into
1206
+ them. KerfScript takes the kerf off every cut, so a hole and an insert of
1207
+ one shape come out the same size; each insert is `press` mm bigger all
1208
+ round so it holds.
1209
+
1210
+ ```kerf
1211
+ use <kerf/inlay>
1212
+ use <kerf/shapes>
1213
+
1214
+ $thickness = 3;
1215
+ // A walnut heart in a plywood plaque
1216
+ inlaid("plaque", materials = ["walnut"]) {
1217
+ rect([80, 60], r = 5);
1218
+ translate([40, 30]) heart(30);
1219
+ }
1220
+ ```
1221
+
1222
+ ### `inlaid(name, depth, press = 0.05, materials, paints, at = [0, 0, 0], rotate = [0, 0, 0])`
1223
+
1224
+ A part with inlays: its first child is the part's shape, and each child
1225
+ after it an inlay's shape. The inlays are cut through the part, or with
1226
+ `depth` engraved that deep on the layer `"pocket"` (set its power for the
1227
+ depth). Each inlay is an insert of its own, `"name inlay 1"` up, `press`
1228
+ mm bigger all round, of `materials[i]` (on a sheet of its own) or painted
1229
+ `paints[i]`; a pocket's insert is `depth` thick. In the assembled view a
1230
+ through insert sits in its hole and a pocket's on the surface over it.
1231
+
1232
+ ## Layered art
1233
+
1234
+ `use <kerf/layered>`
1235
+
1236
+ Multilayer pieces from one drawing, as layered ornaments, mandalas, wreaths
1237
+ and signs are made. The children are the art's layers, back to front; each
1238
+ becomes a part of its own, glued on the one behind it and painted its
1239
+ colour, so the 3D view and the print layout show it built up.
1240
+
1241
+ ```kerf
1242
+ use <kerf/layered>
1243
+
1244
+ $thickness = 3;
1245
+ layered("tree", colors = ["dark green", "green", "light green", "gold"], shadow = 2, hole = [0, 52, 4]) {
1246
+ regular_polygon(3, 40);
1247
+ translate([0, 8]) regular_polygon(3, 28);
1248
+ translate([0, 16]) regular_polygon(3, 16);
1249
+ translate([0, 40]) star(5, 7, 3);
1250
+ }
1251
+ ```
1252
+
1253
+ ### `layered(name = "layered", colors, border = 2, shadow = 0, shadow_color = "dark grey", hole, at = [0, 0, 0], rotate = [0, 0, 0])`
1254
+
1255
+ One part a layer, named `"name layer 1"` up from the back. Each layer is
1256
+ its own drawing joined with everything in front of it grown by `border`
1257
+ mm, so every layer is held up by the one behind and shows as a rim round
1258
+ it. `colors` gives each layer's paint, back to front; without it they go
1259
+ from dark brown at the back to white at the front. `shadow` adds a layer
1260
+ at the back that much wider again, in `shadow_color`. `hole = [x, y, d]`
1261
+ cuts a hole `d` across through every layer, to hang it by. The back layer
1262
+ goes at `at`, turned by `rotate`; a layer may be several pieces.
1263
+
1264
+ ### `layered_color(colors, k, n)`
1265
+
1266
+ The colour of layer `k` of `n`: `colors[k]`, else the palette from dark at
1267
+ the back to light at the front.
1268
+
1269
+ ## Balls and domes
1270
+
1271
+ `use <kerf/sphere>`
1272
+
1273
+ Slot-together balls and domes, as 3D baubles, globes and lantern domes:
1274
+ half-disc fins standing round an upright axis, like the segments of an
1275
+ orange, held by flat rings slotted onto them with halving joints. The fins
1276
+ stop short of the axis, so they never meet.
1277
+
1278
+ ```kerf
1279
+ use <kerf/sphere>
1280
+ use <kerf/scene>
1281
+
1282
+ $thickness = 3;
1283
+ // A bauble with a snowman standing inside it
1284
+ ball(140, fins = 6, hollow = 50, floor = true, at = [0, 0, 70]);
1285
+ scene_figure("snowman", 34, at = [0, 0, 71.5]);
1286
+ ```
1287
+
1288
+ ### `ball(d = 80, fins = 6, rings = 1, width = 8, hollow = 0, floor = false, dome = false, loop = 4, at = [0, 0, 0], label = "ball", clearance = 0.1)`
1289
+
1290
+ A ball `d` across, its centre at `at`: `fins` fins and `rings` rings
1291
+ `width` wide, the equator alone or spread from 60 degrees south to north.
1292
+ `dome = true` makes the top half, standing on its lowest ring. `hollow`
1293
+ cuts the fins away within that radius, to make room for a scene inside,
1294
+ and `floor = true` makes the lowest ring a whole disc for it to stand on,
1295
+ with a rail across the hollow for a standee's feet. `loop` puts a hole of
1296
+ that diameter near the top of each fin for a ribbon to hang it by. The
1297
+ parts are `"ball fin"` and `"ball ring 1"` up, named after `label`.
1298
+
1299
+ ### `ball_rings(d, rings = 1, dome = false)`
1300
+
1301
+ The heights of a ball's rings above its centre.
1302
+
1303
+ ## Scenes
1304
+
1305
+ `use <kerf/scene>`
1306
+
1307
+ Scene boxes and dioramas. A floor (or a shelf) has **rails**: slots running
1308
+ across it, in rows from front to back. Every **standee** has 8 mm feet that
1309
+ go into any rail, so a scene changes by taking standees out and putting
1310
+ others in. A standee is drawn standing on y = 0, centred on x = 0.
1311
+
1312
+ ```kerf
1313
+ use <kerf/scene>
1314
+
1315
+ $thickness = 3;
1316
+ rows = scene_rows(90);
1317
+ part("floor", at = [-100, 0, 0]) scene_floor(200, 90);
1318
+ scene_figure("snowman", 70, at = [-50, rows[1], 3]);
1319
+ scene_figure("gnome", 26, at = [40, rows[0], 3]);
1320
+ part("trees", at = [0, rows[5] + 1.5, 3], rotate = [90, 0, 0]) standee(full = true) {
1321
+ translate([-90, 0]) rect([180, 14]);
1322
+ for (x = [-80:20:80]) translate([x, 14]) regular_polygon(3, 22);
1323
+ }
1324
+ ```
1325
+
1326
+ ### `scene_rows(depth, rows = 6)`
1327
+
1328
+ Where the rails of a floor `depth` mm deep run, as y from its front edge:
1329
+ `rows` of them, the first 8 mm from the front and the last 7 mm from the
1330
+ back. Six rails on a 90 mm floor are at 8, 23, 38, 53, 68 and 83.
1331
+
1332
+ ### `scene_floor(width, depth, rows = 6, clearance = 0.1, margin = 6, r = 0)`, `scene_rails(width, depth, rows = 6, clearance = 0.1, margin = 6)`
1333
+
1334
+ A floor `width` by `depth` with its rails cut, its front edge on y = 0; or
1335
+ only the rails, as slots to cut from a floor or shelf of your own. Each
1336
+ rail is `$thickness + clearance` wide and stops `margin` short of each
1337
+ side.
1338
+
1339
+ ### `standee(mound, full = false, tab = 8, floor, clip)`
1340
+
1341
+ Its children, a drawing, as a standee: `tab` mm feet below y = 0 that go
1342
+ `floor` mm (`$thickness` unless given) into a rail. The feet spread over
1343
+ the width the drawing stands on: one under 28 mm, two a quarter of the
1344
+ width either side of the middle otherwise, three across a `full` width
1345
+ backdrop. A narrow standee stands on a mound 4.5 mm high, which `mound`
1346
+ sets; without one, a ground line 2 mm high joins legs that meet the floor
1347
+ apart. With `clip`, a polygon's points, the drawing is clipped to it and
1348
+ the feet left whole, as for a standee inside a round case.
1349
+
1350
+ ### `standee_feet(width, full = false)`, `standee_mound(width)`
1351
+
1352
+ Where the feet go across a standee `width` wide, from its middle, and the
1353
+ mound under it.
1354
+
1355
+ ### `scene_figure(name, height = 60, at = [0, 0, 0], turn = 0, label, mound, floor, border = 2, gap = 0.6)`
1356
+
1357
+ A layered figure from [`kerf/figures`](#figures) standing in a rail: its
1358
+ backer a standee, the other layers glued on its front, each colour a
1359
+ painted part. `at` is where its feet go, `[x, the rail's y, the floor's
1360
+ top z]`, and `turn` turns it about them.
1361
+
1362
+ ### `figure_base(name, height = 80, base = [60, 20], at = [0, 0, 0], label, clearance = 0.1, r = 3)`
1363
+
1364
+ A layered figure on a base of its own, to stand on a shelf: a base plate
1365
+ with one rail, centred on `at`, the figure's feet in it.
1366
+
1367
+ ### `drip_edge(width, height = 6, depth = 8, n, seed = 1)`, `wave_edge(width, height = 6, depth = 4, n)`
1368
+
1369
+ Edges for snow, icing, water and frills: a strip `width` wide and `height`
1370
+ tall above y = 0, with `n` round drips hanging below it up to `depth` mm,
1371
+ their lengths varied by `seed`; or with `n` waves `depth` mm deep along
1372
+ its bottom.
1373
+
935
1374
  ## Symbols
936
1375
 
937
1376
  `use <kerf/symbols>`
@@ -950,7 +1389,7 @@ part("tag") {
950
1389
  }
951
1390
  ```
952
1391
 
953
- ### `symbol(name, size = 10, center = true, fill = "nonzero", box = "drawn", solid = false, close, bridge)`
1392
+ ### `symbol(name, size = 10, center = true, fill = "nonzero", box = "drawn", solid = false, close, bridge, min_width)`
954
1393
 
955
1394
  The symbol `size` mm across the longer side of what it draws, centred on
956
1395
  the origin, or with its bottom left corner there. With `box = "grid"`,
@@ -964,6 +1403,11 @@ closed and holes filled, and the drawing's own detail engraved on it.
964
1403
  `bridge = w` also joins pieces too far apart to close, such as a moon
965
1404
  beside a mountain, with strips `w` wide.
966
1405
 
1406
+ A symbol drawn small has lines too thin to cut: a bird's legs, a bee's
1407
+ feelers. `min_width = 1.6` grows every line narrower than 1.6 mm to that
1408
+ width, so it can be cut and holds together; gaps narrower than it close
1409
+ up as the lines either side grow.
1410
+
967
1411
  ### `symbol_names(category)`, `symbol_size(name, size = 10, box = "drawn")`, `symbol_source(name)`, `symbol_entry(name)`
968
1412
 
969
1413
  The names of every symbol, or of one category; the `[width, height]` a