@mylasertools/kerfscript 0.7.0 → 0.8.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 +34 -0
- package/LANGUAGE.md +16 -7
- package/dist/cli.js +205 -18
- package/dist/geometry.d.cts +5 -0
- package/dist/geometry.d.ts +5 -0
- package/dist/highlight.cjs +1 -1
- package/dist/highlight.js +1 -1
- package/dist/index.cjs +383 -46
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +383 -46
- package/dist/language.cjs +381 -44
- package/dist/language.js +381 -44
- package/dist/libraries.cjs +353 -16
- package/dist/libraries.js +351 -14
- package/dist/signatures.cjs +29 -4
- package/dist/signatures.js +29 -4
- package/dist/verify/solids.d.cts +2 -1
- package/dist/verify/solids.d.ts +2 -1
- package/dist/verify/types.d.cts +2 -0
- package/dist/verify/types.d.ts +2 -0
- package/docs/library.md +206 -4
- package/docs/parts-and-sheets.md +31 -18
- package/docs/versions.md +2 -2
- package/package.json +1 -1
package/dist/signatures.js
CHANGED
|
@@ -312,7 +312,7 @@ var SIGNATURES = [
|
|
|
312
312
|
params: [p("draw", "Draw the first child too", "false")],
|
|
313
313
|
children: true,
|
|
314
314
|
section: "Combining",
|
|
315
|
-
doc: "Set $bounds = [x0, y0, x1, y1] of the first child for the children after it"
|
|
315
|
+
doc: "Set $bounds = [x0, y0, x1, y1], $area and $centroid = [x, y] of the first child for the children after it"
|
|
316
316
|
},
|
|
317
317
|
{
|
|
318
318
|
name: "fill_holes",
|
|
@@ -420,6 +420,7 @@ var SIGNATURES = [
|
|
|
420
420
|
named("rotate", "How the part is turned in the assembled view, [x, y, z] in degrees"),
|
|
421
421
|
named("stack", "Layers glued in a stack at each placement, one thickness apart", "1"),
|
|
422
422
|
named("mirror", "Cut the part mirrored left to right, its text still reading", "false"),
|
|
423
|
+
named("material", "The material it is cut from, as material(name = ...) sets it"),
|
|
423
424
|
named("bend", "Living hinge bends in the assembled view: [x0, x1, angle] or a list"),
|
|
424
425
|
named("on", "The name of a bent part this one is glued to, to move with it"),
|
|
425
426
|
named("slots", "Names of parts whose tabs pass through this one: their slots are cut"),
|
|
@@ -470,11 +471,12 @@ var SIGNATURES = [
|
|
|
470
471
|
kind: "module",
|
|
471
472
|
params: [
|
|
472
473
|
p("kind", 'What it is, as "dowel", "screw", "magnet", "elastic" or "paper"', '"dowel"'),
|
|
473
|
-
p("from", "One end, [x, y, z]"),
|
|
474
|
-
p("to", "The other end, [x, y, z]"),
|
|
474
|
+
p("from", "One end, [x, y, z]; a ball sits midway between from and to"),
|
|
475
|
+
p("to", "The other end, [x, y, z]; a ball may leave it out"),
|
|
475
476
|
p("size", "Diameter, or [width, height] for a flat section", "6"),
|
|
476
477
|
named("up", "The direction a [width, height] section's height points"),
|
|
477
|
-
named("sides", "Sides of a round section in the 3D view", "24"),
|
|
478
|
+
named("sides", "Sides of a round section in the 3D view; 0 makes a ball", "24"),
|
|
479
|
+
named("shape", '"rod", or "ball" for a bulb, a marble or a bead', '"rod"'),
|
|
478
480
|
named("label", "The name in the hardware list")
|
|
479
481
|
],
|
|
480
482
|
children: true,
|
|
@@ -631,6 +633,18 @@ var SIGNATURES = [
|
|
|
631
633
|
section: "Numbers and vectors",
|
|
632
634
|
doc: "Interpolate between numbers or vectors"
|
|
633
635
|
},
|
|
636
|
+
{
|
|
637
|
+
name: "train_for",
|
|
638
|
+
kind: "function",
|
|
639
|
+
params: [
|
|
640
|
+
p("ratio", "Turns in for one turn out; under 1 speeds up"),
|
|
641
|
+
p("stages", "Pairs of gears, 1 to 3", "2"),
|
|
642
|
+
p("pinion", "Fewest and most teeth of the small gears", "[10, 20]"),
|
|
643
|
+
p("wheel", "Fewest and most teeth of the big gears", "[20, 80]")
|
|
644
|
+
],
|
|
645
|
+
section: "Numbers and vectors",
|
|
646
|
+
doc: "Tooth counts for a gear train nearest a ratio: {stages = [[driver, driven], ...], ratio, error}"
|
|
647
|
+
},
|
|
634
648
|
{
|
|
635
649
|
name: "norm",
|
|
636
650
|
kind: "function",
|
|
@@ -653,6 +667,17 @@ var SIGNATURES = [
|
|
|
653
667
|
section: "Paths and rotations",
|
|
654
668
|
doc: "The length of the lines through a list of points"
|
|
655
669
|
},
|
|
670
|
+
{
|
|
671
|
+
name: "offset_path",
|
|
672
|
+
kind: "function",
|
|
673
|
+
params: [
|
|
674
|
+
p("points", "A list of [x, y] points"),
|
|
675
|
+
p("d", "How far to move it: to the left going along it, or the right when less than 0"),
|
|
676
|
+
p("closed", "The path goes round, its last point joined to its first", "false")
|
|
677
|
+
],
|
|
678
|
+
section: "Paths and rotations",
|
|
679
|
+
doc: "The path moved sideways, each corner mitred: the two edges of a strip along a curve"
|
|
680
|
+
},
|
|
656
681
|
{
|
|
657
682
|
name: "point_at",
|
|
658
683
|
kind: "function",
|
package/dist/verify/solids.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type Vec3 } from '../assembly.cjs';
|
|
2
|
-
import type { BodyRef, Trajectory, VerificationSnapshot } from './types.cjs';
|
|
2
|
+
import type { BodyRef, SnapshotHardware, Trajectory, VerificationSnapshot } from './types.cjs';
|
|
3
3
|
export declare class WorkBudget {
|
|
4
4
|
remaining: number;
|
|
5
5
|
constructor(remaining?: number);
|
|
@@ -23,6 +23,7 @@ export interface Solid {
|
|
|
23
23
|
inner: Cell[];
|
|
24
24
|
}
|
|
25
25
|
export declare function allBodies(s: VerificationSnapshot): BodyRef[];
|
|
26
|
+
export declare function hardwareEnds(h: SnapshotHardware): [Vec3, Vec3];
|
|
26
27
|
export declare function bodyMatrix(s: VerificationSnapshot, r: BodyRef): number[];
|
|
27
28
|
export declare function makeSolid(s: VerificationSnapshot, ref: BodyRef, budget: WorkBudget): Solid;
|
|
28
29
|
export declare function transformSolid(s: Solid, m: number[]): Solid;
|
package/dist/verify/solids.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type Vec3 } from '../assembly.js';
|
|
2
|
-
import type { BodyRef, Trajectory, VerificationSnapshot } from './types.js';
|
|
2
|
+
import type { BodyRef, SnapshotHardware, Trajectory, VerificationSnapshot } from './types.js';
|
|
3
3
|
export declare class WorkBudget {
|
|
4
4
|
remaining: number;
|
|
5
5
|
constructor(remaining?: number);
|
|
@@ -23,6 +23,7 @@ export interface Solid {
|
|
|
23
23
|
inner: Cell[];
|
|
24
24
|
}
|
|
25
25
|
export declare function allBodies(s: VerificationSnapshot): BodyRef[];
|
|
26
|
+
export declare function hardwareEnds(h: SnapshotHardware): [Vec3, Vec3];
|
|
26
27
|
export declare function bodyMatrix(s: VerificationSnapshot, r: BodyRef): number[];
|
|
27
28
|
export declare function makeSolid(s: VerificationSnapshot, ref: BodyRef, budget: WorkBudget): Solid;
|
|
28
29
|
export declare function transformSolid(s: Solid, m: number[]): Solid;
|
package/dist/verify/types.d.cts
CHANGED
|
@@ -48,6 +48,8 @@ export interface SnapshotHardware {
|
|
|
48
48
|
to: Vec3;
|
|
49
49
|
size: number | [number, number];
|
|
50
50
|
up: Vec3;
|
|
51
|
+
/** A ball of diameter size centred at from (from and to are the same point) */
|
|
52
|
+
shape?: 'ball';
|
|
51
53
|
}
|
|
52
54
|
export interface VerificationSnapshot {
|
|
53
55
|
schemaVersion: 1;
|
package/dist/verify/types.d.ts
CHANGED
|
@@ -48,6 +48,8 @@ export interface SnapshotHardware {
|
|
|
48
48
|
to: Vec3;
|
|
49
49
|
size: number | [number, number];
|
|
50
50
|
up: Vec3;
|
|
51
|
+
/** A ball of diameter size centred at from (from and to are the same point) */
|
|
52
|
+
shape?: 'ball';
|
|
51
53
|
}
|
|
52
54
|
export interface VerificationSnapshot {
|
|
53
55
|
schemaVersion: 1;
|
package/docs/library.md
CHANGED
|
@@ -26,7 +26,9 @@ show each module's description when you hover over it.
|
|
|
26
26
|
| [`kerf/hanging`](#hanging) | Keyholes, holes and loops for hanging things on a wall |
|
|
27
27
|
| [`kerf/enclosure`](#enclosures) | Boxes with a screwed-on lid, cutouts for ports and vents |
|
|
28
28
|
| [`kerf/calibration`](#calibration) | Test pieces that measure the kerf and how your sheet fits |
|
|
29
|
-
| [`kerf/gears`](#gears-and-cams) |
|
|
29
|
+
| [`kerf/gears`](#gears-and-cams) | Gears, racks, cams, Geneva drives, ratchets and pawls |
|
|
30
|
+
| [`kerf/linkage`](#linkages) | Where linkage joints are at a crank angle |
|
|
31
|
+
| [`kerf/cones`](#cones) | Cones and cut-off cones cut flat, to roll up |
|
|
30
32
|
| [`kerf/lock`](#lock) | A lock with a key, three layers deep |
|
|
31
33
|
| [`kerf/rings`](#rings) | Round things of stacked rings on a crossed core |
|
|
32
34
|
| [`kerf/joints`](#joints) | Two profiles halved into each other: crosses, fonts, domes |
|
|
@@ -444,6 +446,27 @@ mesh with it turns `angle` degrees: the other way round.
|
|
|
444
446
|
|
|
445
447
|
The turn that lines a gear's teeth up with the gear beside it along x.
|
|
446
448
|
|
|
449
|
+
### `train_for(ratio, stages = 2, pinion = [10, 20], wheel = [20, 80])`
|
|
450
|
+
|
|
451
|
+
Tooth counts for a train of `stages` gear pairs (1 to 3) whose ratio, the
|
|
452
|
+
turns in for one turn out, comes nearest `ratio`. Each pair has a pinion
|
|
453
|
+
of `pinion` teeth and a wheel of `wheel` teeth on the next axle. It
|
|
454
|
+
returns `{stages = [[driver, driven], ...], ratio, error}`, `error` being
|
|
455
|
+
how far off it is, as a fraction; of equally near trains it picks the one
|
|
456
|
+
with fewest teeth. A ratio under 1 speeds up, so the wheels drive. It is
|
|
457
|
+
built in, so it works without `use <kerf/gears>`.
|
|
458
|
+
|
|
459
|
+
```kerf
|
|
460
|
+
use <kerf/gears>
|
|
461
|
+
|
|
462
|
+
// A year for the Earth in an orrery: [[10, 73], [10, 76], [12, 79]], 0.002% off
|
|
463
|
+
t = train_for(365.25, 3);
|
|
464
|
+
s = t.stages[0];
|
|
465
|
+
part("pinion") spur_gear(s[0], 1.5);
|
|
466
|
+
part("wheel", at = [gear_distance(s[0], s[1], 1.5), 0, 0], rotate = [0, 0, gear_phase(s[1])])
|
|
467
|
+
spur_gear(s[1], 1.5);
|
|
468
|
+
```
|
|
469
|
+
|
|
447
470
|
### `rack(teeth, mod = 2, height, pressure = 20, backlash = 0.1)`
|
|
448
471
|
|
|
449
472
|
A straight rack along +x, its pitch line at y = 0. A `spur_gear()` of the
|
|
@@ -467,6 +490,165 @@ Cams: an `eccentric()` pushes a follower up and down by twice `offset`; a
|
|
|
467
490
|
`snail_cam()` lifts it slowly from `r0` to `r1` over a turn and drops it at
|
|
468
491
|
once, as a trip hammer works; `tappets()` lift a lever `n` times a turn.
|
|
469
492
|
|
|
493
|
+
### `cam(lift, base_r, follower = "knife", roller_d = 0, bore = 6, steps = 180, square = false)`
|
|
494
|
+
|
|
495
|
+
A cam whose profile comes from a lift curve: `lift` is a function of the
|
|
496
|
+
angle (0 to 360) giving how far the follower rises above the base circle
|
|
497
|
+
of radius `base_r`. The follower rides on the cam's top (+y) and moves
|
|
498
|
+
straight up and down; turned anticlockwise by `a` degrees (`rotate = [0,
|
|
499
|
+
0, a]`) the cam lifts it `lift(a)`. A `"knife"` follower rides the curve
|
|
500
|
+
itself; a `"roller"` of diameter `roller_d` rolls on a profile inside it.
|
|
501
|
+
|
|
502
|
+
```kerf
|
|
503
|
+
use <kerf/gears>
|
|
504
|
+
|
|
505
|
+
$fn = 48;
|
|
506
|
+
turn = 0; // the cam's angle
|
|
507
|
+
// A bird that pecks twice, then rests
|
|
508
|
+
peck = function(a) cam_rise(a, 0, 40, 8) - cam_rise(a, 40, 80, 8) + cam_rise(a, 100, 140, 8) - cam_rise(a, 140, 180, 8);
|
|
509
|
+
part("cam", rotate = [0, 0, turn]) cam(peck, 25, "roller", 10);
|
|
510
|
+
part("roller", at = [0, cam_follower(peck, 25, turn, 10), 0]) difference() { circle(d = 10); circle(d = 3); }
|
|
511
|
+
```
|
|
512
|
+
|
|
513
|
+
### `cam_rise(a, a0, a1, height)`
|
|
514
|
+
|
|
515
|
+
A smooth (cycloidal) rise of `height` between angles `a0` and `a1`: 0
|
|
516
|
+
before, `height` after. Add and take away rises to make dwells, rises and
|
|
517
|
+
falls.
|
|
518
|
+
|
|
519
|
+
### `cam_follower(lift, base_r, angle, roller_d = 0)`, `cam_pressure(lift, base_r, roller_d = 0)`
|
|
520
|
+
|
|
521
|
+
How high the follower's tip, or its roller's centre, stands above the
|
|
522
|
+
cam's axle at `angle`, to place it from the same curve. `cam_pressure()` is
|
|
523
|
+
the steepest pressure angle over a turn: keep it under about 30 degrees,
|
|
524
|
+
with a bigger base circle or a longer rise, or the follower jams.
|
|
525
|
+
|
|
526
|
+
### `cam_pitch(lift, base_r, roller_d = 0, steps = 180)`
|
|
527
|
+
|
|
528
|
+
The curve the follower's tip or roller centre follows, in the cam's turn.
|
|
529
|
+
|
|
530
|
+
### `geneva_wheel(slots, distance, pin_d = 6, bore = 6, clearance = 0.2)`, `geneva_lock(...)`, `geneva_crank(...)`
|
|
531
|
+
|
|
532
|
+
A Geneva drive: a driver turning all the time steps a wheel on one slot
|
|
533
|
+
each turn and locks it in between, for counters, calendars and carousels
|
|
534
|
+
that stop to show each scene. The driver's axle is at the origin and the
|
|
535
|
+
wheel's `distance` along +x. The wheel and the locking disc lie side by
|
|
536
|
+
side in one plane; the crank above the disc carries a dowel pin of `pin_d`
|
|
537
|
+
that runs in the slots. With many slots the wheel comes close to the
|
|
538
|
+
driver's axle, and `geneva_lock()` says how small the bore must be.
|
|
539
|
+
|
|
540
|
+
```kerf
|
|
541
|
+
use <kerf/gears>
|
|
542
|
+
|
|
543
|
+
$fn = 48;
|
|
544
|
+
a = 0; // the driver's turn
|
|
545
|
+
part("wheel", at = [60, 0, 0], rotate = [0, 0, geneva_turn(6, 60, a)]) geneva_wheel(6, 60, 6);
|
|
546
|
+
part("lock", at = [0, 0, 0], rotate = [0, 0, a]) geneva_lock(6, 60, 6);
|
|
547
|
+
part("crank", at = [0, 0, $thickness], rotate = [0, 0, a]) geneva_crank(6, 60, 6);
|
|
548
|
+
```
|
|
549
|
+
|
|
550
|
+
### `geneva_turn(slots, distance, angle)`
|
|
551
|
+
|
|
552
|
+
How far the wheel has turned (clockwise) when the driver has turned
|
|
553
|
+
`angle` anticlockwise from its pin pointing at the wheel: `-360 / slots`
|
|
554
|
+
for each whole turn. With `geneva_pin_radius()`, `geneva_wheel_radius()`
|
|
555
|
+
and `geneva_lock_radius()` for the sizes.
|
|
556
|
+
|
|
557
|
+
### `ratchet(teeth, r, depth, bore = 6, square = false)`, `pawl(teeth, r, depth, length, width = 8, bore = 3, at = 90, clearance = 0.2)`
|
|
558
|
+
|
|
559
|
+
A ratchet wheel that turns anticlockwise freely, and a pawl that stops it
|
|
560
|
+
turning back: for a crank that winds one way, a counter or a typewriter
|
|
561
|
+
carriage. The pawl is drawn where it works round the wheel's centre, its
|
|
562
|
+
tip on the tooth face nearest `at` degrees, so give it the wheel's
|
|
563
|
+
placement. It turns on a pin at `pawl_pivot()`, and gravity, a rubber band
|
|
564
|
+
or a spring wire keeps it down on the teeth.
|
|
565
|
+
|
|
566
|
+
```kerf
|
|
567
|
+
use <kerf/gears>
|
|
568
|
+
|
|
569
|
+
$fn = 32;
|
|
570
|
+
part("wheel", at = [0, 0, 0]) ratchet(12, 30, 5);
|
|
571
|
+
part("pawl", at = [0, 0, 0]) pawl(12, 30, 5);
|
|
572
|
+
```
|
|
573
|
+
|
|
574
|
+
### `pawl_pivot(teeth, r, depth, length, width = 8, at = 90, clearance = 0.2)`, `pawl_points(...)`, `pawl_min_length(teeth, r, depth, width = 8)`, `pawl_face(teeth, at = 90)`, `pawl_lean(teeth, r, depth)`
|
|
575
|
+
|
|
576
|
+
Where the pawl's pivot pin goes round the wheel's centre, its outline, the
|
|
577
|
+
shortest it can be at a given width, the angle of the tooth face it rests
|
|
578
|
+
on, and how far it leans out from the wheel's edge to clear the teeth as
|
|
579
|
+
they pass. Left at 0, `length` is 0.8 × `r`, or the shortest that clears
|
|
580
|
+
the teeth on a small wheel; a `length` given shorter than that is an
|
|
581
|
+
error.
|
|
582
|
+
|
|
583
|
+
## Linkages
|
|
584
|
+
|
|
585
|
+
`use <kerf/linkage>`
|
|
586
|
+
|
|
587
|
+
Where the joints of a linkage are at a crank angle, so moving parts are
|
|
588
|
+
placed from the same numbers as the links' lengths: steam engine pistons,
|
|
589
|
+
typebars, walking legs, waving arms. Each takes the linkage drawn flat.
|
|
590
|
+
|
|
591
|
+
```kerf
|
|
592
|
+
use <kerf/linkage>
|
|
593
|
+
|
|
594
|
+
$fn = 32;
|
|
595
|
+
angle = 60; // the crank's turn
|
|
596
|
+
j = four_bar(80, 20, 70, 50, angle);
|
|
597
|
+
part("crank", at = [0, 0, 3], rotate = [0, 0, angle]) hull() { circle(d = 10); translate([20, 0]) circle(d = 10); }
|
|
598
|
+
part("rocker", at = [80, 0, 3], rotate = [0, 0, link_angle([80, 0], j[1])])
|
|
599
|
+
hull() { circle(d = 10); translate([50, 0]) circle(d = 10); }
|
|
600
|
+
```
|
|
601
|
+
|
|
602
|
+
### `circle_meet(a, ra, b, rb, side = 1)`
|
|
603
|
+
|
|
604
|
+
Where a circle of radius `ra` round `a` meets one of radius `rb` round `b`:
|
|
605
|
+
the point left of the line from `a` to `b`, or right of it with `side =
|
|
606
|
+
-1`. `undef` when they don't meet. Two links of those lengths from those
|
|
607
|
+
pivots join there.
|
|
608
|
+
|
|
609
|
+
### `slider_crank(r, l, angle, offset = 0)`, `slider_stroke(r, l, offset = 0)`
|
|
610
|
+
|
|
611
|
+
A crank of radius `r` round the origin drives a slider along `y = offset`
|
|
612
|
+
through a rod `l` long: `[crank pin, slider pin]` at the crank's `angle`,
|
|
613
|
+
or `undef` where the rod can't reach. `slider_stroke()` is how far the
|
|
614
|
+
slider travels.
|
|
615
|
+
|
|
616
|
+
### `four_bar(ground, crank, coupler, rocker, angle, side = 1)`, `four_bar_turns(ground, crank, coupler, rocker)`
|
|
617
|
+
|
|
618
|
+
A four-bar linkage with the crank's pivot at the origin and the rocker's at
|
|
619
|
+
`[ground, 0]`: `[crank end, rocker end]` at the crank's `angle`, or
|
|
620
|
+
`undef` where the links can't close. `four_bar_turns()` is true when the
|
|
621
|
+
crank turns all the way round (Grashof's rule).
|
|
622
|
+
|
|
623
|
+
### `link_angle(a, b)`
|
|
624
|
+
|
|
625
|
+
The angle of the line from `a` to `b`, to turn a link along it.
|
|
626
|
+
|
|
627
|
+
## Cones
|
|
628
|
+
|
|
629
|
+
`use <kerf/cones>`
|
|
630
|
+
|
|
631
|
+
Cones and cut-off cones cut flat from paper, card, veneer or thin plastic,
|
|
632
|
+
to roll up: gramophone horns, lampshades, funnels.
|
|
633
|
+
|
|
634
|
+
```kerf
|
|
635
|
+
use <kerf/cones>
|
|
636
|
+
|
|
637
|
+
$fn = 64;
|
|
638
|
+
part("shade") cone_flat(60, 25, 70, tab = 8);
|
|
639
|
+
```
|
|
640
|
+
|
|
641
|
+
### `cone_flat(r1, r2, h, tab = 0, steps = 0)`
|
|
642
|
+
|
|
643
|
+
The flat pattern of a cone of radius `r1` at one end, `r2` at the other,
|
|
644
|
+
`h` high: a ring sector with its apex at the origin, opening anticlockwise
|
|
645
|
+
from +x. `tab` adds a glue tab along the far edge with its fold scored.
|
|
646
|
+
Equal radii make a cylinder: a rectangle `2 * PI * r1` wide.
|
|
647
|
+
|
|
648
|
+
### `cone_pattern(r1, r2, h)`
|
|
649
|
+
|
|
650
|
+
The sector's `[outer radius, inner radius, angle, slant length]`.
|
|
651
|
+
|
|
470
652
|
## Lock
|
|
471
653
|
|
|
472
654
|
`use <kerf/lock>`
|
|
@@ -565,15 +747,35 @@ and boxes made to fit them.
|
|
|
565
747
|
standing; cards `"business"`, `"us business"`, `"credit"`, `"japan"`,
|
|
566
748
|
`"playing"`, `"bridge"`, `"tarot"`, `"postcard"` and `"us postcard"`, and
|
|
567
749
|
photos `"4x6"`, `"5x7"`, `"8x10"`, `"10x15"`, `"13x18"` and the instant
|
|
568
|
-
film sizes
|
|
750
|
+
film sizes `"instant mini"`, `"instant square"`, `"instant wide"` and
|
|
751
|
+
`"instant classic"`, lying down. An unknown name stops with the list of
|
|
752
|
+
known ones.
|
|
753
|
+
|
|
754
|
+
### `part_size(name)`
|
|
755
|
+
|
|
756
|
+
A bought part's sizes as a record: `body = [width, depth, height]`, and
|
|
757
|
+
for a part with a shaft its diameter `shaft`, the `shaft_length` it stands
|
|
758
|
+
out of the body and the `hole` to cut for it. `"music-18"` is an 18-note
|
|
759
|
+
wind-up music box movement (its shaft is the winding key's), and
|
|
760
|
+
`"quartz-clock"` a 56 mm quartz clock movement with the 16.5 mm shaft, for
|
|
761
|
+
dials up to `dial = 8` mm thick. `"marble-16"` and `"marble-25"` are
|
|
762
|
+
marbles. These are common retail sizes, which vary: measure yours.
|
|
763
|
+
|
|
764
|
+
```kerf
|
|
765
|
+
use <kerf/sizes>
|
|
766
|
+
|
|
767
|
+
m = part_size("quartz-clock");
|
|
768
|
+
part("dial") difference() { circle(d = 160); circle(d = m.hole); }
|
|
769
|
+
```
|
|
569
770
|
|
|
570
771
|
### `landscape(size)`, `portrait(size)`
|
|
571
772
|
|
|
572
773
|
A size turned to lie wider than tall, or to stand taller than wide.
|
|
573
774
|
|
|
574
|
-
### `lookup_size(name, table)`, `size_names(table)`
|
|
775
|
+
### `lookup_size(name, table)`, `size_names(table)`, `lookup_alias(name, aliases)`
|
|
575
776
|
|
|
576
|
-
The size of a name in a table of `[name, size]`,
|
|
777
|
+
The size of a name in a table of `[name, size]`, the names in it, and the
|
|
778
|
+
name an older name stands for in a table of `[old, new]`.
|
|
577
779
|
|
|
578
780
|
## Symbols
|
|
579
781
|
|
package/docs/parts-and-sheets.md
CHANGED
|
@@ -95,6 +95,8 @@ place(at = [20, 10, 30], rotate = [0, 0, 90]) box([80, 60, 40], name = "crate");
|
|
|
95
95
|
- `stack = 3` glues three layers at each placement, one thickness apart:
|
|
96
96
|
thick feet, posts and blocks from thin sheet. The parts list says how
|
|
97
97
|
many make a stack.
|
|
98
|
+
- `material = "red acrylic"` names the material the part is cut from,
|
|
99
|
+
as wrapping it in `material(name = "red acrylic")` would.
|
|
98
100
|
- `mirror = true` cuts the part mirrored left to right. A lopsided end
|
|
99
101
|
plate's other half is the same part mirrored, and its engraving still
|
|
100
102
|
reads the right way round.
|
|
@@ -188,28 +190,39 @@ from one point to another, a screw, a magnet, a strip of paper. `size` is
|
|
|
188
190
|
a diameter, or `[w, h]` for a flat piece. `kerf check` lists the hardware
|
|
189
191
|
with the parts, and the 3D view shows it.
|
|
190
192
|
|
|
193
|
+
`shape = "ball"` (or `sides = 0`) makes a ball of diameter `size` midway
|
|
194
|
+
between `from` and `to`, for a light bulb, a marble or a bead. A ball may
|
|
195
|
+
leave `to` out and sit at `from`: `hardware("bulb", [0, 0, 120], size = 60,
|
|
196
|
+
shape = "ball")`.
|
|
197
|
+
|
|
191
198
|
The kinds are these; a colour (`pink`, `yellow`, `red`, `green`, `blue`,
|
|
192
199
|
`orange`, `purple`, `black`, `grey`) works too, and any other kind warns
|
|
193
200
|
and shows grey. JavaScript gets the list as `HARDWARE_KINDS`.
|
|
194
201
|
|
|
195
|
-
| Kind
|
|
196
|
-
|
|
|
197
|
-
| `dowel`
|
|
198
|
-
| `steel`
|
|
199
|
-
| `brass`
|
|
200
|
-
| `screw`
|
|
201
|
-
| `bolt`
|
|
202
|
-
| `nut`
|
|
203
|
-
| `magnet`
|
|
204
|
-
| `paper`
|
|
205
|
-
| `card`
|
|
206
|
-
| `felt`
|
|
207
|
-
| `elastic`
|
|
208
|
-
| `cord`
|
|
209
|
-
| `ribbon`
|
|
210
|
-
| `wire`
|
|
211
|
-
| `led`
|
|
212
|
-
| `
|
|
202
|
+
| Kind | What it is | Shown |
|
|
203
|
+
| ---------- | ------------------------------------------- | ---------------- |
|
|
204
|
+
| `dowel` | a wooden dowel or axle | matt, #e2c48f |
|
|
205
|
+
| `steel` | a steel rod, pin or axle | metal, #a7adb3 |
|
|
206
|
+
| `brass` | a brass rod, tube or pin | metal, #c9a227 |
|
|
207
|
+
| `screw` | a screw | metal, #9aa0a6 |
|
|
208
|
+
| `bolt` | a bolt | metal, #9aa0a6 |
|
|
209
|
+
| `nut` | a nut | metal, #9aa0a6 |
|
|
210
|
+
| `magnet` | a disc or block magnet | metal, #55585c |
|
|
211
|
+
| `paper` | a sheet or strip of paper | matt, #fbfaf6 |
|
|
212
|
+
| `card` | card stock | matt, #f4f1e8 |
|
|
213
|
+
| `felt` | felt pads or lining | matt, #6f6a64 |
|
|
214
|
+
| `elastic` | an elastic band or cord | matt, #262626 |
|
|
215
|
+
| `cord` | cord, string or thread | matt, #b23a3a |
|
|
216
|
+
| `ribbon` | ribbon or tape | matt, #c2485a |
|
|
217
|
+
| `wire` | wire | metal, #b87333 |
|
|
218
|
+
| `led` | an LED or a strip of them | glowing, #fff4c2 |
|
|
219
|
+
| `bulb` | a light bulb | glowing, #fff4c2 |
|
|
220
|
+
| `ball` | a marble, ball or bead | matt, #8fb8d8 |
|
|
221
|
+
| `tube` | a tube or hollow arbor | metal, #c9a227 |
|
|
222
|
+
| `lens` | a lens | matt, #d6ecf3 |
|
|
223
|
+
| `mirror` | a mirror | metal, #c8d3da |
|
|
224
|
+
| `movement` | a bought clock, music box or motor movement | matt, #3d3d3d |
|
|
225
|
+
| `white` | anything white | matt, #f7f7f4 |
|
|
213
226
|
|
|
214
227
|
```kerf
|
|
215
228
|
step("Stand the walls in the base") {
|
package/docs/versions.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Versions
|
|
2
2
|
|
|
3
|
-
KerfScript 0.
|
|
3
|
+
KerfScript 0.8.0 implements language version 0.3. The package version tracks
|
|
4
4
|
the software release; the language version tracks the syntax and behavior
|
|
5
5
|
of `.kerf` programs.
|
|
6
6
|
|
|
@@ -30,4 +30,4 @@ files used with a design. Applications that store designs should retain
|
|
|
30
30
|
that information and compare the output before upgrading the interpreter.
|
|
31
31
|
|
|
32
32
|
Pin the npm package to an exact version when your application needs a fixed
|
|
33
|
-
renderer, for example `@mylasertools/kerfscript@0.
|
|
33
|
+
renderer, for example `@mylasertools/kerfscript@0.8.0`.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mylasertools/kerfscript",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0",
|
|
4
4
|
"description": "KerfScript: a programming language and library for laser-cutting generators. Write parametric 2D parts with cut, score and engrave layers, kerf compensation and joinery, then turn settings into SVG or DXF cut files from Node.js, the browser, the command line or WebAssembly.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "AGPL-3.0-only",
|