@mylasertools/kerfscript 0.9.0 → 0.11.0

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 (67) hide show
  1. package/CHANGELOG.md +287 -0
  2. package/LANGUAGE.md +100 -44
  3. package/README.md +2 -1
  4. package/dist/assembly.d.cts +22 -1
  5. package/dist/assembly.d.ts +22 -1
  6. package/dist/bores.d.cts +10 -0
  7. package/dist/bores.d.ts +10 -0
  8. package/dist/cli.js +9977 -6847
  9. package/dist/colors.d.cts +4 -0
  10. package/dist/colors.d.ts +4 -0
  11. package/dist/customizer.d.cts +3 -0
  12. package/dist/customizer.d.ts +3 -0
  13. package/dist/effects.d.cts +31 -0
  14. package/dist/effects.d.ts +31 -0
  15. package/dist/evaluator.d.cts +10 -1
  16. package/dist/evaluator.d.ts +10 -1
  17. package/dist/export/mesh.d.cts +66 -0
  18. package/dist/export/mesh.d.ts +66 -0
  19. package/dist/export/model.d.cts +14 -0
  20. package/dist/export/model.d.ts +14 -0
  21. package/dist/export/pages.d.cts +23 -0
  22. package/dist/export/pages.d.ts +23 -0
  23. package/dist/export/triangulate.d.cts +5 -0
  24. package/dist/export/triangulate.d.ts +5 -0
  25. package/dist/export/zip.d.cts +5 -0
  26. package/dist/export/zip.d.ts +5 -0
  27. package/dist/geometry.d.cts +21 -0
  28. package/dist/geometry.d.ts +21 -0
  29. package/dist/hardware.d.cts +2 -0
  30. package/dist/hardware.d.ts +2 -0
  31. package/dist/highlight.cjs +2 -2
  32. package/dist/highlight.js +2 -2
  33. package/dist/import/dbg.d.cts +1 -0
  34. package/dist/import/dbg.d.ts +1 -0
  35. package/dist/index.cjs +1693 -75
  36. package/dist/index.d.cts +9 -3
  37. package/dist/index.d.ts +9 -3
  38. package/dist/index.js +1693 -75
  39. package/dist/instructions.d.cts +27 -0
  40. package/dist/instructions.d.ts +27 -0
  41. package/dist/language.cjs +1664 -53
  42. package/dist/language.js +1664 -53
  43. package/dist/libraries.cjs +1641 -36
  44. package/dist/libraries.js +1641 -36
  45. package/dist/lights.d.cts +38 -0
  46. package/dist/lights.d.ts +38 -0
  47. package/dist/png.d.cts +14 -0
  48. package/dist/png.d.ts +14 -0
  49. package/dist/render.d.cts +8 -0
  50. package/dist/render.d.ts +8 -0
  51. package/dist/signatures.cjs +98 -9
  52. package/dist/signatures.js +98 -9
  53. package/dist/text.d.cts +29 -0
  54. package/dist/text.d.ts +29 -0
  55. package/dist/verify/types.d.cts +6 -0
  56. package/dist/verify/types.d.ts +6 -0
  57. package/docs/3d-files.md +93 -0
  58. package/docs/cli.md +38 -22
  59. package/docs/customizer.md +69 -0
  60. package/docs/javascript.md +51 -0
  61. package/docs/layers.md +24 -1
  62. package/docs/library.md +574 -16
  63. package/docs/openscad.md +15 -13
  64. package/docs/parts-and-sheets.md +207 -29
  65. package/docs/verification.md +1 -1
  66. package/docs/versions.md +2 -2
  67. package/package.json +1 -1
