@mylasertools/kerfscript 0.0.0-stage → 0.2.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 (56) hide show
  1. package/CHANGELOG.md +60 -0
  2. package/CLA.md +76 -0
  3. package/COMMERCIAL-LICENSE.md +63 -0
  4. package/LANGUAGE.md +398 -0
  5. package/LICENSE +661 -0
  6. package/README.md +187 -2
  7. package/THIRD-PARTY-NOTICES.md +124 -0
  8. package/TRADEMARKS.md +45 -0
  9. package/dist/ast.d.cts +160 -0
  10. package/dist/ast.d.ts +160 -0
  11. package/dist/cli.d.cts +1 -0
  12. package/dist/cli.d.ts +1 -0
  13. package/dist/cli.js +19416 -0
  14. package/dist/customizer.d.cts +19 -0
  15. package/dist/customizer.d.ts +19 -0
  16. package/dist/evaluator.d.cts +129 -0
  17. package/dist/evaluator.d.ts +129 -0
  18. package/dist/export/dxf.d.cts +3 -0
  19. package/dist/export/dxf.d.ts +3 -0
  20. package/dist/export/svg.d.cts +15 -0
  21. package/dist/export/svg.d.ts +15 -0
  22. package/dist/functions.d.cts +4 -0
  23. package/dist/functions.d.ts +4 -0
  24. package/dist/geometry.d.cts +44 -0
  25. package/dist/geometry.d.ts +44 -0
  26. package/dist/index.cjs +44 -0
  27. package/dist/index.d.cts +10 -0
  28. package/dist/index.d.ts +10 -0
  29. package/dist/index.js +44 -0
  30. package/dist/joinery.d.cts +7 -0
  31. package/dist/joinery.d.ts +7 -0
  32. package/dist/lexer.d.cts +28 -0
  33. package/dist/lexer.d.ts +28 -0
  34. package/dist/parser.d.cts +6 -0
  35. package/dist/parser.d.ts +6 -0
  36. package/dist/paths.d.cts +28 -0
  37. package/dist/paths.d.ts +28 -0
  38. package/dist/render.d.cts +58 -0
  39. package/dist/render.d.ts +58 -0
  40. package/dist/stdlib.d.cts +1 -0
  41. package/dist/stdlib.d.ts +1 -0
  42. package/dist/text.d.cts +36 -0
  43. package/dist/text.d.ts +36 -0
  44. package/dist/values.d.cts +25 -0
  45. package/dist/values.d.ts +25 -0
  46. package/docs/cli.md +76 -0
  47. package/docs/compatibility.md +64 -0
  48. package/docs/customizer.md +74 -0
  49. package/docs/getting-started.md +115 -0
  50. package/docs/javascript.md +153 -0
  51. package/docs/kerf.md +67 -0
  52. package/docs/layers.md +108 -0
  53. package/docs/openscad.md +71 -0
  54. package/docs/parts-and-sheets.md +82 -0
  55. package/docs/versions.md +33 -0
  56. package/package.json +86 -4
