@mylasertools/kerfscript 0.10.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 (55) hide show
  1. package/CHANGELOG.md +199 -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 +2236 -375
  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 +4 -2
  15. package/dist/export/model.d.ts +4 -2
  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 +1308 -77
  25. package/dist/index.d.cts +4 -2
  26. package/dist/index.d.ts +4 -2
  27. package/dist/index.js +1308 -77
  28. package/dist/instructions.d.cts +27 -0
  29. package/dist/instructions.d.ts +27 -0
  30. package/dist/language.cjs +1281 -50
  31. package/dist/language.js +1281 -50
  32. package/dist/libraries.cjs +1262 -36
  33. package/dist/libraries.js +1262 -36
  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 +29 -8
  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 +454 -16
  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
@@ -0,0 +1,38 @@
1
+ import type { HardwareItem } from './evaluator.cjs';
2
+ type Vec3 = [number, number, number];
3
+ export interface Light {
4
+ /** A point light at from, or light all along a strip from `from` to `to` */
5
+ from: Vec3;
6
+ to: Vec3;
7
+ /** #rrggbb */
8
+ color: string;
9
+ /** Light given off in all, in lumens (a tealight is about 12) */
10
+ lumens: number;
11
+ /** A flame: it flickers in the 3D view */
12
+ flicker: boolean;
13
+ /** What gives it off: "tealight", "led", "bulb", or "light" for light() */
14
+ source: string;
15
+ /** The assembly step that adds it, 0 for none */
16
+ step: number;
17
+ label?: string;
18
+ }
19
+ /** Colours a light may be named by, besides the paint colours */
20
+ export declare const LIGHT_COLORS: Record<string, string>;
21
+ /** A light's colour as #rrggbb, from a name or a hex colour */
22
+ export declare function lightColor(v: string): string | undefined;
23
+ /** A tealight: a cup 39 mm across and 16 mm high, its flame 10 mm above */
24
+ export declare const TEALIGHT: {
25
+ diameter: number;
26
+ height: number;
27
+ flame: number;
28
+ };
29
+ /** The light a piece of hardware gives off: a tealight's flame, an LED or
30
+ * a strip of them, a bulb */
31
+ export declare function hardwareLights(h: HardwareItem): Light[];
32
+ /** Points that stand for a light: the point itself, or up to `max` evenly
33
+ * along a strip, sharing its lumens */
34
+ export declare function lightPoints(light: Light, max?: number): {
35
+ at: Vec3;
36
+ lumens: number;
37
+ }[];
38
+ export {};
@@ -0,0 +1,38 @@
1
+ import type { HardwareItem } from './evaluator.js';
2
+ type Vec3 = [number, number, number];
3
+ export interface Light {
4
+ /** A point light at from, or light all along a strip from `from` to `to` */
5
+ from: Vec3;
6
+ to: Vec3;
7
+ /** #rrggbb */
8
+ color: string;
9
+ /** Light given off in all, in lumens (a tealight is about 12) */
10
+ lumens: number;
11
+ /** A flame: it flickers in the 3D view */
12
+ flicker: boolean;
13
+ /** What gives it off: "tealight", "led", "bulb", or "light" for light() */
14
+ source: string;
15
+ /** The assembly step that adds it, 0 for none */
16
+ step: number;
17
+ label?: string;
18
+ }
19
+ /** Colours a light may be named by, besides the paint colours */
20
+ export declare const LIGHT_COLORS: Record<string, string>;
21
+ /** A light's colour as #rrggbb, from a name or a hex colour */
22
+ export declare function lightColor(v: string): string | undefined;
23
+ /** A tealight: a cup 39 mm across and 16 mm high, its flame 10 mm above */
24
+ export declare const TEALIGHT: {
25
+ diameter: number;
26
+ height: number;
27
+ flame: number;
28
+ };
29
+ /** The light a piece of hardware gives off: a tealight's flame, an LED or
30
+ * a strip of them, a bulb */
31
+ export declare function hardwareLights(h: HardwareItem): Light[];
32
+ /** Points that stand for a light: the point itself, or up to `max` evenly
33
+ * along a strip, sharing its lumens */
34
+ export declare function lightPoints(light: Light, max?: number): {
35
+ at: Vec3;
36
+ lumens: number;
37
+ }[];
38
+ export {};
package/dist/png.d.cts CHANGED
@@ -1,5 +1,18 @@
1
1
  import type { LayerDef } from './evaluator.cjs';
