@mylasertools/kerfscript 0.2.0 → 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.
@@ -1,7 +1,8 @@
1
1
  # Parts and sheets
2
2
 
3
- A design often has more than one piece. KerfScript lets you name each piece,
4
- say how many you need and what it is cut from, and lays them out on sheets.
3
+ Use parts to name the pieces in a design, set quantities and assign
4
+ materials. KerfScript lays them out on sheets, grouping parts that use the
5
+ same material and thickness.
5
6
 
6
7
  ## Parts
7
8
 
@@ -10,16 +11,27 @@ part("side", qty = 2) rect([100, 60]);
10
11
  part("base") rect([100, 100]);
11
12
  ```
12
13
 
13
- `part(name, qty = 1)` makes a named part. Everything inside it is one piece
14
- with its own layers. Shapes outside any part form one part called `part`.
14
+ This creates two side panels and one base. Each `part()` has its own layers
15
+ and appears in the parts list with dimensions and cut length. The default
16
+ quantity is one.
15
17
 
16
- Parts show up in the part list with their size and cut length, which the
17
- playground and `kerf check` print.
18
+ Shapes outside a `part()` are collected into a part named `part`.
19
+
20
+ Transforms and operations such as `translate()`, `difference()` and
21
+ `offset()` can wrap a part and change all of it. Layer wrappers such as
22
+ `score()` and `engrave()` go inside the part instead, since a whole part on
23
+ the score layer would have nothing to cut:
24
+
25
+ ```kerf
26
+ part("tag") {
27
+ rect([60, 30], r = 3);
28
+ score() translate([5, 5]) rect([50, 20]);
29
+ }
30
+ ```
18
31
 
19
32
  ## Materials
20
33
 
21
- Each part records `$thickness`, `$kerf` and `$material` where it is made.
22
- `material()` sets all three for the parts inside it:
34
+ `material()` sets the thickness, kerf and material name for its parts:
23
35
 
24
36
  ```kerf