package/docs/library.md CHANGED
@@ -21,7 +21,8 @@ show each module's description when you hover over it.
21
21
  | ---------------------------------- | -------------------------------------------------------------- |
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
- | [`kerf/hinge`](#living-hinges) | Living hinges that bend flat sheet, and a box with round sides |
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, round boxes and bent walls |
25
26
  | [`kerf/dividers`](#dividers) | Dividers that slot into each other like an egg crate |
26
27
  | [`kerf/hanging`](#hanging) | Keyholes, holes and loops for hanging things on a wall |
27
28
  | [`kerf/enclosure`](#enclosures) | Boxes with a screwed-on lid, cutouts for ports and vents |
@@ -33,6 +34,7 @@ show each module's description when you hover over it.
33
34
  | [`kerf/rings`](#rings) | Round things of stacked rings on a crossed core |
34
35
  | [`kerf/joints`](#joints) | Two profiles halved into each other: crosses, fonts, domes |
35
36
  | [`kerf/fit`](#fit-and-align) | Drawings scaled to a size and placed by a point of their box |
37
+ | [`kerf/shapes`](#shapes) | Hearts, teardrops, clouds, shields, banners, tags and more |
36
38
  | [`kerf/sizes`](#sizes) | Paper, card and photo sizes |
37
39
  | [`kerf/symbols`](#symbols) | 867 pictograms by name |
38
40
  | [`kerf/geo`](#maps) | The world's land, for maps and globes |
@@ -41,6 +43,17 @@ Sizes are in millimetres. Joints use `$thickness`, the sheet thickness, so
41
43
  set it to what you measure. Each section has an example in the gallery that
42
44
  you can open in the playground.
43
45
 
46
+ ### Before you draw it yourself
47
+
48
+ | To | Use |
49
+ | -------------------------------------------------- | ------------------------------------------------------- |
50
+ | Draw a heart, a teardrop, a cloud, a banner or tag | [`kerf/shapes`](#shapes) |
51
+ | Draw a pictogram: a paw, a tree, a star, a house | `symbol("paw", size)` from [`kerf/symbols`](#symbols) |
52
+ | Scale a drawing to a box, or place it by a corner | `fit()` and `align()` from [`kerf/fit`](#fit-and-align) |
53
+ | Close small gaps between shapes | `close(r)`, in place of `offset(delta = -r) offset(r)` |
54
+ | Fit text to a width or a height | `text(fit = [w, h])`, and `text_size()` to measure it |
55
+ | Stand a sign or a photo up | `stand()` from [`kerf/stand`](#stands) |
56
+
44
57
  ## Boxes
45
58
 
46
59
  `use <kerf/box>`
@@ -126,6 +139,50 @@ is `true` or `false` for all four, or `[bottom, right, top, left]`.
126
139
  The centres of the tabs along an edge, for placing anything else that
127
140
  lines up with them.
128
141
 
142
+ ## Stands
143
+
144
+ `use <kerf/stand>`
145
+
146
+ A panel (a sign, a photo frame, a calendar) standing in a base, its tabs
147
+ through slots in the base, upright or leaning back. `stand()` makes both
148
+ parts and puts them together; the tabs and slots always match, at any
149
+ lean and `$thickness`.
150
+
151
+ ```kerf
152
+ use <kerf/stand>
153
+
154
+ stand(160, depth = 45, lean = 10) {
155
+ rect([160, 90], r = 6);
156
+ engrave() translate([80, 45]) text("OPEN", fit = [120, 40], halign = "center", valign = "cap");
157
+ }
158
+ ```
159
+
160
+ ### `stand(width, depth = 40, count, tab, lean = 0, margin = 10, back, r = 3, clearance = 0.1, name = "Sign")`
161
+
162
+ The children draw the panel, its bottom edge on y = 0 from x = 0 to
163
+ `width`; `stand()` adds the tabs. The base is `depth` deep, `margin` wider
164
+ than the panel on each side, with corners rounded to `r`. The panel leans
165
+ back by `lean` degrees (up to 45), its back face meeting the base `back`
166
+ from the front (half way by default). The parts are `name` and
167
+ `"name stand"`.
168
+
169
+ | Parameter | Default | Meaning |
170
+ | ----------- | ------------------------------- | ------------------------------------ |
171
+ | `count` | one for every 50 mm, at least 1 | Number of tabs |
172
+ | `tab` | half the space between tabs | Width of each tab |
173
+ | `clearance` | `0.1` | Added to each slot's width and depth |
174
+
175
+ ### `stand_tabs(width, count, tab, lean = 0)`
176
+
177
+ The tabs for the bottom edge of a panel, x from 0 to `width`, hanging below
178
+ y = 0 far enough to go through a base `$thickness` thick at that lean.
179
+
180
+ ### `stand_slots(width, count, tab, lean = 0, clearance = 0.1)`
181
+
182
+ The slots for `stand_tabs()` with the same `width`, `count`, `tab` and
183
+ `lean`, for a base of your own: x from 0 to `width`, for a panel whose back
184
+ face meets the top of the base on y = 0, leaning back towards +y.
185
+
129
186
  ## Living hinges
130
187
 
131
188
  `use <kerf/hinge>`
@@ -207,17 +264,123 @@ Wrap it in `place()` with the plate's placement, put the other plate
207
264
  `width` away, and give both plates `slots`: they cut the slots for the
208
265
  tabs where the strip passes through them. Segments of the path shorter
209
266
  than `straight` are taken as curve; a sharp corner bends round radius
210
- `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.
211
363
 
212
364
  ### `strip_bends(path, straight = 10, r)`
213
365
 
214
- 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()`:
215
368
  where each curve starts and ends and how far it turns, left positive.
216
- 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.
217
379
 
218
380
  ### `strip_merge(list)`
219
381
 
220
- 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.
221
384
 
222
385
  ## Dividers
223
386
 
@@ -767,12 +930,76 @@ the origin: `"center"`, `"left"`, `"right"`, `"top"`, `"bottom"`,
767
930
  `"top-left"`, `"top-right"`, `"bottom-left"`, `"bottom-right"`, or
768
931
  `[fx, fy]` as fractions of the box. `anchor_point()` gives those fractions.
769
932
 
933
+ ## Shapes
934
+
935
+ `use <kerf/shapes>`
936
+
937
+ Basic shapes by name, each sized to a box: `size` is `[w, h]`, or one
938
+ number for both, and the shape is centred on the origin as `circle()` and
939
+ `ellipse()` are. Arrows and chevrons point along x; the others stand
940
+ upright. Curves follow `$fn` when it is set, and otherwise take about a
941
+ point per millimetre.
942
+
943
+ ```kerf
944
+ use <kerf/shapes>
945
+
946
+ part("gift tag") {
947
+ tag([70, 36]);
948
+ engrave() translate([8, 0]) heart([16, 14]);
949
+ }
950
+ part("sign", at = [0, 50, 0]) {
951
+ banner([120, 30]);
952
+ engrave() text("WELCOME", fit = [80, 12], halign = "center", valign = "cap");
953
+ }
954
+ ```
955
+
956
+ A shape with one outline also has a `_points()` function that gives the
957
+ outline as points, counter-clockwise, with the same arguments: for
958
+ `offset_path()`, `flex_strip()`, `point_at()` and anything else that works
959
+ on a list of points. `heart_points(40)` is the outline of `heart(40)`.
960
+
961
+ | Shape | Draws |
962
+ | ------------------------------------------- | ----------------------------------------------------------------------------------------------- |
963
+ | `heart(size = 20)` | a heart: two round lobes, a dip between them and a point at the bottom |
964
+ | `teardrop(size = [14, 20])` | round at the bottom, a point at the top; taller than it is wide |
965
+ | `egg(size = [16, 20], taper = 0.2)` | an egg on its broad end; `taper` 0 is an ellipse |
966
+ | `lens(size = [10, 20])` | two arcs meeting in a point at each end of its longer side: a leaf, a petal, an eye |
967
+ | `crescent(d = 20, thickness)` | a crescent moon `d` across, open to the right, `thickness` (`d / 4`) at its widest |
968
+ | `capsule(size = [30, 10])` | a rectangle with round ends |
969
+ | `diamond(size = [14, 20])` | a rhombus touching the middle of each side of its box |
970
+ | `rounded_polygon(n = 6, r = 10, round = 2)` | `regular_polygon(n, r)` with each corner rounded to radius `round` |
971
+ | `shield(size = [16, 20], point = 0.55)` | a flat top and straight sides curving in to a point; `point` is the curve's part of `h` |
972
+ | `arrow(size = [30, 14], shaft, head)` | an arrow `size[0]` long with a head `size[1]` wide; `shaft` is `h / 3`, `head` `h` |
973
+ | `chevron(size = [12, 20], thickness)` | a chevron (>), each arm `thickness` (`w / 2`) across along x |
974
+ | `banner(size = [60, 16], notch)` | a banner with a V `notch` (`h / 3`) deep cut into each end |
975
+ | `house(size = [20, 24], roof)` | walls and a pitched roof `roof` (`w / 2`) tall |
976
+ | `tag(size = [50, 25], cut, hole)` | a tag with its left corners cut off by `cut` (`h / 4`) and a hole `hole` (`h / 4`) across |
977
+ | `ring(d = 20, width = 3)` | a ring `d` across with a band `width` wide |
978
+ | `scalloped(d = 30, n = 16)` | a circle `d` across with `n` round scallops round its edge |
979
+ | `flower(d = 30, petals = 6, center = 0.35)` | petals round a round middle `center` of `d` across |
980
+ | `cloud(size = [40, 24], puffs = 3)` | a flat bottom with `puffs` round puffs along the top |
981
+ | `speech_bubble(size = [40, 30], r, tail)` | a rounded box with a tail `tail` (`h / 4`) long at its bottom left; `mirror()` it for the right |
982
+
983
+ The outlines: `heart_points()`, `teardrop_points()`, `egg_points()`,
984
+ `lens_points()`, `crescent_points()`, `capsule_points()`,
985
+ `diamond_points()`, `rounded_polygon_points()`, `shield_points()`,
986
+ `arrow_points()`, `chevron_points()`, `banner_points()`, `house_points()`
987
+ and `tag_points()` (without the hole).
988
+
989
+ The library's helpers are there for your own shapes too:
990
+ `shape_size(size, what)` turns a number or `[w, h]` into `[w, h]` and
991
+ checks it, `shape_steps(length)` is the number of points for a curve about
992
+ `length` mm long, `shape_fill(points, size)` scales points to fill a box
993
+ centred on the origin, `shape_centre(points)` centres them, and
994
+ `shape_arc(c, r, a0, a1, n)` gives `n + 1` points along an arc. `shape_tall_lens([w, h])` is a lens pointed at the top and the bottom, as `lens()` draws one no wider than it is tall.
995
+
770
996
  ## Sizes
771
997
 
772
998
  `use <kerf/sizes>`
773
999
 
774
- Paper, card and photo sizes in millimetres, for holders, folders, frames
775
- and boxes made to fit them.
1000
+ Paper, card, photo and banknote sizes in millimetres, and the sizes of
1001
+ bought parts and everyday things, for holders, folders, frames and boxes
1002
+ made to fit them.
776
1003
 
777
1004
  ### `paper_size(name)`, `card_size(name)`, `photo_size(name)`
778
1005
 
@@ -780,21 +1007,46 @@ and boxes made to fit them.
780
1007
  `"B4"` to `"B6"`, `"C4"` to `"C6"`, `"DL"`, `"letter"`, `"legal"`,
781
1008
  `"tabloid"`, `"half letter"`, `"executive"`, `"pocket"` and `"traveler"`,
782
1009
  standing; cards `"business"`, `"us business"`, `"credit"`, `"japan"`,
783
- `"playing"`, `"bridge"`, `"tarot"`, `"postcard"` and `"us postcard"`, and
1010
+ `"playing"`, `"bridge"`, `"tarot"`, `"postcard"`, `"us postcard"` and
1011
+ `"gift card"`, and
784
1012
  photos `"4x6"`, `"5x7"`, `"8x10"`, `"10x15"`, `"13x18"` and the instant
785
1013
  film sizes `"instant mini"`, `"instant square"`, `"instant wide"` and
786
1014
  `"instant classic"`, lying down. An unknown name stops with the list of
787
1015
  known ones.
788
1016
 
1017
+ ### `note_size(name)`
1018
+
1019
+ A banknote's `[width, height]`, lying down: `"usd"` (every US note is the
1020
+ same size), `"cad"` (every Canadian note), `"eur 5"` to `"eur 200"`,
1021
+ `"gbp 5"` to `"gbp 50"` and `"aud 5"` to `"aud 100"`. For a wallet or a
1022
+ money gift holder, fit the largest note it is for.
1023
+
789
1024
  ### `part_size(name)`
790
1025
 
791
- A bought part's sizes as a record: `body = [width, depth, height]`, and
792
- for a part with a shaft its diameter `shaft`, the `shaft_length` it stands
793
- out of the body and the `hole` to cut for it. `"music-18"` is an 18-note
794
- wind-up music box movement (its shaft is the winding key's), and
795
- `"quartz-clock"` a 56 mm quartz clock movement with the 16.5 mm shaft, for
796
- dials up to `dial = 8` mm thick. `"marble-16"` and `"marble-25"` are
797
- marbles. These are common retail sizes, which vary: measure yours.
1026
+ The sizes of a bought part or an everyday thing as a record: `body =
1027
+ [width, depth, height]`; for a round one its `diameter` and `height` (an
1028
+ egg's `length`); for one with a shaft its diameter `shaft`, the
1029
+ `shaft_length` it stands out of the body; and the `hole` to cut for it,
1030
+ where there is one.
1031
+
1032
+ | Name | What it is |
1033
+ | ------------------------------------------------ | -------------------------------------------------------------------------------- |
1034
+ | `"music-18"` | an 18-note wind-up music box movement; its shaft is the winding key's |
1035
+ | `"quartz-clock"` | a 56 mm quartz clock movement with the 16.5 mm shaft, for dials up to `dial = 8` |
1036
+ | `"tealight"`, `"maxi tealight"` | 39 × 16 and 59 × 24, with a `hole` to stand one in |
1037
+ | `"led tealight"`, `"led puck"` | battery lights, 38 × 36 with the flame and 70 × 25 |
1038
+ | `"fairy lights"` | the battery box of a string of them, and its `wire` |
1039
+ | `"hen egg"`, `"chocolate egg"` | 44 and 40 across, 57 and 60 long |
1040
+ | `"wine bottle"` | 76 across and 300 high, its `neck` 30 across |
1041
+ | `"magnet 6x2"`, `"magnet 10x3"`, `"magnet 12x3"` | disc magnets, with a `hole` to press one into |
1042
+ | `"key ring 25"` | a 25 mm split key ring |
1043
+ | `"battery box 2aa"`, `"battery box 3aa"` | closed battery boxes with a switch |
1044
+ | `"coin cell holder"` | a holder for a CR2032 cell |
1045
+ | `"key fob"` | a car key fob |
1046
+ | `"tissue box"`, `"tissue cube"` | tissue boxes, long and cube |
1047
+ | `"marble-16"`, `"marble-25"` | marbles |
1048
+
1049
+ These are common retail sizes, which vary: measure yours.
798
1050
 
799
1051
  ```kerf
800
1052
  use <kerf/sizes>
@@ -803,6 +1055,19 @@ m = part_size("quartz-clock");
803
1055
  part("dial") difference() { circle(d = 160); circle(d = m.hole); }
804
1056
  ```
805
1057
 
1058
+ ```kerf
1059
+ use <kerf/sizes>
1060
+
1061
+ egg = part_size("hen egg");
1062
+ // A ring an egg sits in, a little over half its width
1063
+ part("egg cup") difference() { circle(d = egg.diameter + 16); circle(d = egg.diameter * 0.75); }
1064
+ ```
1065
+
1066
+ ### `size_list(kind)`
1067
+
1068
+ The names in one table, as a list, for a customizer menu: `"paper"`,
1069
+ `"card"`, `"photo"`, `"note"` or `"part"`, as `// [size_list("note")]`.
1070
+
806
1071
  ### `landscape(size)`, `portrait(size)`
807
1072
 
808
1073
  A size turned to lie wider than tall, or to stand taller than wide.
@@ -812,6 +1077,294 @@ A size turned to lie wider than tall, or to stand taller than wide.
812
1077
  The size of a name in a table of `[name, size]`, the names in it, and the
813
1078
  name an older name stands for in a table of `[old, new]`.
814
1079
 
1080
+ ## Drawers
1081
+
1082
+ `use <kerf/drawers>`
1083
+
1084
+ A carcass of small numbered drawers in a grid, as for an advent calendar,
1085
+ behind a façade of any shape: a finger-jointed box open at the front,
1086
+ shelves and walls halved into each other inside it, and a drawer in each
1087
+ cell with its number engraved on the front.
1088
+
1089
+ ```kerf
1090
+ use <kerf/drawers>
1091
+
1092
+ $thickness = 3;
1093
+ // 24 drawers, numbered in a shuffled order, behind a house front
1094
+ drawers(4, 6, [40, 30], 60, shuffle = 7) {
1095
+ polygon([[-10, -5], [185, -5], [185, 200], [87.5, 260], [-10, 200]]);
1096
+ }
1097
+ ```
1098
+
1099
+ ### `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 = "")`
1100
+
1101
+ `cols` by `rows` drawers, each cell `[w, h]` inside and the carcass `depth`
1102
+ deep, its front left bottom corner at the origin and the drawers facing
1103
+ -y. Drawers run on the shelves `ease` mm clear all round, and pull out
1104
+ `open` of their depth in the assembled view. `pull` is `"notch"` (a dip in
1105
+ the front's top edge), `"hole"` (a finger hole) or `"none"`. The numbers
1106
+ go row by row from the top left: 1 up, a list of your own in `numbers`
1107
+ (text works too), shuffled by a seed in `shuffle`, or none with `numbers
1108
+ = false`. Children are a façade, drawn on the carcass's front from its
1109
+ bottom left corner: the drawers' openings are cut through it, and it goes
1110
+ on in a step of its own. The parts are named after `label`, and the
1111
+ assembly is in steps: the carcass, the shelves and walls, the façade, the
1112
+ drawers.
1113
+
1114
+ ### `drawers_size(cols, rows, cell, depth)`, `drawers_numbers(n, numbers, shuffle)`
1115
+
1116
+ The carcass's outer `[width, height, depth]`, for drawing a façade round
1117
+ it, and the numbers on the drawers.
1118
+
1119
+ ## Figures
1120
+
1121
+ `use <kerf/figures>`
1122
+
1123
+ Layered characters for ornaments, standees, scenes and cards, drawn for
1124
+ this library:
1125
+
1126
+ | Cast | Figures |
1127
+ | ------------- | ------------------------------------------------------------------------------------------------ |
1128
+ | `"christmas"` | `santa`, `elf`, `gnome`, `angel`, `reindeer`, `gingerbread`, `snowman` |
1129
+ | `"easter"` | `bunny`, `chick`, `lamb` |
1130
+ | `"halloween"` | `ghost`, `witch`, `pumpkin`, `bat`, `skeleton` |
1131
+ | `"nativity"` | `mary`, `joseph`, `baby`, `shepherd`, `caspar`, `melchior`, `balthasar`, `ox`, `donkey`, `sheep` |
1132
+ | `"animals"` | `bear`, `fox`, `cat`, `dog`, `owl`, `deer` |
1133
+
1134
+ A figure is built in layers, as layered wood art is. The **outline** is a
1135
+ backer of its whole silhouette, standing `border` mm proud of the rest.
1136
+ On it lie the coloured pieces of its **clothes** (an animal's coat) and its
1137
+ **face** (skin, bellies, beaks, ears) side by side, `gap` mm apart, so the
1138
+ backer shows between them as lines. On those lie the **details**: eyes,
1139
+ noses, buttons. Each layer comes in one or more colours.
1140
+
1141
+ ```kerf
1142
+ use <kerf/figures>
1143
+
1144
+ $thickness = 3;
1145
+ figure_parts("bunny", 80, at = [0, 0, 0], rotate = [90, 0, 0]);
1146
+ figure_parts("chick", 80, at = [70, 0, 0], rotate = [90, 0, 0]);
1147
+ ```
1148
+
1149
+ ### `figure_parts(name, height = 100, at = [0, 0, 0], rotate = [0, 0, 0], label, border = 2, gap = 0.6, qty = 1)`
1150
+
1151
+ The figure as layered parts, its outline `height` mm tall: the outline
1152
+ placed at `at` and turned by `rotate` (`[90, 0, 0]` stands it up), the
1153
+ clothes and face glued on it and the details on those. Each colour of each
1154
+ layer is a part of its own, painted that colour, so the 3D view and the
1155
+ print layout show the figure in colour and the sheets keep one wood. The
1156
+ parts are named after `label`, the figure's name unless given: `"bunny
1157
+ outline"`, `"bunny face pink"`, `"bunny details black"`. A detail too small to cut at that height, under `min_width` of
1158
+ `figure_layer()`, is left out.
1159
+
1160
+ ### `figure(name, height = 100, border = 2, gap = 0.6)`
1161
+
1162
+ The figure from one sheet: its outline cut, the lines between its coloured
1163
+ pieces scored, and its details engraved. Put it inside a `part()`.
1164
+
1165
+ ### `figure_layer(name, layer, height = 100, color, border = 2, gap = 0.6, min_width = 1.6)`
1166
+
1167
+ One layer of the figure as shapes: `"outline"`, `"clothes"`, `"face"` or
1168
+ `"details"`, every colour of it or only `color`. The outline is `height` mm
1169
+ tall, standing on y = 0 and centred on x = 0. Each piece loses what the
1170
+ pieces after it cover, `gap` wider, and any sliver narrower than
1171
+ `min_width`; details stay on the clothes and face.
1172
+
1173
+ ### `figure_names(cast)`, `figure_casts()`, `figure_layers(name)`
1174
+
1175
+ The names of the figures, all or those of one cast; the casts; and the
1176
+ parts a figure is built of, as `[layer, colour]` from the outline up, as
1177
+ `figure_parts()` makes them.
1178
+
1179
+ ### `figure_details(name, height, base, qty = 1, border = 2, gap = 0.6, k = 0)`
1180
+
1181
+ The figure's details as painted parts named after `base`, glued on the
1182
+ first of its clothes and face parts that is big enough to cut at that
1183
+ height, as `figure_parts()` and `scene_figure()` make them.
1184
+
1185
+ ### `figure_entry(name)`, `figure_shapes(shapes)`, `figure_unique(list)`
1186
+
1187
+ A figure's entry, `[name, cast, outline colour, pieces]`; the shapes of one
1188
+ of its pieces drawn, in the figure's own units; and a list without its
1189
+ repeats. Each figure is drawn 100 units tall as a list of pieces in
1190
+ painter's order, each `[layer, colour, shapes]`, the shapes circles,
1191
+ ellipses, round-ended strokes, rounded rectangles, polygons and smooth
1192
+ closed curves, as the library's comments describe.
1193
+
1194
+ ## Inlays
1195
+
1196
+ `use <kerf/inlay>`
1197
+
1198
+ Inlays of another wood, stock or colour: shapes cut out of one part, or
1199
+ engraved into it as pockets, and cut again as inserts that press into
1200
+ them. KerfScript takes the kerf off every cut, so a hole and an insert of
1201
+ one shape come out the same size; each insert is `press` mm bigger all
1202
+ round so it holds.
1203
+
1204
+ ```kerf
1205
+ use <kerf/inlay>
1206
+ use <kerf/shapes>
1207
+
1208
+ $thickness = 3;
1209
+ // A walnut heart in a plywood plaque
1210
+ inlaid("plaque", materials = ["walnut"]) {
1211
+ rect([80, 60], r = 5);
1212
+ translate([40, 30]) heart(30);
1213
+ }
1214
+ ```
1215
+
1216
+ ### `inlaid(name, depth, press = 0.05, materials, paints, at = [0, 0, 0], rotate = [0, 0, 0])`
1217
+
1218
+ A part with inlays: its first child is the part's shape, and each child
1219
+ after it an inlay's shape. The inlays are cut through the part, or with
1220
+ `depth` engraved that deep on the layer `"pocket"` (set its power for the
1221
+ depth). Each inlay is an insert of its own, `"name inlay 1"` up, `press`
1222
+ mm bigger all round, of `materials[i]` (on a sheet of its own) or painted
1223
+ `paints[i]`; a pocket's insert is `depth` thick. In the assembled view a
1224
+ through insert sits in its hole and a pocket's on the surface over it.
1225
+
1226
+ ## Layered art
1227
+
1228
+ `use <kerf/layered>`
1229
+
1230
+ Multilayer pieces from one drawing, as layered ornaments, mandalas, wreaths
1231
+ and signs are made. The children are the art's layers, back to front; each
1232
+ becomes a part of its own, glued on the one behind it and painted its
1233
+ colour, so the 3D view and the print layout show it built up.
1234
+
1235
+ ```kerf
1236
+ use <kerf/layered>
1237
+
1238
+ $thickness = 3;
1239
+ layered("tree", colors = ["dark green", "green", "light green", "gold"], shadow = 2, hole = [0, 52, 4]) {
1240
+ regular_polygon(3, 40);
1241
+ translate([0, 8]) regular_polygon(3, 28);
1242
+ translate([0, 16]) regular_polygon(3, 16);
1243
+ translate([0, 40]) star(5, 7, 3);
1244
+ }
1245
+ ```
1246
+
1247
+ ### `layered(name = "layered", colors, border = 2, shadow = 0, shadow_color = "dark grey", hole, at = [0, 0, 0], rotate = [0, 0, 0])`
1248
+
1249
+ One part a layer, named `"name layer 1"` up from the back. Each layer is
1250
+ its own drawing joined with everything in front of it grown by `border`
1251
+ mm, so every layer is held up by the one behind and shows as a rim round
1252
+ it. `colors` gives each layer's paint, back to front; without it they go
1253
+ from dark brown at the back to white at the front. `shadow` adds a layer
1254
+ at the back that much wider again, in `shadow_color`. `hole = [x, y, d]`
1255
+ cuts a hole `d` across through every layer, to hang it by. The back layer
1256
+ goes at `at`, turned by `rotate`; a layer may be several pieces.
1257
+
1258
+ ### `layered_color(colors, k, n)`
1259
+
1260
+ The colour of layer `k` of `n`: `colors[k]`, else the palette from dark at
1261
+ the back to light at the front.
1262
+
1263
+ ## Balls and domes
1264
+
1265
+ `use <kerf/sphere>`
1266
+
1267
+ Slot-together balls and domes, as 3D baubles, globes and lantern domes:
1268
+ half-disc fins standing round an upright axis, like the segments of an
1269
+ orange, held by flat rings slotted onto them with halving joints. The fins
1270
+ stop short of the axis, so they never meet.
1271
+
1272
+ ```kerf
1273
+ use <kerf/sphere>
1274
+ use <kerf/scene>
1275
+
1276
+ $thickness = 3;
1277
+ // A bauble with a snowman standing inside it
1278
+ ball(140, fins = 6, hollow = 50, floor = true, at = [0, 0, 70]);
1279
+ scene_figure("snowman", 34, at = [0, 0, 71.5]);
1280
+ ```
1281
+
1282
+ ### `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)`
1283
+
1284
+ A ball `d` across, its centre at `at`: `fins` fins and `rings` rings
1285
+ `width` wide, the equator alone or spread from 60 degrees south to north.
1286
+ `dome = true` makes the top half, standing on its lowest ring. `hollow`
1287
+ cuts the fins away within that radius, to make room for a scene inside,
1288
+ and `floor = true` makes the lowest ring a whole disc for it to stand on,
1289
+ with a rail across the hollow for a standee's feet. `loop` puts a hole of
1290
+ that diameter near the top of each fin for a ribbon to hang it by. The
1291
+ parts are `"ball fin"` and `"ball ring 1"` up, named after `label`.
1292
+
1293
+ ### `ball_rings(d, rings = 1, dome = false)`
1294
+
1295
+ The heights of a ball's rings above its centre.
1296
+
1297
+ ## Scenes
1298
+
1299
+ `use <kerf/scene>`
1300
+
1301
+ Scene boxes and dioramas. A floor (or a shelf) has **rails**: slots running
1302
+ across it, in rows from front to back. Every **standee** has 8 mm feet that
1303
+ go into any rail, so a scene changes by taking standees out and putting
1304
+ others in. A standee is drawn standing on y = 0, centred on x = 0.
1305
+
1306
+ ```kerf
1307
+ use <kerf/scene>
1308
+
1309
+ $thickness = 3;
1310
+ rows = scene_rows(90);
1311
+ part("floor", at = [-100, 0, 0]) scene_floor(200, 90);
1312
+ scene_figure("snowman", 70, at = [-50, rows[1], 3]);
1313
+ scene_figure("gnome", 26, at = [40, rows[0], 3]);
1314
+ part("trees", at = [0, rows[5] + 1.5, 3], rotate = [90, 0, 0]) standee(full = true) {
1315
+ translate([-90, 0]) rect([180, 14]);
1316
+ for (x = [-80:20:80]) translate([x, 14]) regular_polygon(3, 22);
1317
+ }
1318
+ ```
1319
+
1320
+ ### `scene_rows(depth, rows = 6)`
1321
+
1322
+ Where the rails of a floor `depth` mm deep run, as y from its front edge:
1323
+ `rows` of them, the first 8 mm from the front and the last 7 mm from the
1324
+ back. Six rails on a 90 mm floor are at 8, 23, 38, 53, 68 and 83.
1325
+
1326
+ ### `scene_floor(width, depth, rows = 6, clearance = 0.1, margin = 6, r = 0)`, `scene_rails(width, depth, rows = 6, clearance = 0.1, margin = 6)`
1327
+
1328
+ A floor `width` by `depth` with its rails cut, its front edge on y = 0; or
1329
+ only the rails, as slots to cut from a floor or shelf of your own. Each
1330
+ rail is `$thickness + clearance` wide and stops `margin` short of each
1331
+ side.
1332
+
1333
+ ### `standee(mound, full = false, tab = 8, floor, clip)`
1334
+
1335
+ Its children, a drawing, as a standee: `tab` mm feet below y = 0 that go
1336
+ `floor` mm (`$thickness` unless given) into a rail. The feet spread over
1337
+ the width the drawing stands on: one under 28 mm, two a quarter of the
1338
+ width either side of the middle otherwise, three across a `full` width
1339
+ backdrop. A narrow standee stands on a mound 4.5 mm high, which `mound`
1340
+ sets; without one, a ground line 2 mm high joins legs that meet the floor
1341
+ apart. With `clip`, a polygon's points, the drawing is clipped to it and
1342
+ the feet left whole, as for a standee inside a round case.
1343
+
1344
+ ### `standee_feet(width, full = false)`, `standee_mound(width)`
1345
+
1346
+ Where the feet go across a standee `width` wide, from its middle, and the
1347
+ mound under it.
1348
+
1349
+ ### `scene_figure(name, height = 60, at = [0, 0, 0], turn = 0, label, mound, floor, border = 2, gap = 0.6)`
1350
+
1351
+ A layered figure from [`kerf/figures`](#figures) standing in a rail: its
1352
+ backer a standee, the other layers glued on its front, each colour a
1353
+ painted part. `at` is where its feet go, `[x, the rail's y, the floor's
1354
+ top z]`, and `turn` turns it about them.
1355
+
1356
+ ### `figure_base(name, height = 80, base = [60, 20], at = [0, 0, 0], label, clearance = 0.1, r = 3)`
1357
+
1358
+ A layered figure on a base of its own, to stand on a shelf: a base plate
1359
+ with one rail, centred on `at`, the figure's feet in it.
1360
+
1361
+ ### `drip_edge(width, height = 6, depth = 8, n, seed = 1)`, `wave_edge(width, height = 6, depth = 4, n)`
1362
+
1363
+ Edges for snow, icing, water and frills: a strip `width` wide and `height`
1364
+ tall above y = 0, with `n` round drips hanging below it up to `depth` mm,
1365
+ their lengths varied by `seed`; or with `n` waves `depth` mm deep along
1366
+ its bottom.
1367
+
815
1368
  ## Symbols
816
1369
 
817
1370
  `use <kerf/symbols>`
@@ -830,7 +1383,7 @@ part("tag") {
830
1383
  }
831
1384
  ```
832
1385
 
833
- ### `symbol(name, size = 10, center = true, fill = "nonzero", box = "drawn", solid = false, close, bridge)`
1386
+ ### `symbol(name, size = 10, center = true, fill = "nonzero", box = "drawn", solid = false, close, bridge, min_width)`
834
1387
 
835
1388
  The symbol `size` mm across the longer side of what it draws, centred on
836
1389
  the origin, or with its bottom left corner there. With `box = "grid"`,
@@ -844,6 +1397,11 @@ closed and holes filled, and the drawing's own detail engraved on it.
844
1397
  `bridge = w` also joins pieces too far apart to close, such as a moon
845
1398
  beside a mountain, with strips `w` wide.
846
1399
 
1400
+ A symbol drawn small has lines too thin to cut: a bird's legs, a bee's
1401
+ feelers. `min_width = 1.6` grows every line narrower than 1.6 mm to that
1402
+ width, so it can be cut and holds together; gaps narrower than it close
1403
+ up as the lines either side grow.
1404
+
847
1405
  ### `symbol_names(category)`, `symbol_size(name, size = 10, box = "drawn")`, `symbol_source(name)`, `symbol_entry(name)`
848
1406
 
849
1407
  The names of every symbol, or of one category; the `[width, height]` a