2
2
  import type { Sheet } from './render.cjs';
3
+ type Poly = [number, number][];
4
+ type RGB = [number, number, number];
5
+ export declare class Canvas {
6
+ readonly w: number;
7
+ readonly h: number;
8
+ readonly data: Uint8ClampedArray;
9
+ constructor(w: number, h: number);
10
+ blend(i: number, c: RGB, a: number): void;
11
+ fill(polys: Poly[], c: RGB, alpha: number): void;
12
+ line(p: Poly, c: RGB, width: number): void;
13
+ }
14
+ /** A picture `w` by `h` pixels, white, drawn on by `draw`, as a PNG */
15
+ export declare function pngOf(w: number, h: number, draw: (cv: Canvas) => void): Uint8Array;
3
16
  /** The most pixels a picture of a sheet has, and on each side */
4
17
  export declare const MAX_PIXELS = 16000000;
5
18
  export declare const MAX_SIDE = 16384;
@@ -7,3 +20,4 @@ export declare const MAX_SIDE = 16384;
7
20
  * MAX_PIXELS or MAX_SIDE): fills in their layer colours,
8
21
  * then line and cut layers on top. `side` "back" draws the back job. */
9
22
  export declare function sheetPng(sheet: Sheet, layers: LayerDef[], width?: number): Uint8Array;
23
+ export {};
package/dist/png.d.ts CHANGED
@@ -1,5 +1,18 @@
1
1
  import type { LayerDef } from './evaluator.js';
2
2
  import type { Sheet } from './render.js';
3
+ type Poly = [number, number][];
4
+ type RGB = [number, number, number];
5
+ export declare class Canvas {
6
+ readonly w: number;
7
+ readonly h: number;
8
+ readonly data: Uint8ClampedArray;
9
+ constructor(w: number, h: number);
10
+ blend(i: number, c: RGB, a: number): void;
11
+ fill(polys: Poly[], c: RGB, alpha: number): void;
12
+ line(p: Poly, c: RGB, width: number): void;
13
+ }
14
+ /** A picture `w` by `h` pixels, white, drawn on by `draw`, as a PNG */
15
+ export declare function pngOf(w: number, h: number, draw: (cv: Canvas) => void): Uint8Array;
3
16
  /** The most pixels a picture of a sheet has, and on each side */
4
17
  export declare const MAX_PIXELS = 16000000;
5
18
  export declare const MAX_SIDE = 16384;
@@ -7,3 +20,4 @@ export declare const MAX_SIDE = 16384;
7
20
  * MAX_PIXELS or MAX_SIDE): fills in their layer colours,
8
21
  * then line and cut layers on top. `side` "back" draws the back job. */
9
22
  export declare function sheetPng(sheet: Sheet, layers: LayerDef[], width?: number): Uint8Array;
23
+ export {};
package/dist/render.d.cts CHANGED
@@ -1,5 +1,6 @@
1
1
  import { type AssemblyPart } from './assembly.cjs';
2
2
  import type { RenderAnalysis } from './analysis.cjs';
3
+ import type { Light } from './lights.cjs';
3
4
  import { type HardwareItem, type LayerDef, type Limits } from './evaluator.cjs';
4
5
  import { type LayerPath } from './export/svg.cjs';
5
6
  import { type Layer } from './geometry.cjs';
@@ -33,10 +34,13 @@ export interface PartInfo {
33
34
  thickness: number;
34
35
  kerf: number;
35
36
  material: string;
37
+ paint?: string;
36
38
  stack?: number;
37
39
  glued?: string;
38
40
  label?: number;
39
41
  mirrored?: boolean;
42
+ copies?: number[];
43
+ joins?: string[];
40
44
  }