25
37
  material(thickness = 3, kerf = 0.15, name = "plywood") {
@@ -31,38 +43,40 @@ material(thickness = 2, kerf = 0.1, name = "acrylic") {
31
43
  }
32
44
  ```
33
45
 
34
- ## Sheets
35
-
36
- With the default `$layout = "pack"`, KerfScript:
46
+ The two plywood panels share a sheet. The acrylic window goes on a separate
47
+ sheet. Each part records the `$thickness`, `$kerf` and `$material` values in
48
+ effect where it is defined.
37
49
 
38
- 1. groups parts by material and thickness,
39
- 2. copies each part `qty` times,
40
- 3. turns a part 90° when that makes it fit,
41
- 4. packs them in rows onto sheets of `$sheet` (600 by 400 mm by default),
42
- with `$gap` millimetres between parts and around the edge.
50
+ ## Sheets
43
51
 
44
- A part bigger than the sheet gives a warning. With `$layout = "none"` parts
45
- stay where your program put them.
52
+ Set the available sheet size and spacing in millimetres:
46
53
 
47
54
  ```kerf
48
55
  $sheet = [300, 200];
49
56
  $gap = 4;
50
57
  ```
51
58
 
52
- ## One file per sheet
59
+ With the default `$layout = "pack"`, KerfScript arranges copies of each part
60
+ in rows, leaving the specified gap. It rotates a part 90° if that lets it
61
+ fit the sheet. The default sheet is 600 × 400 mm, with a 3 mm gap between
62
+ parts and at the sheet edges.
53
63
 
54
- The design above makes two sheets: one of plywood and one of acrylic. The
55
- combined SVG shows every sheet stacked one above the other, which is useful
56
- for a preview but is **not** a cutting job: the sheets are different
57
- materials.
64
+ A part larger than the sheet produces a warning. Set `$layout = "none"`
65
+ to keep the positions from your code instead of packing the parts.
66
+
67
+ The CLI `--margin` option and API `margin` option let you set the edge
68
+ spacing separately from the gap between parts.
69
+
70
+ ## One file per sheet
58
71
 
59
- Cut each sheet as its own job:
72
+ A combined SVG stacks all sheets in one preview. For the material example
73
+ above, export the plywood and acrylic sheets separately and cut each with
74
+ the matching material settings.
60
75
 
61
- - On the command line, `--split` writes one file per sheet
62
- (`design-1.svg`, `design-2.svg`, ...). `kerf check` lists the sheets with
63
- their material and thickness.
64
- - From JavaScript, `result.sheets` has an SVG and a DXF for each sheet, with
65
- its `material` and `thickness`.
76
+ - On the command line, add `--split` to write `design-1.svg`,
77
+ `design-2.svg` and so on. `kerf check` lists each sheet's material and
78
+ thickness.
79
+ - In JavaScript, `result.sheets` provides the SVG, DXF, material and
80
+ thickness for each sheet.
66
81
 
67
- Before cutting, check that each file's material and thickness match the
68
- sheet in your machine.
82
+ DXF exports contain one sheet per file.
package/docs/versions.md CHANGED
@@ -1,43 +1,33 @@
1
1
  # Versions
2
2
 
3
- KerfScript has two version numbers.
3
+ KerfScript 0.2.0 implements language version 0.1. The package version tracks
4
+ the software release; the language version tracks the syntax and behavior
5
+ of `.kerf` programs.
4
6
 
5
- - The **language version** (now 0.1) covers what `.kerf` files mean: the
6
- syntax, the built-in modules and functions, and the rules for layers, kerf
7
- and parts. The [language reference](../LANGUAGE.md) describes one language
8
- version.
9
- - The **package version** (now 0.2.0) is the version of the interpreter, the
10
- `kerf` command and the JavaScript API. It changes more often: bug fixes,
11
- new output options and API additions do not change the language.
12
-
13
- The site footer, `kerf --version` and the `VERSION` and `LANGUAGE_VERSION`
14
- exports show both.
7
+ Package updates can include bug fixes, export options and JavaScript API
8
+ changes without changing the language version. Use `kerf --version` to see
9
+ both numbers, or read the `VERSION` and `LANGUAGE_VERSION` exports in JavaScript.
15
10
 
16
11
  ## Before 1.0
17
12
 
18
- KerfScript is young, and the language may still change before 1.0. What we
19
- promise in the meantime:
13
+ The language may change before 1.0. Release notes identify changes that
14
+ affect existing programs or their output, including geometry and text layout
15
+ fixes. Removing or renaming a language feature requires a new language version.
20
16
 
21
- - **Changes are written down.** Every change that can alter what a file
22
- produces is listed in the changelog under the version that made it.
23
- - **Files keep running where we can manage it.** A program that worked keeps
24
- working, or stops with an error that says what to change. It does not
25
- silently start cutting something different.
26
- - **Geometry changes are called out.** If the same file starts producing
27
- different geometry, for example after a packing or text layout fix, the
28
- changelog says which designs are affected.
29
- - **Breaking changes raise the language version.** Package releases within
30
- one language version do not remove or rename anything in the language.
17
+ Check the changelog when upgrading a tool that renders saved designs.
31
18
 
32
19
  ## From 1.0
33
20
 
34
- From language version 1.0, `.kerf` files written for 1.x keep producing the
35
- same parts in every later 1.x interpreter, apart from bug fixes listed in the
36
- changelog. New features are additions. Anything that would change existing
37
- files waits for 2.0.
21
+ The compatibility policy for language version 1.x is to keep existing
22
+ programs working throughout that series. New features will be added without
23
+ changing existing syntax. Bug fixes that affect output will be listed in
24
+ the changelog; other breaking changes will require language version 2.0.
38
25
 
39
26
  ## Pinning a version
40
27
 
41
- Hosts that store designs, like MyLaserTools, record which interpreter
42
- version a design was published with, so a stored design can be checked
43
- against later versions before it is upgraded.
28
+ For repeatable exports, record the interpreter version, settings and font
29
+ files used with a design. Applications that store designs should retain
30
+ that information and compare the output before upgrading the interpreter.
31
+
32
+ Pin the npm package to an exact version when your application needs a fixed
33
+ renderer, for example `@mylasertools/kerfscript@0.2.0`.
package/package.json CHANGED
@@ -1,15 +1,15 @@
1
1
  {
2
2
  "name": "@mylasertools/kerfscript",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "KerfScript: a programming language for laser cutting. Write parametric 2D parts with cut, score and engrave layers, kerf compensation and joinery, and export SVG or DXF.",
5
5
  "type": "module",
6
6
  "license": "AGPL-3.0-only",
7
7
  "author": "MyLaserTools",
8
8
  "repository": {
9
9
  "type": "git",
10
- "url": "git+https://github.com/mylasertools-com/kerfscript.git"
10
+ "url": "git+https://github.com/mylasertools/kerfscript.git"
11
11
  },
12
- "bugs": "https://github.com/mylasertools-com/kerfscript/issues",
12
+ "bugs": "https://github.com/mylasertools/kerfscript/issues",
13
13
  "keywords": [
14
14
  "kerfscript",
15
15
  "laser-cutting",
@@ -72,7 +72,8 @@
72
72
  "prepack": "npm run check",
73
73
  "format": "prettier --write .",
74
74
  "format:check": "prettier --check .",
75
- "compat": "node scripts/compat.mjs"
75
+ "compat": "node scripts/compat.mjs",
76
+ "readme-images": "npm run build && cd site && node ../scripts/readme-images.mjs"
76
77
  },
77
78
  "devDependencies": {
78
79
  "@types/node": "20.19.43",