@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.
- package/CHANGELOG.md +287 -0
- package/LANGUAGE.md +100 -44
- package/README.md +2 -1
- package/dist/assembly.d.cts +22 -1
- package/dist/assembly.d.ts +22 -1
- package/dist/bores.d.cts +10 -0
- package/dist/bores.d.ts +10 -0
- package/dist/cli.js +9977 -6847
- package/dist/colors.d.cts +4 -0
- package/dist/colors.d.ts +4 -0
- package/dist/customizer.d.cts +3 -0
- package/dist/customizer.d.ts +3 -0
- package/dist/effects.d.cts +31 -0
- package/dist/effects.d.ts +31 -0
- package/dist/evaluator.d.cts +10 -1
- package/dist/evaluator.d.ts +10 -1
- package/dist/export/mesh.d.cts +66 -0
- package/dist/export/mesh.d.ts +66 -0
- package/dist/export/model.d.cts +14 -0
- package/dist/export/model.d.ts +14 -0
- package/dist/export/pages.d.cts +23 -0
- package/dist/export/pages.d.ts +23 -0
- package/dist/export/triangulate.d.cts +5 -0
- package/dist/export/triangulate.d.ts +5 -0
- package/dist/export/zip.d.cts +5 -0
- package/dist/export/zip.d.ts +5 -0
- package/dist/geometry.d.cts +21 -0
- package/dist/geometry.d.ts +21 -0
- package/dist/hardware.d.cts +2 -0
- package/dist/hardware.d.ts +2 -0
- package/dist/highlight.cjs +2 -2
- package/dist/highlight.js +2 -2
- package/dist/import/dbg.d.cts +1 -0
- package/dist/import/dbg.d.ts +1 -0
- package/dist/index.cjs +1693 -75
- package/dist/index.d.cts +9 -3
- package/dist/index.d.ts +9 -3
- package/dist/index.js +1693 -75
- package/dist/instructions.d.cts +27 -0
- package/dist/instructions.d.ts +27 -0
- package/dist/language.cjs +1664 -53
- package/dist/language.js +1664 -53
- package/dist/libraries.cjs +1641 -36
- package/dist/libraries.js +1641 -36
- package/dist/lights.d.cts +38 -0
- package/dist/lights.d.ts +38 -0
- package/dist/png.d.cts +14 -0
- package/dist/png.d.ts +14 -0
- package/dist/render.d.cts +8 -0
- package/dist/render.d.ts +8 -0
- package/dist/signatures.cjs +98 -9
- package/dist/signatures.js +98 -9
- package/dist/text.d.cts +29 -0
- package/dist/text.d.ts +29 -0
- package/dist/verify/types.d.cts +6 -0
- package/dist/verify/types.d.ts +6 -0
- package/docs/3d-files.md +93 -0
- package/docs/cli.md +38 -22
- package/docs/customizer.md +69 -0
- package/docs/javascript.md +51 -0
- package/docs/layers.md +24 -1
- package/docs/library.md +574 -16
- package/docs/openscad.md +15 -13
- package/docs/parts-and-sheets.md +207 -29
- package/docs/verification.md +1 -1
- package/docs/versions.md +2 -2
- package/package.json +1 -1
package/docs/3d-files.md
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
# 3D files
|
|
2
|
+
|
|
3
|
+
KerfScript writes a model in 3D as well as the files you cut: a GLB to look
|
|
4
|
+
at or render, a 3MF to 3D print in colour, or an STL. Each part becomes a
|
|
5
|
+
solid as thick as its sheet, and what is engraved or scored on it becomes a
|
|
6
|
+
thin coloured layer on its face.
|
|
7
|
+
|
|
8
|
+
```sh
|
|
9
|
+
kerf render box.kerf -o box.glb # the assembled model, to view or render
|
|
10
|
+
kerf render sign.kerf -o sign.3mf --print # laid out to print in colour
|
|
11
|
+
kerf render coaster.kerf -o coaster.stl # one mesh
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
The format follows the file's extension.
|
|
15
|
+
|
|
16
|
+
## What is in the model
|
|
17
|
+
|
|
18
|
+
- **Parts** are solids `$thickness` thick, where `part(at, rotate)` and
|
|
19
|
+
`place()` put them. A part that bends on a living hinge is bent, its
|
|
20
|
+
hinge's slits cut through it. Each copy of a part is a solid of its own.
|
|
21
|
+
- **Engraving and scoring** are separate bodies on the part's face, in their
|
|
22
|
+
layer's colour, standing 0.1 mm off it (`--mark-height` sets how far).
|
|
23
|
+
Score lines become strips 0.3 mm wide. Each overlaps the face by 0.01 mm,
|
|
24
|
+
so the two never share a face. Marks for the back face (`side = "back"`)
|
|
25
|
+
are on the back.
|
|
26
|
+
- **Hardware** from `hardware()` becomes rods, bars and balls in its colour.
|
|
27
|
+
|
|
28
|
+
A program that places no parts is laid out flat, as `--flat` does.
|
|
29
|
+
|
|
30
|
+
## Assembled or flat
|
|
31
|
+
|
|
32
|
+
By default the parts are where the assembly puts them. With `--flat` they
|
|
33
|
+
lie side by side on the bed, front face up, which is how a flat design
|
|
34
|
+
prints: a coaster, a sign, an ornament, a bookmark. Laid flat, marks for
|
|
35
|
+
the back face and hardware are left out, since nothing can stand under a
|
|
36
|
+
part on the bed.
|
|
37
|
+
|
|
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.
|
|
47
|
+
|
|
48
|
+
```sh
|
|
49
|
+
kerf render snow-scene.kerf -o snow-scene.3mf --print
|
|
50
|
+
```
|
|
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
|
+
|
|
56
|
+
## Formats
|
|
57
|
+
|
|
58
|
+
| File | Units | Holds |
|
|
59
|
+
| ------ | ------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
60
|
+
| `.glb` | metres, y up (glTF) | a node and mesh for each body, with materials named after the sheet material or layer; each node's `extras` give its `kind` (part, mark, hardware), `part` and `copy` |
|
|
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 |
|
|
62
|
+
| `.stl` | millimetres, z up | every body in one mesh, without colours |
|
|
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
|
+
|
|
74
|
+
Every part and mark is a closed solid: each edge is shared by exactly two
|
|
75
|
+
triangles, facing out. A bent part is the exception: it is built from bands
|
|
76
|
+
across its hinge, which meet inside it.
|
|
77
|
+
|
|
78
|
+
## From JavaScript
|
|
79
|
+
|
|
80
|
+
```js
|
|
81
|
+
import { render, toModel } from '@mylasertools/kerfscript';
|
|
82
|
+
|
|
83
|
+
const result = render(source);
|
|
84
|
+
const glb = toModel(result, 'glb'); // a Uint8Array
|
|
85
|
+
const print = toModel(result, '3mf', { layout: 'print', markHeight: 0.6 });
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
`meshBodies(result, options)` gives the bodies themselves (positions and
|
|
89
|
+
triangles in millimetres) for a viewer of your own, and `toGlb()`, `to3mf()`
|
|
90
|
+
and `toStl()` write them. The options are `layout` (`"assembled"`,
|
|
91
|
+
`"flat"` or `"print"`), `markHeight`, `lineWidth`, `slitWidth`, `hardware`
|
|
92
|
+
and `gap`.
|
|
93
|
+
See the [JavaScript API](javascript.md).
|
package/docs/cli.md
CHANGED
|
@@ -104,28 +104,33 @@ installed libraries by themselves.
|
|
|
104
104
|
|
|
105
105
|
## Options
|
|
106
106
|
|
|
107
|
-
| Option | Use
|
|
108
|
-
| ---------------------- |
|
|
109
|
-
| `-o, --out <file>` | Output path ending in `.svg`, `.dxf` or `.json`; defaults to `<file>.svg`
|
|
110
|
-
| `-D name=value` | Override a parameter; repeat for multiple values
|
|
111
|
-
| `-p, --params <file>` | Load parameter values from a JSON file
|
|
112
|
-
| `--font <file.ttf>` | Supply a font file; repeat for multiple fonts. `Atkinson` is built in
|
|
113
|
-
| `--kerf <mm>` | Override kerf for every part
|
|
114
|
-
| `--sheet <W>x<H>` | Set the sheet width and height in millimetres
|
|
115
|
-
| `--gap <mm>` | Set spacing between parts
|
|
116
|
-
| `--margin <mm>` | Set spacing at sheet edges; defaults to the gap
|
|
117
|
-
| `--no-pack` | Keep the positions defined in the program
|
|
118
|
-
| `--guides` | Include the guide layer
|
|
119
|
-
| `--split` | Export one file per sheet, and each sheet's back-face job
|
|
120
|
-
| `--nest` | Pack small parts into the holes of bigger ones
|
|
121
|
-
| `--stats` | With `check`: points in the files, by part and layer
|
|
122
|
-
| `--sweep name=a:s:b` | With `check`: try every value from a to b in steps of s, or `name=a,b,c`
|
|
123
|
-
| `--
|
|
124
|
-
|
|
|
125
|
-
| `--
|
|
126
|
-
|
|
|
127
|
-
|
|
|
128
|
-
|
|
|
107
|
+
| Option | Use |
|
|
108
|
+
| ---------------------- | ----------------------------------------------------------------------------------------------- |
|
|
109
|
+
| `-o, --out <file>` | Output path ending in `.svg`, `.dxf` or `.json`; defaults to `<file>.svg` |
|
|
110
|
+
| `-D name=value` | Override a parameter; repeat for multiple values |
|
|
111
|
+
| `-p, --params <file>` | Load parameter values from a JSON file |
|
|
112
|
+
| `--font <file.ttf>` | Supply a font file; repeat for multiple fonts. `Atkinson` is built in |
|
|
113
|
+
| `--kerf <mm>` | Override kerf for every part |
|
|
114
|
+
| `--sheet <W>x<H>` | Set the sheet width and height in millimetres |
|
|
115
|
+
| `--gap <mm>` | Set spacing between parts |
|
|
116
|
+
| `--margin <mm>` | Set spacing at sheet edges; defaults to the gap |
|
|
117
|
+
| `--no-pack` | Keep the positions defined in the program |
|
|
118
|
+
| `--guides` | Include the guide layer |
|
|
119
|
+
| `--split` | Export one file per sheet, and each sheet's back-face job |
|
|
120
|
+
| `--nest` | Pack small parts into the holes of bigger ones |
|
|
121
|
+
| `--stats` | With `check`: points in the files, by part and layer |
|
|
122
|
+
| `--sweep name=a:s:b` | With `check`: try every value from a to b in steps of s, or `name=a,b,c` |
|
|
123
|
+
| `--settings` | With `check`: what each setting changes across its range; exit 1 if one changes nothing |
|
|
124
|
+
| `--drive` | With `check`: try every value of the setting marked `drive` (see the customizer) |
|
|
125
|
+
| `-o out.png`, `--px n` | A picture of each sheet, `n` pixels wide (1200), to look at rather than cut |
|
|
126
|
+
| `-o out.glb` | The model in 3D: `.glb` to view, `.3mf` to print in colour, `.stl`; see [3D files](3d-files.md) |
|
|
127
|
+
| `--flat` | With a 3D file: the parts side by side, front face up |
|
|
128
|
+
| `--print` | With a 3D file: to print, each part and what is glued on it one object; marks 0.6 mm high |
|
|
129
|
+
| `--mark-height <mm>` | With a 3D file: how far engraving and scoring stand off the face (0.1) |
|
|
130
|
+
| `--call 'm(1, 2)'` | Run one call of the file's modules instead of its program; `-D` sets variables first |
|
|
131
|
+
| `--params-list file` | With `check`: try each set of settings in a JSON list of objects |
|
|
132
|
+
| `-h, --help` | Show command help |
|
|
133
|
+
| `-v, --version` | Show version numbers |
|
|
129
134
|
|
|
130
135
|
`-D` accepts KerfScript values, including numbers, quoted strings, booleans
|
|
131
136
|
and lists. For example: `-D width=200` or `-D 'name="Ada"'`.
|
|
@@ -174,6 +179,17 @@ step's parts in orange, and the parts and hardware it adds. With
|
|
|
174
179
|
kerf instructions lock-box.kerf -o lock-box-instructions.html
|
|
175
180
|
```
|
|
176
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
|
+
|
|
177
193
|
`kerf diff` renders two designs (or one design before and after a change)
|
|
178
194
|
with the same settings and lists, part by part and layer by layer, what
|
|
179
195
|
differs: the area of shapes that changed, open lines added or removed, and
|
package/docs/customizer.md
CHANGED
|
@@ -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 +86,62 @@ The playground gives it a Play button that steps it round its range, and
|
|
|
73
86
|
any position that warns (parts colliding, a slot that misses), as
|
|
74
87
|
`--sweep crank=0:5:360` would. `kerf params` lists it with `"drive": true`.
|
|
75
88
|
|
|
89
|
+
## Settings that apply only sometimes
|
|
90
|
+
|
|
91
|
+
A setting that matters only with certain other choices can say so with
|
|
92
|
+
`when` and a condition at the end of its comment, after its range or
|
|
93
|
+
choices or on its own. The playground and the desktop app show it only
|
|
94
|
+
while the condition holds, and hide a group when none of its settings
|
|
95
|
+
show:
|
|
96
|
+
|
|
97
|
+
```kerf
|
|
98
|
+
mount = "wall"; // [wall:On a wall, stand:On a stand]
|
|
99
|
+
// Room for the stand's tabs in their slots
|
|
100
|
+
clearance = 0.15; // [0:0.05:0.5] when mount == "stand"
|
|
101
|
+
// Hole for a nail
|
|
102
|
+
hole = 5; // when mount == "wall"
|
|
103
|
+
|
|
104
|
+
rect([120, 80], r = 6);
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
The condition can use the other settings by name, numbers, strings,
|
|
108
|
+
`true` and `false`, comparisons, `&&`, `||`, `!`, arithmetic, `? :` and
|
|
109
|
+
`[i]` indexing. A condition that names something other than a setting, or
|
|
110
|
+
calls a function, is reported as a warning, and the setting then always
|
|
111
|
+
shows. `kerf params` lists the condition as `"when"`, and in JavaScript
|
|
112
|
+
`shown(parameter, values, parameters)` says whether a setting applies to
|
|
113
|
+
the values chosen so far.
|
|
114
|
+
|
|
115
|
+
## Settings that do nothing
|
|
116
|
+
|
|
117
|
+
A setting whose slider moves nothing confuses the people using the design.
|
|
118
|
+
`kerf check --settings` tries each setting across its range, the others as
|
|
119
|
+
they are, and says what it changes:
|
|
120
|
+
|
|
121
|
+
```text
|
|
122
|
+
$ kerf check sign.kerf --settings
|
|
123
|
+
Each setting tried across its range, the others as they are:
|
|
124
|
+
name: changes the files
|
|
125
|
+
band: changes the files
|
|
126
|
+
from 50 to 60 it changes nothing
|
|
127
|
+
notes: changes nothing at "for the shop", "for th", "pohs eht rof"
|
|
128
|
+
lift: changes only the assembled view, not the files
|
|
129
|
+
mount: changes the files
|
|
130
|
+
"wall" and "hook" give the same result
|
|
131
|
+
clearance: not tried, as it applies only when mount == "stand"
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
A range is tried at its ends and three points between, a menu at every
|
|
135
|
+
choice, a checkbox both ways and text shorter and changed. The files, the
|
|
136
|
+
sheets' material and thickness and the parts list count as what is cut;
|
|
137
|
+
each part's shape, marks and place as the assembled view. A setting that
|
|
138
|
+
changes nothing, or that the program stops at for all values but one, makes
|
|
139
|
+
the command exit with 1, with the errors listed; a range where nothing
|
|
140
|
+
changes, or choices that give the same result, are pointed out without
|
|
141
|
+
failing. The
|
|
142
|
+
setting marked `drive` and settings whose `when` doesn't hold are left out.
|
|
143
|
+
In JavaScript, `settingEffects(source, options)` gives the same as a list.
|
|
144
|
+
|
|
76
145
|
## Changing settings without editing the file
|
|
77
146
|
|
|
78
147
|
The CLI accepts values with `-D` or a JSON file with `--params`:
|
package/docs/javascript.md
CHANGED
|
@@ -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 |
|
|
@@ -127,6 +128,56 @@ if (width) {
|
|
|
127
128
|
Read the settings again after editing the source; the offsets refer to the
|
|
128
129
|
string passed to `parameters()`.
|
|
129
130
|
|
|
131
|
+
A setting whose comment ends with a `when` condition (see the
|
|
132
|
+
[customizer](customizer.md)) has it as `when`. `shown()` says whether it
|
|
133
|
+
applies to the values chosen so far, the others at their initial values:
|
|
134
|
+
|
|
135
|
+
```js
|
|
136
|
+
import { parameters, shown } from '@mylasertools/kerfscript';
|
|
137
|
+
|
|
138
|
+
const settings = parameters(source).parameters;
|
|
139
|
+
const visible = settings.filter((p) => shown(p, { mount: 'stand' }, settings));
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
## settingEffects()
|
|
143
|
+
|
|
144
|
+
What each setting changes, as `kerf check --settings` reports it:
|
|
145
|
+
|
|
146
|
+
```js
|
|
147
|
+
import { settingEffects } from '@mylasertools/kerfscript';
|
|
148
|
+
|
|
149
|
+
for (const e of settingEffects(source)) console.log(e.name, e.effect, e.same);
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
Each entry has `name`, the values `tried` and `effect`: `"files"`,
|
|
153
|
+
`"view"` (only the assembled view, steps or hardware), `"nothing"`,
|
|
154
|
+
`"failed"` (the program stops at all values but one, or all of them) or
|
|
155
|
+
`"skipped"` with a `reason`. `same` lists runs of a range, or groups of
|
|
156
|
+
choices, that give the same result, and `errors` the values the program
|
|
157
|
+
stops at. Pass render options as the second argument and how many values
|
|
158
|
+
of a range to try as the third (5).
|
|
159
|
+
|
|
160
|
+
## toModel()
|
|
161
|
+
|
|
162
|
+
Write the model in 3D, as [3D files](3d-files.md) describes:
|
|
163
|
+
|
|
164
|
+
```js
|
|
165
|
+
import { render, toModel } from '@mylasertools/kerfscript';
|
|
166
|
+
|
|
167
|
+
const glb = toModel(render(source), 'glb');
|
|
168
|
+
const print = toModel(render(source), '3mf', { layout: 'print', markHeight: 0.6 });
|
|
169
|
+
```
|
|
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.
|
|
176
|
+
`meshBodies(result, options)` gives the solid bodies (positions and
|
|
177
|
+
triangles in millimetres, z up) for a viewer of your own; `toGlb()`,
|
|
178
|
+
`to3mf()` and `toStl()` write a list of them. `result.flat` lists every copy
|
|
179
|
+
of every part flat at its own origin, placed or not.
|
|
180
|
+
|
|
130
181
|
## format()
|
|
131
182
|
|
|
132
183
|
`format(source)` returns the program with its layout set, as `kerf fmt`
|
package/docs/layers.md
CHANGED
|
@@ -97,7 +97,8 @@ engrave() translate([40, 20]) circle(d = 12);
|
|
|
97
97
|
|
|
98
98
|
The rectangle and circle use separate engraving layers. You can assign each
|
|
99
99
|
a different power in your laser software. Supported modes are `"cut"`,
|
|
100
|
-
`"line"`, `"fill"` and `"
|
|
100
|
+
`"line"`, `"fill"`, `"guide"` and `"paint"`. The colour is a hex colour
|
|
101
|
+
or a colour's name, as `"red"`.
|
|
101
102
|
|
|
102
103
|
## The back face
|
|
103
104
|
|
|
@@ -128,6 +129,28 @@ part("tile") {
|
|
|
128
129
|
A child given the layer `""` is left out, but still covers the ones
|
|
129
130
|
before it: a bare patch.
|
|
130
131
|
|
|
132
|
+
## Painted areas
|
|
133
|
+
|
|
134
|
+
A layer with `mode = "paint"` marks areas painted by hand after cutting.
|
|
135
|
+
They are never in the files for the laser, but the 3D view and the print
|
|
136
|
+
layout show them in the layer's colour, on the part's own sheet:
|
|
137
|
+
|
|
138
|
+
```kerf
|
|
139
|
+
layer("red", mode = "paint", color = "red");
|
|
140
|
+
layer("white", mode = "paint", color = "white");
|
|
141
|
+
part("mushroom", paint = "cream") {
|
|
142
|
+
circle(d = 60);
|
|
143
|
+
paint(["red", "white"]) {
|
|
144
|
+
translate([0, 8]) circle(d = 50);
|
|
145
|
+
for (p = [[-10, 18], [8, 22], [0, 4]]) translate(p) circle(d = 8);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
Paint is clipped to the part, and a paint layer with `side = "back"`
|
|
151
|
+
paints the face underneath. `part(paint = colour)` paints the whole part;
|
|
152
|
+
see [Parts and sheets](parts-and-sheets.md).
|
|
153
|
+
|
|
131
154
|
## Printing on parts
|
|
132
155
|
|
|
133
156
|
To print on the parts and then cut them, `layer(name, mode = "fill",
|