41
45
  export interface Placed {
42
46
  part: string;
@@ -79,6 +83,7 @@ export interface RenderResult {
79
83
  warnings: string[];
80
84
  echoes: string[];
81
85
  hardware: HardwareItem[];
86
+ lights: Light[];
82
87
  steps: string[];
83
88
  }
84
89
  export declare function render(source: string, options?: RenderOptions): RenderResult;
package/dist/render.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import { type AssemblyPart } from './assembly.js';
2
2
  import type { RenderAnalysis } from './analysis.js';
3
+ import type { Light } from './lights.js';
3
4
  import { type HardwareItem, type LayerDef, type Limits } from './evaluator.js';
4
5
  import { type LayerPath } from './export/svg.js';
5
6
  import { type Layer } from './geometry.js';
@@ -33,10 +34,13 @@ export interface PartInfo {
33
34
  thickness: number;
34
35
  kerf: number;
35
36
  material: string;
37
+ paint?: string;
36
38
  stack?: number;
37
39
  glued?: string;
38
40
  label?: number;
39
41
  mirrored?: boolean;
42
+ copies?: number[];
43
+ joins?: string[];
40
44
  }
41
45
  export interface Placed {
42
46
  part: string;
@@ -79,6 +83,7 @@ export interface RenderResult {
79
83
  warnings: string[];
80
84
  echoes: string[];
81
85
  hardware: HardwareItem[];
86
+ lights: Light[];
82
87
  steps: string[];
83
88
  }
84
89
  export declare function render(source: string, options?: RenderOptions): RenderResult;
@@ -177,6 +177,26 @@ var SIGNATURES = [
177
177
  named(
178
178
  "bridge",
179
179
  "Join every island (an i's dot, an accent, a stencil's counter) to the rest with a strip this wide"
180
+ ),
181
+ named(
182
+ "weld",
183
+ "Slide each word's letters together into one piece, as a script name is cut; a number is how far each overlaps the one before, in mm",
184
+ "false"
185
+ ),
186
+ named("underline", "With weld: a bar this high under the baseline, joining the words"),
187
+ named(
188
+ "lines",
189
+ "Break the text at spaces into up to this many lines; with fit, as many as let it be biggest",
190
+ "1"
191
+ ),
192
+ named("line_spacing", "The distance between lines, as a share of the usual", "1"),
193
+ named(
194
+ "path",
195
+ "Lay the text along these [x, y] points, each letter turned to the path, centred on it"
196
+ ),
197
+ named(
198
+ "arc",
199
+ "Lay the text round a circle of this radius about the origin: over the top, or along the bottom when less than 0"
180
200
  )
181
201
  ],
182
202
  section: "Shapes",
@@ -514,8 +534,8 @@ var SIGNATURES = [
514
534
  kind: "module",
515
535
  params: [
516
536
  p("name", "Layer name"),
517
- p("mode", '"cut", "line", "fill" or "guide"'),
518
- p("color", 'Colour in the output, as "#00aa00"'),
537
+ p("mode", '"cut", "line", "fill", "guide" or "paint" (shown in 3D, not cut)'),
538
+ p("color", 'Colour in the output, as "#00aa00" or a name, as "red"'),
519
539
  named("order", "Where it goes among the custom layers in the files, lowest first", "0"),
520
540
  named("bleed", "How far past the part's edge it may print", "0"),
521
541
  named(
@@ -539,7 +559,30 @@ var SIGNATURES = [
539
559
  named("stack", "Layers glued in a stack at each placement, one thickness apart", "1"),
540
560
  named("mirror", "Cut the part mirrored left to right, its text still reading", "false"),
541
561
  named("material", "The material it is cut from, as material(name = ...) sets it"),
562
+ named(
563
+ "pieces",
564
+ 'How many separate pieces it cuts into, as a pair of eyes, or "any": no warning that it is in pieces',
565
+ "1"
566
+ ),
567
+ named(
568
+ "paint",
569
+ 'Its colour in the 3D view and the print layout, as "red" or "#c8372d"; the part stays on the sheet of its material'
570
+ ),
542
571
  named("bend", "Living hinge bends in the assembled view: [x0, x1, angle] or a list"),
572
+ named(
573
+ "fold",
574
+ "Folds along any line in the assembled view, as for card: [from, to, angle] or a list; more than 0 folds towards the top face"
575
+ ),
576
+ named("fold_open", "How far the folds are folded: 0 lies flat, 1 as their angles say", "1"),
577
+ named(
578
+ "hang",
579
+ "The point [x, y] on the part it hangs from, at `at`: it swings in its own plane until its weight is below"
580
+ ),
581
+ named("cord", "The cord it hangs on, in mm; 0 for a ring or pin", "0"),
582
+ named(
583
+ "split",
584
+ "Cut a part too big for the bed into pieces joined by jigsaw knobs: true for the sheet, or [width, height]"
585
+ ),
543
586
  named("on", "The name of a bent part this one is glued to, to move with it"),
544
587
  named("slots", "Names of parts whose tabs pass through this one: their slots are cut"),
545
588
  named("clearance", "Added to the slots, in total across each", "0.1"),
@@ -564,7 +607,12 @@ var SIGNATURES = [
564
607
  "glue",
565
608
  "The name of a part this one is glued flat onto; at and rotate are then on its face"
566
609
  ),
567
- named("face", 'The face of the glue part it goes on: "top" or "bottom"', '"top"')
610
+ named("face", 'The face of the glue part it goes on: "top" or "bottom"', '"top"'),
611
+ named(
612
+ "press_fit",
613
+ "Pressed into the glue part, as an inlay: they overlap on purpose, so they are not checked against each other",
614
+ "false"
615
+ )
568
616
  ],
569
617
  children: true,
570
618
  section: "Parts and sheets",
@@ -612,12 +660,35 @@ var SIGNATURES = [
612
660
  named("up", "The direction a [width, height] section's height points"),
613
661
  named("sides", "Sides of a round section in the 3D view; 0 makes a ball", "24"),
614
662
  named("shape", '"rod", or "ball" for a bulb, a marble or a bead', '"rod"'),
615
- named("label", "The name in the hardware list")
663
+ named("label", "The name in the hardware list"),
664
+ named(
665
+ "mass",
666
+ "Its weight in grams, for the check that the model stands, as an egg in a holder"
667
+ )
616
668
  ],
617
669
  children: true,
618
670
  section: "Parts and sheets",
619
671
  doc: "Hardware the assembly needs, in the parts list and the 3D view"
620
672
  },
673
+ {
674
+ name: "light",
675
+ kind: "module",
676
+ params: [
677
+ p("at", "Where the light is, [x, y, z]", "[0, 0, 0]"),
678
+ p(
679
+ "color",
680
+ `Its colour: "warm white", "white", "cool white", "warm", "flame", a colour's name or "#ffd9a0"`,
681
+ '"warm white"'
682
+ ),
683
+ p("lumens", "How much light it gives off: a tealight is about 12", "20"),
684
+ named("to", "The other end of a strip of light, [x, y, z]: it lights all along"),
685
+ named("flicker", "A flame: it flickers in the 3D view", "false"),
686
+ named("label", "Its name in 3D files")
687
+ ],
688
+ children: true,
689
+ section: "Parts and sheets",
690
+ doc: "A light source in the 3D view and GLB files, with nothing to show for it"
691
+ },
621
692
  {
622
693
  name: "material",
623
694
  kind: "module",
@@ -152,6 +152,26 @@ var SIGNATURES = [
152
152
  named(
153
153
  "bridge",
154
154
  "Join every island (an i's dot, an accent, a stencil's counter) to the rest with a strip this wide"
155
+ ),
156
+ named(
157
+ "weld",
158
+ "Slide each word's letters together into one piece, as a script name is cut; a number is how far each overlaps the one before, in mm",
159
+ "false"
160
+ ),
161
+ named("underline", "With weld: a bar this high under the baseline, joining the words"),
162
+ named(
163
+ "lines",
164
+ "Break the text at spaces into up to this many lines; with fit, as many as let it be biggest",
165
+ "1"
166
+ ),
167
+ named("line_spacing", "The distance between lines, as a share of the usual", "1"),
168
+ named(
169
+ "path",
170
+ "Lay the text along these [x, y] points, each letter turned to the path, centred on it"
171
+ ),
172
+ named(
173
+ "arc",
174
+ "Lay the text round a circle of this radius about the origin: over the top, or along the bottom when less than 0"
155
175
  )
156
176
  ],
157
177
  section: "Shapes",
@@ -489,8 +509,8 @@ var SIGNATURES = [
489
509
  kind: "module",
490
510
  params: [
491
511
  p("name", "Layer name"),
492
- p("mode", '"cut", "line", "fill" or "guide"'),
493
- p("color", 'Colour in the output, as "#00aa00"'),
512
+ p("mode", '"cut", "line", "fill", "guide" or "paint" (shown in 3D, not cut)'),
513
+ p("color", 'Colour in the output, as "#00aa00" or a name, as "red"'),
494
514
  named("order", "Where it goes among the custom layers in the files, lowest first", "0"),
495
515
  named("bleed", "How far past the part's edge it may print", "0"),
496
516
  named(
@@ -514,7 +534,30 @@ var SIGNATURES = [
514
534
  named("stack", "Layers glued in a stack at each placement, one thickness apart", "1"),
515
535
  named("mirror", "Cut the part mirrored left to right, its text still reading", "false"),
516
536
  named("material", "The material it is cut from, as material(name = ...) sets it"),
537
+ named(
538
+ "pieces",
539
+ 'How many separate pieces it cuts into, as a pair of eyes, or "any": no warning that it is in pieces',
540
+ "1"
541
+ ),
542
+ named(
543
+ "paint",
544
+ 'Its colour in the 3D view and the print layout, as "red" or "#c8372d"; the part stays on the sheet of its material'
545
+ ),
517
546
  named("bend", "Living hinge bends in the assembled view: [x0, x1, angle] or a list"),
547
+ named(
548
+ "fold",
549
+ "Folds along any line in the assembled view, as for card: [from, to, angle] or a list; more than 0 folds towards the top face"
550
+ ),
551
+ named("fold_open", "How far the folds are folded: 0 lies flat, 1 as their angles say", "1"),
552
+ named(
553
+ "hang",
554
+ "The point [x, y] on the part it hangs from, at `at`: it swings in its own plane until its weight is below"
555
+ ),
556
+ named("cord", "The cord it hangs on, in mm; 0 for a ring or pin", "0"),
557
+ named(
558
+ "split",
559
+ "Cut a part too big for the bed into pieces joined by jigsaw knobs: true for the sheet, or [width, height]"
560
+ ),
518
561
  named("on", "The name of a bent part this one is glued to, to move with it"),
519
562
  named("slots", "Names of parts whose tabs pass through this one: their slots are cut"),
520
563
  named("clearance", "Added to the slots, in total across each", "0.1"),
@@ -539,7 +582,12 @@ var SIGNATURES = [
539
582
  "glue",
540
583
  "The name of a part this one is glued flat onto; at and rotate are then on its face"
541
584
  ),
542
- named("face", 'The face of the glue part it goes on: "top" or "bottom"', '"top"')
585
+ named("face", 'The face of the glue part it goes on: "top" or "bottom"', '"top"'),
586
+ named(
587
+ "press_fit",
588
+ "Pressed into the glue part, as an inlay: they overlap on purpose, so they are not checked against each other",
589
+ "false"
590
+ )
543
591
  ],
544
592
  children: true,
545
593
  section: "Parts and sheets",
@@ -587,12 +635,35 @@ var SIGNATURES = [
587
635
  named("up", "The direction a [width, height] section's height points"),
588
636
  named("sides", "Sides of a round section in the 3D view; 0 makes a ball", "24"),
589
637
  named("shape", '"rod", or "ball" for a bulb, a marble or a bead', '"rod"'),
590
- named("label", "The name in the hardware list")
638
+ named("label", "The name in the hardware list"),
639
+ named(
640
+ "mass",
641
+ "Its weight in grams, for the check that the model stands, as an egg in a holder"
642
+ )
591
643
  ],
592
644
  children: true,
593
645
  section: "Parts and sheets",
594
646
  doc: "Hardware the assembly needs, in the parts list and the 3D view"
595
647
  },
648
+ {
649
+ name: "light",
650
+ kind: "module",
651
+ params: [
652
+ p("at", "Where the light is, [x, y, z]", "[0, 0, 0]"),
653
+ p(
654
+ "color",
655
+ `Its colour: "warm white", "white", "cool white", "warm", "flame", a colour's name or "#ffd9a0"`,
656
+ '"warm white"'
657
+ ),
658
+ p("lumens", "How much light it gives off: a tealight is about 12", "20"),
659
+ named("to", "The other end of a strip of light, [x, y, z]: it lights all along"),
660
+ named("flicker", "A flame: it flickers in the 3D view", "false"),
661
+ named("label", "Its name in 3D files")
662
+ ],
663
+ children: true,
664
+ section: "Parts and sheets",
665
+ doc: "A light source in the 3D view and GLB files, with nothing to show for it"
666
+ },
596
667
  {
597
668
  name: "material",
598
669
  kind: "module",
package/dist/text.d.cts CHANGED
@@ -39,4 +39,27 @@ export declare function textMetrics(book: FontBook, text: string, o: TextOptions
39
39
  descent: number;
40
40
  cap: number;
41
41
  };
42
+ /** The text laid along a path: each letter where its middle falls along
43
+ * the path, turned to the path's direction there, its baseline on the
44
+ * path. halign puts the text's start, middle or end at the path's.
45
+ * `over` is how far the text runs past the path's ends, 0 when it fits. */
46
+ export declare function textAlong(book: FontBook, text: string, o: TextOptions, points: [number, number][]): {
47
+ polys: Poly[];
48
+ over: number;
49
+ };
50
+ /** A circle of radius |r| round the origin as a path for text: r > 0
51
+ * goes clockwise, its middle at the top, for text on the outside reading
52
+ * round; r < 0 goes anticlockwise, its middle at the bottom, for text
53
+ * along the bottom reading left to right */
54
+ export declare function arcPath(r: number): [number, number][];
55
+ /** Text with its letters welded into one piece, as script names are cut:
56
+ * within each word a letter that does not touch the one before slides
57
+ * back until it overlaps it by `overlap` mm (a tenth of the size, and
58
+ * at least 1.5, by default); `underline` (a height) adds a bar
59
+ * under the baseline joining the words. `loose` lists the letters left
60
+ * as pieces of their own, as an i's dot. */
61
+ export declare function textWeld(book: FontBook, text: string, o: TextOptions, underline?: number, overlap?: number): {
62
+ polys: Poly[];
63
+ loose: string[];
64
+ };
42
65
  export {};
package/dist/text.d.ts CHANGED
@@ -39,4 +39,27 @@ export declare function textMetrics(book: FontBook, text: string, o: TextOptions
39
39
  descent: number;
40
40
  cap: number;
41
41
  };
42
+ /** The text laid along a path: each letter where its middle falls along
43
+ * the path, turned to the path's direction there, its baseline on the
44
+ * path. halign puts the text's start, middle or end at the path's.
45
+ * `over` is how far the text runs past the path's ends, 0 when it fits. */
46
+ export declare function textAlong(book: FontBook, text: string, o: TextOptions, points: [number, number][]): {
47
+ polys: Poly[];
48
+ over: number;
49
+ };
50
+ /** A circle of radius |r| round the origin as a path for text: r > 0
51
+ * goes clockwise, its middle at the top, for text on the outside reading
52
+ * round; r < 0 goes anticlockwise, its middle at the bottom, for text
53
+ * along the bottom reading left to right */
54
+ export declare function arcPath(r: number): [number, number][];
55
+ /** Text with its letters welded into one piece, as script names are cut:
56
+ * within each word a letter that does not touch the one before slides
57
+ * back until it overlaps it by `overlap` mm (a tenth of the size, and
58
+ * at least 1.5, by default); `underline` (a height) adds a bar
59
+ * under the baseline joining the words. `loose` lists the letters left
60
+ * as pieces of their own, as an i's dot. */
61
+ export declare function textWeld(book: FontBook, text: string, o: TextOptions, underline?: number, overlap?: number): {
62
+ polys: Poly[];
63
+ loose: string[];
64
+ };
42
65
  export {};
@@ -36,6 +36,12 @@ export interface SnapshotPart {
36
36
  /** null means unavailable; [] means known to have no open cutting lines. */
37
37
  cutLines: Poly[] | null;
38
38
  bends: Bend[];
39
+ /** Fold lines of card or paper; a folded part is not rigid */
40
+ folds?: {
41
+ from: [number, number];
42
+ to: [number, number];
43
+ angle: number;
44
+ }[];
39
45
  stack?: number;
40
46
  glue?: PartRef;
41
47
  glueFace?: 'top' | 'bottom';
@@ -36,6 +36,12 @@ export interface SnapshotPart {
36
36
  /** null means unavailable; [] means known to have no open cutting lines. */
37
37
  cutLines: Poly[] | null;
38
38
  bends: Bend[];
39
+ /** Fold lines of card or paper; a folded part is not rigid */
40
+ folds?: {
41
+ from: [number, number];
42
+ to: [number, number];
43
+ angle: number;
44
+ }[];
39
45
  stack?: number;
40
46
  glue?: PartRef;
41
47
  glueFace?: 'top' | 'bottom';
package/docs/3d-files.md CHANGED
@@ -7,7 +7,7 @@ thin coloured layer on its face.
7
7
 
8
8
  ```sh
9
9
  kerf render box.kerf -o box.glb # the assembled model, to view or render
10
- kerf render sign.kerf -o sign.3mf --flat # the parts flat, to print in colour
10
+ kerf render sign.kerf -o sign.3mf --print # laid out to print in colour
11
11
  kerf render coaster.kerf -o coaster.stl # one mesh
12
12
  ```
13
13
 
@@ -35,14 +35,24 @@ prints: a coaster, a sign, an ornament, a bookmark. Laid flat, marks for
35
35
  the back face and hardware are left out, since nothing can stand under a
36
36
  part on the bed.
37
37
 
38
- For printing, set the marks to a few layers' height. `--print` does both:
39
- the parts flat and the marks 0.6 mm high, so the engraving prints as a
40
- raised second colour.
38
+ ## Laid out to print
39
+
40
+ `--print` lays the model out to 3D print in colour. Each part is one
41
+ object with everything glued on it (`glue =` and the layers of a
42
+ `stack`), each layer where the assembly puts it and in its own colour, so
43
+ a standee of three glued layers prints as one piece, not three to glue.
44
+ An upright part lies down on its back face, or on the lowest layer glued
45
+ under it. Marks stand 0.6 mm high, a raised colour of their own, and only
46
+ where they show: not under a layer glued over them or on the bed.
41
47
 
42
48
  ```sh
43
- kerf render coaster.kerf -o coaster.3mf --print
49
+ kerf render snow-scene.kerf -o snow-scene.3mf --print
44
50
  ```
45
51
 
52
+ Each layer takes its colour from its material: a colour in the name
53
+ (`material = "green"`, `"#cc3333 card"`) or a wood or sheet it names. A
54
+ stack with a part bent on a living hinge is laid out part by part, flat.
55
+
46
56
  ## Formats
47
57
 
48
58
  | File | Units | Holds |
@@ -51,6 +61,16 @@ kerf render coaster.kerf -o coaster.3mf --print
51
61
  | `.3mf` | millimetres, z up | each part one object, with its engraving and scoring as coloured parts of it, so a slicer prints each in its own colour |
52
62
  | `.stl` | millimetres, z up | every body in one mesh, without colours |
53
63
 
64
+ A GLB of the assembled model carries its lights (tealights, LEDs, bulbs
65
+ and `light()`) as point lights (`KHR_lights_punctual`), each with its
66
+ colour and its intensity in candela; a strip of LEDs is several along it.
67
+ Translucent materials (vellum, paper, frosted acrylic) are partly
68
+ transparent and carry `KHR_materials_transmission`. Each light's node has
69
+ `extras` with `kind: "light"`, its `source`,
70
+ `lumens` and `flicker`, which is true for a flame. Glowing bodies, an LED
71
+ or a flame, are emissive. Blender and most glTF viewers light the scene
72
+ with them.
73
+
54
74
  Every part and mark is a closed solid: each edge is shared by exactly two
55
75
  triangles, facing out. A bent part is the exception: it is built from bands
56
76
  across its hinge, which meet inside it.
@@ -62,11 +82,12 @@ import { render, toModel } from '@mylasertools/kerfscript';
62
82
 
63
83
  const result = render(source);
64
84
  const glb = toModel(result, 'glb'); // a Uint8Array
65
- const print = toModel(result, '3mf', { layout: 'flat', markHeight: 0.6 });
85
+ const print = toModel(result, '3mf', { layout: 'print', markHeight: 0.6 });
66
86
  ```
67
87
 
68
88
  `meshBodies(result, options)` gives the bodies themselves (positions and
69
89
  triangles in millimetres) for a viewer of your own, and `toGlb()`, `to3mf()`
70
- and `toStl()` write them. The options are `layout` (`"assembled"` or
71
- `"flat"`), `markHeight`, `lineWidth`, `slitWidth`, `hardware` and `gap`.
90
+ and `toStl()` write them. The options are `layout` (`"assembled"`,
91
+ `"flat"` or `"print"`), `markHeight`, `lineWidth`, `slitWidth`, `hardware`
92
+ and `gap`.
72
93
  See the [JavaScript API](javascript.md).
package/docs/cli.md CHANGED
@@ -125,7 +125,7 @@ installed libraries by themselves.
125
125
  | `-o out.png`, `--px n` | A picture of each sheet, `n` pixels wide (1200), to look at rather than cut |
126
126
  | `-o out.glb` | The model in 3D: `.glb` to view, `.3mf` to print in colour, `.stl`; see [3D files](3d-files.md) |
127
127
  | `--flat` | With a 3D file: the parts side by side, front face up |
128
- | `--print` | With a 3D file: `--flat` with the marks 0.6 mm high, to print as a second colour |
128
+ | `--print` | With a 3D file: to print, each part and what is glued on it one object; marks 0.6 mm high |
129
129
  | `--mark-height <mm>` | With a 3D file: how far engraving and scoring stand off the face (0.1) |
130
130
  | `--call 'm(1, 2)'` | Run one call of the file's modules instead of its program; `-D` sets variables first |
131
131
  | `--params-list file` | With `check`: try each set of settings in a JSON list of objects |
@@ -179,6 +179,17 @@ step's parts in orange, and the parts and hardware it adds. With
179
179
  kerf instructions lock-box.kerf -o lock-box-instructions.html
180
180
  ```
181
181
 
182
+ With `-o` ending in `.pdf` it writes the same instructions as a PDF, an A4
183
+ page for the parts and one for each step; ending in `.png`, a picture of
184
+ each page, `lock-box-1.png` up, `--px` wide (1200 by default), to share or
185
+ show in a listing. The text is drawn as the font's outlines, so neither
186
+ needs a browser or a font installed.
187
+
188
+ ```sh
189
+ kerf instructions lock-box.kerf -o lock-box.pdf
190
+ kerf instructions lock-box.kerf -o lock-box.png --px 1600
191
+ ```
192
+
182
193
  `kerf diff` renders two designs (or one design before and after a change)
183
194
  with the same settings and lists, part by part and layer by layer, what
184
195
  differs: the area of shapes that changed, open lines added or removed, and
@@ -48,6 +48,19 @@ Put a range or choice list after the assignment:
48
48
  | No comment on a boolean | Checkbox |
49
49
  | No comment on a string | Text field |
50
50
 
51
+ A menu can come from a library: a function call in the brackets, as
52
+ `// [figure_names("easter")]`, `// [symbol_names("animals")]` or
53
+ `// [size_list("note")]`, is run with the program's `use <kerf/...>`
54
+ libraries, and each item of the list it gives is a choice (or each
55
+ `[value, label]` pair a choice with a label):
56
+
57
+ ```kerf
58
+ use <kerf/figures>
59
+
60
+ figure = "bunny"; // [figure_names("easter")]
61
+ part("figure") figure(figure, 80);
62
+ ```
63
+
51
64
  `/* [Size] */` starts a group named Size. `/* [Hidden] */` hides the
52
65
  settings that follow it, until another group begins.
53
66
 
@@ -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