@@ -0,0 +1,7 @@
1
+ import { type Poly } from './geometry.cjs';
2
+ export type Edge = 'out' | 'in' | 'flat';
3
+ export declare function fingerCount(length: number, finger: number): number;
4
+ export declare function fingerRect(w: number, h: number, edges: Edge[], t: number, finger: number): Poly[];
5
+ export declare function fingerHoles(length: number, edge: Edge, t: number, finger: number): Poly[];
6
+ export declare function tslot(d: number, length: number, nutW: number, nutH: number, nutAt: number): Poly[];
7
+ export declare function livingHinge(w: number, h: number, spacing: number, bridge: number, cut: number): Poly[];
@@ -0,0 +1,7 @@
1
+ import { type Poly } from './geometry.js';
2
+ export type Edge = 'out' | 'in' | 'flat';
3
+ export declare function fingerCount(length: number, finger: number): number;
4
+ export declare function fingerRect(w: number, h: number, edges: Edge[], t: number, finger: number): Poly[];
5
+ export declare function fingerHoles(length: number, edge: Edge, t: number, finger: number): Poly[];
6
+ export declare function tslot(d: number, length: number, nutW: number, nutH: number, nutAt: number): Poly[];
7
+ export declare function livingHinge(w: number, h: number, spacing: number, bridge: number, cut: number): Poly[];
@@ -0,0 +1,28 @@
1
+ export type TokenType = 'num' | 'str' | 'id' | 'punct' | 'eof';
2
+ export interface Pos {
3
+ line: number;
4
+ col: number;
5
+ offset: number;
6
+ }
7
+ export interface Token {
8
+ type: TokenType;
9
+ value: string;
10
+ pos: Pos;
11
+ }
12
+ export interface Comment {
13
+ text: string;
14
+ line: number;
15
+ block: boolean;
16
+ own: boolean;
17
+ }
18
+ export declare class KerfError extends Error {
19
+ line?: number;
20
+ col?: number;
21
+ echoes: string[];
22
+ missingFonts?: string[];
23
+ constructor(message: string, pos?: Pos);
24
+ }
25
+ export declare function tokenize(src: string): {
26
+ tokens: Token[];
27
+ comments: Comment[];
28
+ };
@@ -0,0 +1,28 @@
1
+ export type TokenType = 'num' | 'str' | 'id' | 'punct' | 'eof';
2
+ export interface Pos {
3
+ line: number;
4
+ col: number;
5
+ offset: number;
6
+ }
7
+ export interface Token {
8
+ type: TokenType;
9
+ value: string;
10
+ pos: Pos;
11
+ }
12
+ export interface Comment {
13
+ text: string;
14
+ line: number;
15
+ block: boolean;
16
+ own: boolean;
17
+ }
18
+ export declare class KerfError extends Error {
19
+ line?: number;
20
+ col?: number;
21
+ echoes: string[];
22
+ missingFonts?: string[];
23
+ constructor(message: string, pos?: Pos);
24
+ }
25
+ export declare function tokenize(src: string): {
26
+ tokens: Token[];
27
+ comments: Comment[];
28
+ };
@@ -0,0 +1,6 @@
1
+ import type { Program } from './ast.cjs';
2
+ import { type Comment } from './lexer.cjs';
3
+ export declare function parse(src: string): {
4
+ program: Program;
5
+ comments: Comment[];
6
+ };
@@ -0,0 +1,6 @@
1
+ import type { Program } from './ast.js';
2
+ import { type Comment } from './lexer.js';
3
+ export declare function parse(src: string): {
4
+ program: Program;
5
+ comments: Comment[];
6
+ };
@@ -0,0 +1,28 @@
1
+ import type { Poly } from './geometry.cjs';
2
+ export type Cmd = {
3
+ type: 'M' | 'L';
4
+ x: number;
5
+ y: number;
6
+ } | {
7
+ type: 'Q';
8
+ x1: number;
9
+ y1: number;
10
+ x: number;
11
+ y: number;
12
+ } | {
13
+ type: 'C';
14
+ x1: number;
15
+ y1: number;
16
+ x2: number;
17
+ y2: number;
18
+ x: number;
19
+ y: number;
20
+ } | {
21
+ type: 'Z';
22
+ };
23
+ export interface Flattened {
24
+ closed: Poly[];
25
+ open: Poly[];
26
+ }
27
+ export declare function flatten(cmds: Cmd[], tolerance?: number): Flattened;
28
+ export declare function parseSvgPath(d: string): Cmd[];
@@ -0,0 +1,28 @@
1
+ import type { Poly } from './geometry.js';
2
+ export type Cmd = {
3
+ type: 'M' | 'L';
4
+ x: number;
5
+ y: number;
6
+ } | {
7
+ type: 'Q';
8
+ x1: number;
9
+ y1: number;
10
+ x: number;
11
+ y: number;
12
+ } | {
13
+ type: 'C';
14
+ x1: number;
15
+ y1: number;
16
+ x2: number;
17
+ y2: number;
18
+ x: number;
19
+ y: number;
20
+ } | {
21
+ type: 'Z';
22
+ };
23
+ export interface Flattened {
24
+ closed: Poly[];
25
+ open: Poly[];
26
+ }
27
+ export declare function flatten(cmds: Cmd[], tolerance?: number): Flattened;
28
+ export declare function parseSvgPath(d: string): Cmd[];
@@ -0,0 +1,58 @@
1
+ import { type LayerDef, type Limits } from './evaluator.cjs';
2
+ import { type LayerPath } from './export/svg.cjs';
3
+ import { type Layer } from './geometry.cjs';
4
+ import { type FontSource } from './text.cjs';
5
+ import type { Value } from './values.cjs';
6
+ export interface RenderOptions {
7
+ params?: Record<string, Value>;
8
+ fonts?: Record<string, FontSource>;
9
+ defaultFont?: string;
10
+ resolve?: (path: string) => string | undefined;
11
+ kerf?: number;
12
+ layout?: 'pack' | 'none';
13
+ sheet?: [number, number];
14
+ gap?: number;
15
+ margin?: number;
16
+ guides?: boolean;
17
+ maxSteps?: number;
18
+ limits?: Partial<Limits>;
19
+ }
20
+ export interface PartInfo {
21
+ name: string;
22
+ qty: number;
23
+ width: number;
24
+ height: number;
25
+ pieces: number;
26
+ cutLength: number;
27
+ thickness: number;
28
+ kerf: number;
29
+ material: string;
30
+ }
31
+ export interface Placed {
32
+ part: string;
33
+ copy: number;
34
+ layers: Map<string, Layer>;
35
+ rotated: boolean;
36
+ }
37
+ export interface Sheet {
38
+ width: number;
39
+ height: number;
40
+ material: string;
41
+ thickness: number;
42
+ items: Placed[];
43
+ paths: LayerPath[];
44
+ svg: string;
45
+ dxf: string;
46
+ }
47
+ export interface RenderResult {
48
+ sheets: Sheet[];
49
+ width: number;
50
+ height: number;
51
+ paths: LayerPath[];
52
+ svg: string;
53
+ parts: PartInfo[];
54
+ layers: LayerDef[];
55
+ warnings: string[];
56
+ echoes: string[];
57
+ }
58
+ export declare function render(source: string, options?: RenderOptions): RenderResult;
@@ -0,0 +1,58 @@
1
+ import { type LayerDef, type Limits } from './evaluator.js';
2
+ import { type LayerPath } from './export/svg.js';
3
+ import { type Layer } from './geometry.js';
4
+ import { type FontSource } from './text.js';
5
+ import type { Value } from './values.js';
6
+ export interface RenderOptions {
7
+ params?: Record<string, Value>;
8
+ fonts?: Record<string, FontSource>;
9
+ defaultFont?: string;
10
+ resolve?: (path: string) => string | undefined;
11
+ kerf?: number;
12
+ layout?: 'pack' | 'none';
13
+ sheet?: [number, number];
14
+ gap?: number;
15
+ margin?: number;
16
+ guides?: boolean;
17
+ maxSteps?: number;
18
+ limits?: Partial<Limits>;
19
+ }
20
+ export interface PartInfo {
21
+ name: string;
22
+ qty: number;
23
+ width: number;
24
+ height: number;
25
+ pieces: number;
26
+ cutLength: number;
27
+ thickness: number;
28
+ kerf: number;
29
+ material: string;
30
+ }
31
+ export interface Placed {
32
+ part: string;
33
+ copy: number;
34
+ layers: Map<string, Layer>;
35
+ rotated: boolean;
36
+ }
37
+ export interface Sheet {
38
+ width: number;
39
+ height: number;
40
+ material: string;
41
+ thickness: number;
42
+ items: Placed[];
43
+ paths: LayerPath[];
44
+ svg: string;
45
+ dxf: string;
46
+ }
47
+ export interface RenderResult {
48
+ sheets: Sheet[];
49
+ width: number;
50
+ height: number;
51
+ paths: LayerPath[];
52
+ svg: string;
53
+ parts: PartInfo[];
54
+ layers: LayerDef[];
55
+ warnings: string[];
56
+ echoes: string[];
57
+ }
58
+ export declare function render(source: string, options?: RenderOptions): RenderResult;
@@ -0,0 +1 @@
1
+ export declare const LIBRARIES: Record<string, string>;
@@ -0,0 +1 @@
1
+ export declare const LIBRARIES: Record<string, string>;
@@ -0,0 +1,36 @@
1
+ import { type Poly } from './geometry.cjs';
2
+ import { type Cmd } from './paths.cjs';
3
+ export type FontSource = ArrayBuffer | Uint8Array;
4
+ interface OtFont {
5
+ getPath(text: string, x: number, y: number, size: number, options?: object): {
6
+ commands: Cmd[];
7
+ };
8
+ getAdvanceWidth(text: string, size: number, options?: object): number;
9
+ ascender: number;
10
+ descender: number;
11
+ unitsPerEm: number;
12
+ }
13
+ export declare class FontBook {
14
+ private sources;
15
+ private fallback?;
16
+ private parsed;
17
+ readonly missing: Set<string>;
18
+ constructor(sources: Record<string, FontSource>, fallback?: string | undefined);
19
+ names(): string[];
20
+ get(name: string): OtFont;
21
+ }
22
+ export interface TextOptions {
23
+ size: number;
24
+ font: string;
25
+ halign: string;
26
+ valign: string;
27
+ spacing: number;
28
+ }
29
+ export declare function textRegions(book: FontBook, text: string, o: TextOptions): Poly[];
30
+ export declare function textMetrics(book: FontBook, text: string, o: TextOptions): {
31
+ advance: number;
32
+ bounds: number[][];
33
+ ascent: number;
34
+ descent: number;
35
+ };
36
+ export {};
package/dist/text.d.ts ADDED
@@ -0,0 +1,36 @@
1
+ import { type Poly } from './geometry.js';
2
+ import { type Cmd } from './paths.js';
3
+ export type FontSource = ArrayBuffer | Uint8Array;
4
+ interface OtFont {
5
+ getPath(text: string, x: number, y: number, size: number, options?: object): {
6
+ commands: Cmd[];
7
+ };
8
+ getAdvanceWidth(text: string, size: number, options?: object): number;
9
+ ascender: number;
10
+ descender: number;
11
+ unitsPerEm: number;
12
+ }
13
+ export declare class FontBook {
14
+ private sources;
15
+ private fallback?;
16
+ private parsed;
17
+ readonly missing: Set<string>;
18
+ constructor(sources: Record<string, FontSource>, fallback?: string | undefined);
19
+ names(): string[];
20
+ get(name: string): OtFont;
21
+ }
22
+ export interface TextOptions {
23
+ size: number;
24
+ font: string;
25
+ halign: string;
26
+ valign: string;
27
+ spacing: number;
28
+ }
29
+ export declare function textRegions(book: FontBook, text: string, o: TextOptions): Poly[];
30
+ export declare function textMetrics(book: FontBook, text: string, o: TextOptions): {
31
+ advance: number;
32
+ bounds: number[][];
33
+ ascent: number;
34
+ descent: number;
35
+ };
36
+ export {};
@@ -0,0 +1,25 @@
1
+ import type { Expr, Param } from './ast.cjs';
2
+ export interface Range {
3
+ type: 'range';
4
+ start: number;
5
+ step: number;
6
+ end: number;
7
+ }
8
+ export interface Closure {
9
+ type: 'function';
10
+ params: Param[];
11
+ body: Expr;
12
+ scope: unknown;
13
+ name?: string;
14
+ }
15
+ export type Value = number | string | boolean | undefined | Value[] | Range | Closure;
16
+ export declare const isRange: (v: Value) => v is Range;
17
+ export declare const isFn: (v: Value) => v is Closure;
18
+ export declare const isNum: (v: Value) => v is number;
19
+ export declare function rangeValues(r: Range, limit: number): number[];
20
+ export declare function truthy(v: Value): boolean;
21
+ export declare function equals(a: Value, b: Value): boolean;
22
+ export declare function typeName(v: Value): string;
23
+ export declare function show(v: Value): string;
24
+ export declare function str(v: Value): string;
25
+ export declare function fmt(n: number): string;
@@ -0,0 +1,25 @@
1
+ import type { Expr, Param } from './ast.js';
2
+ export interface Range {
3
+ type: 'range';
4
+ start: number;
5
+ step: number;
6
+ end: number;
7
+ }
8
+ export interface Closure {
9
+ type: 'function';
10
+ params: Param[];
11
+ body: Expr;
12
+ scope: unknown;
13
+ name?: string;
14
+ }
15
+ export type Value = number | string | boolean | undefined | Value[] | Range | Closure;
16
+ export declare const isRange: (v: Value) => v is Range;
17
+ export declare const isFn: (v: Value) => v is Closure;
18
+ export declare const isNum: (v: Value) => v is number;
19
+ export declare function rangeValues(r: Range, limit: number): number[];
20
+ export declare function truthy(v: Value): boolean;
21
+ export declare function equals(a: Value, b: Value): boolean;
22
+ export declare function typeName(v: Value): string;
23
+ export declare function show(v: Value): string;
24
+ export declare function str(v: Value): string;
25
+ export declare function fmt(n: number): string;
package/docs/cli.md ADDED
@@ -0,0 +1,76 @@
1
+ # Command line
2
+
3
+ Use the `kerf` command to export designs, change parameters and inspect
4
+ parts from your terminal. Install the package with Node.js 20 or newer:
5
+
6
+ ```sh
7
+ npm install --global @mylasertools/kerfscript
8
+ kerf render box.kerf -o box.svg
9
+ ```
10
+
11
+ You can also run it through `npx`:
12
+
13
+ ```sh
14
+ npx @mylasertools/kerfscript render box.kerf -o box.svg
15
+ ```
16
+
17
+ Save a `.kerf` file from the [models](https://kerfscript.mylasertools.com/models/)
18
+ to try these commands.
19
+
20
+ ## Commands
21
+
22
+ ```sh
23
+ kerf render <file.kerf> [-o out.svg] [options]
24
+ kerf params <file.kerf>
25
+ kerf check <file.kerf>
26
+ ```
27
+
28
+ `render` exports SVG, DXF or JSON, using the output file's extension to
29
+ choose the format. `params` lists the editable settings as JSON. `check`
30
+ reports parts, dimensions, cut lengths, sheets and warnings.
31
+
32
+ ## Options
33
+
34
+ | Option | Use |
35
+ | --- | --- |
36
+ | `-o, --out <file>` | Output path ending in `.svg`, `.dxf` or `.json`; defaults to `<file>.svg` |
37
+ | `-D name=value` | Override a parameter; repeat for multiple values |
38
+ | `-p, --params <file>` | Load parameter values from a JSON file |
39
+ | `--font <file.ttf>` | Supply a font file; repeat for multiple fonts |
40
+ | `--kerf <mm>` | Override kerf for every part |
41
+ | `--sheet <W>x<H>` | Set the sheet width and height in millimetres |
42
+ | `--gap <mm>` | Set spacing between parts |
43
+ | `--margin <mm>` | Set spacing at sheet edges; defaults to the gap |
44
+ | `--no-pack` | Keep the positions defined in the program |
45
+ | `--guides` | Include the guide layer |
46
+ | `--split` | Export one file per sheet |
47
+ | `-h, --help` | Show command help |
48
+ | `-v, --version` | Show version numbers |
49
+
50
+ `-D` accepts KerfScript values, including numbers, quoted strings, booleans
51
+ and lists. For example: `-D width=200` or `-D 'name="Ada"'`.
52
+
53
+ ## Examples
54
+
55
+ ```sh
56
+ kerf render name-sign.kerf -D 'name="Ada"' --font Inter-Bold.ttf -o ada.svg
57
+ kerf render box.kerf --sheet 400x300 --kerf 0.12 --split -o box.svg
58
+ kerf render box.kerf -o box.dxf
59
+ kerf check box.kerf
60
+ ```
61
+
62
+ For multiple sheets, `--split` creates numbered files such as `box-1.svg`
63
+ and `box-2.svg`. Use it for DXF exports of a design with several sheets.
64
+
65
+ Warnings are written to standard error and allow rendering to continue.
66
+ An error stops the command, reports its location when available and returns
67
+ a non-zero exit code.
68
+
69
+ ## Fonts
70
+
71
+ Supply font files with `--font` for designs that use text. The CLI does not
72
+ look up fonts installed on your system.
73
+
74
+ `--font Inter-Bold.ttf` makes the font available as `Inter-Bold`. A design
75
+ can request it with `font = "Inter-Bold"`. The first supplied font is the
76
+ default for text that does not name one.
@@ -0,0 +1,64 @@
1
+ # Laser software
2
+
3
+ Export SVG or DXF from KerfScript, then set up the cutting job in your laser
4
+ software. Check the imported size and layers before assigning power, speed
5
+ and operation order.
6
+
7
+ ## What is in the files
8
+
9
+ **SVG**
10
+
11
+ - Millimetre dimensions with a matching `viewBox`.
12
+ - Named layer groups for engraving, scoring, cutting and any custom layers.
13
+ - Red cut paths, blue score paths and black filled engraving.
14
+ - Inner cut paths before outer outlines in the file.
15
+
16
+ **DXF**
17
+
18
+ - R12 polylines with millimetre units.
19
+ - Named layers such as `CUT`, `SCORE` and `ENGRAVE`.
20
+ - Engraving as outlines. Set the engraving layer to fill in your laser software.
21
+ - One sheet per file. Use the CLI's `--split` option for several sheets.
22
+
23
+ ## Checked
24
+
25
+ | Program | Version | SVG | DXF | Checks |
26
+ | --- | --- | --- | --- | --- |
27
+ | Inkscape | 1.4.2 | Passed | Passed | Dimensions, layers and SVG fills |
28
+
29
+ Six reference models passed these import checks on 28 October 2026.
30
+ Drawing dimensions matched within 0.02 mm, including kerf compensation.
31
+ These results cover file imports; they do not establish a fit for a
32
+ particular machine or material.
33
+
34
+ ## Not checked yet
35
+
36
+ LightBurn, xTool Studio, xTool Creative Space, RDWorks and LaserGRBL have
37
+ not yet been verified with the reference models. Import handling can differ
38
+ between programs, especially for units, layer colours and fills.
39
+
40
+ ## Checklist for a new program
41
+
42
+ Download the calibration square and box from the
43
+ [models](https://kerfscript.mylasertools.com/models/) and check their imports:
44
+
45
+ 1. **Size:** the calibration square's cut path is 100.15 mm wide with
46
+ `$kerf = 0.15`, allowing for a finished 100 mm square. If the imported
47
+ size differs, check the unit and DPI settings.
48
+ 2. **Layers:** cutting, scoring and engraving can be assigned separate operations.
49
+ 3. **Fill:** engraved text has filled letters. For DXF, select fill in the
50
+ engraving layer's settings.
51
+ 4. **Holes:** cut holes remain open and contain no engraving.
52
+ 5. **Order:** the job preview cuts inner paths before outer outlines.
53
+ 6. **Parts:** the box contains all six panels without overlaps.
54
+
55
+ ## What the file does not decide
56
+
57
+ Set power, speed, passes and focus for your machine and material. Check the
58
+ job preview for engraving before cutting and holes before outer outlines;
59
+ laser software can reorder the paths in a file.
60
+
61
+ For multiple sheets, use a separate file and matching material settings for
62
+ each sheet. If KerfScript has already applied kerf compensation, leave the
63
+ laser software's kerf offset at zero. Test the job on scrap before cutting
64
+ the final material.
@@ -0,0 +1,74 @@
1
+ # Settings
2
+
3
+ Expose dimensions, text and other choices as controls beside your design.
4
+ Comments define sliders and menus, while the variable values provide their
5
+ defaults. KerfScript uses OpenSCAD's customizer comment format.
6
+
7
+ ```kerf
8
+ /* [Size] */
9
+ // Outer width
10
+ width = 120; // [40:5:400]
11
+ // Outer depth
12
+ depth = 80; // [200]
13
+
14
+ /* [Style] */
15
+ shape = "round"; // [round:Round, square:Square]
16
+ holes = 3; // [2, 3, 4]
17
+ lid = true;
18
+ label = "Tools";
19
+
20
+ /* [Hidden] */
21
+ wall = 3;
22
+
23
+ rect([width, depth]);
24
+ ```
25
+
26
+ This example defines several control types. The rectangle uses `width`
27
+ and `depth`; the other variables illustrate settings you can use elsewhere
28
+ in a design.
29
+
30
+ ## What becomes a setting
31
+
32
+ A variable declared at the top level becomes a setting when its value is a
33
+ number, string, boolean or list of numbers. Variables defined by expressions,
34
+ such as `half_width = width / 2`, are calculated from the other values and
35
+ do not get their own controls.
36
+
37
+ ## Comments
38
+
39
+ Put a range or choice list after the assignment:
40
+
41
+ | Comment after the value | Control |
42
+ | --- | --- |
43
+ | `// [40:5:400]` | Slider from 40 to 400, in steps of 5 |
44
+ | `// [40:400]` | Slider from 40 to 400 |
45
+ | `// [200]` | Number with an upper limit of 200 |
46
+ | `// [2, 3, 4]` | Choice of 2, 3 or 4 |
47
+ | `// [round:Round, square:Square]` | Menu with a label for each value |
48
+ | No comment on a boolean | Checkbox |
49
+ | No comment on a string | Text field |
50
+
51
+ `/* [Size] */` starts a group named Size. `/* [Hidden] */` hides the
52
+ settings that follow it, until another group begins.
53
+
54
+ A `//` comment immediately above a variable supplies its caption. Keep the
55
+ file's introductory comment separate with a blank line so it does not
56
+ become the first setting's caption.
57
+
58
+ ## Changing settings without editing the file
59
+
60
+ The CLI accepts values with `-D` or a JSON file with `--params`:
61
+
62
+ ```sh
63
+ kerf render box.kerf -D width=200
64
+ kerf render box.kerf --params box-settings.json
65
+ kerf params box.kerf
66
+ ```
67
+
68
+ `box-settings.json` can contain `{"width": 200, "lid": false}`.
69
+ Use `kerf params` to list a design's settings as JSON.
70
+
71
+ String values need quotes, for example `-D 'label="Oak"'` for a design
72
+ with a `label` setting. In JavaScript, pass values through `render()`'s
73
+ `params` option and read the settings with `parameters()`. See the
74
+ [JavaScript API](javascript.md).