@mylasertools/kerfscript 0.7.0 → 0.9.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 +103 -0
- package/LANGUAGE.md +201 -84
- package/README.md +2 -2
- package/dist/assembly.d.cts +2 -1
- package/dist/assembly.d.ts +2 -1
- package/dist/ast.d.cts +6 -0
- package/dist/ast.d.ts +6 -0
- package/dist/bores.d.cts +5 -0
- package/dist/bores.d.ts +5 -0
- package/dist/cli.js +2098 -285
- package/dist/customizer.d.cts +1 -0
- package/dist/customizer.d.ts +1 -0
- package/dist/evaluator.d.cts +9 -0
- package/dist/evaluator.d.ts +9 -0
- package/dist/functions.d.cts +2 -0
- package/dist/functions.d.ts +2 -0
- package/dist/geometry.d.cts +11 -0
- package/dist/geometry.d.ts +11 -0
- package/dist/halving.d.cts +8 -0
- package/dist/halving.d.ts +8 -0
- package/dist/highlight.cjs +2 -1
- package/dist/highlight.js +2 -1
- package/dist/index.cjs +474 -58
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +474 -58
- package/dist/language.cjs +462 -46
- package/dist/language.js +462 -46
- package/dist/libraries.cjs +435 -19
- package/dist/libraries.js +435 -19
- package/dist/plot.d.cts +16 -0
- package/dist/plot.d.ts +16 -0
- package/dist/signatures.cjs +189 -5
- package/dist/signatures.js +189 -5
- 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/cli.md +1 -0
- package/docs/compatibility.md +0 -8
- package/docs/customizer.md +18 -0
- package/docs/library.md +248 -5
- package/docs/parts-and-sheets.md +86 -18
- package/docs/versions.md +2 -2
- package/package.json +1 -1
package/docs/library.md
CHANGED
|
@@ -26,10 +26,13 @@ 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 |
|
|
35
|
+
| [`kerf/fit`](#fit-and-align) | Drawings scaled to a size and placed by a point of their box |
|
|
33
36
|
| [`kerf/sizes`](#sizes) | Paper, card and photo sizes |
|
|
34
37
|
| [`kerf/symbols`](#symbols) | 867 pictograms by name |
|
|
35
38
|
| [`kerf/geo`](#maps) | The world's land, for maps and globes |
|
|
@@ -444,6 +447,27 @@ mesh with it turns `angle` degrees: the other way round.
|
|
|
444
447
|
|
|
445
448
|
The turn that lines a gear's teeth up with the gear beside it along x.
|
|
446
449
|
|
|
450
|
+
### `train_for(ratio, stages = 2, pinion = [10, 20], wheel = [20, 80])`
|
|
451
|
+
|
|
452
|
+
Tooth counts for a train of `stages` gear pairs (1 to 3) whose ratio, the
|
|
453
|
+
turns in for one turn out, comes nearest `ratio`. Each pair has a pinion
|
|
454
|
+
of `pinion` teeth and a wheel of `wheel` teeth on the next axle. It
|
|
455
|
+
returns `{stages = [[driver, driven], ...], ratio, error}`, `error` being
|
|
456
|
+
how far off it is, as a fraction; of equally near trains it picks the one
|
|
457
|
+
with fewest teeth. A ratio under 1 speeds up, so the wheels drive. It is
|
|
458
|
+
built in, so it works without `use <kerf/gears>`.
|
|
459
|
+
|
|
460
|
+
```kerf
|
|
461
|
+
use <kerf/gears>
|
|
462
|
+
|
|
463
|
+
// A year for the Earth in an orrery: [[10, 73], [10, 76], [12, 79]], 0.002% off
|
|
464
|
+
t = train_for(365.25, 3);
|
|
465
|
+
s = t.stages[0];
|
|
466
|
+
part("pinion") spur_gear(s[0], 1.5);
|
|
467
|
+
part("wheel", at = [gear_distance(s[0], s[1], 1.5), 0, 0], rotate = [0, 0, gear_phase(s[1])])
|
|
468
|
+
spur_gear(s[1], 1.5);
|
|
469
|
+
```
|
|
470
|
+
|
|
447
471
|
### `rack(teeth, mod = 2, height, pressure = 20, backlash = 0.1)`
|
|
448
472
|
|
|
449
473
|
A straight rack along +x, its pitch line at y = 0. A `spur_gear()` of the
|
|
@@ -467,6 +491,165 @@ Cams: an `eccentric()` pushes a follower up and down by twice `offset`; a
|
|
|
467
491
|
`snail_cam()` lifts it slowly from `r0` to `r1` over a turn and drops it at
|
|
468
492
|
once, as a trip hammer works; `tappets()` lift a lever `n` times a turn.
|
|
469
493
|
|
|
494
|
+
### `cam(lift, base_r, follower = "knife", roller_d = 0, bore = 6, steps = 180, square = false)`
|
|
495
|
+
|
|
496
|
+
A cam whose profile comes from a lift curve: `lift` is a function of the
|
|
497
|
+
angle (0 to 360) giving how far the follower rises above the base circle
|
|
498
|
+
of radius `base_r`. The follower rides on the cam's top (+y) and moves
|
|
499
|
+
straight up and down; turned anticlockwise by `a` degrees (`rotate = [0,
|
|
500
|
+
0, a]`) the cam lifts it `lift(a)`. A `"knife"` follower rides the curve
|
|
501
|
+
itself; a `"roller"` of diameter `roller_d` rolls on a profile inside it.
|
|
502
|
+
|
|
503
|
+
```kerf
|
|
504
|
+
use <kerf/gears>
|
|
505
|
+
|
|
506
|
+
$fn = 48;
|
|
507
|
+
turn = 0; // the cam's angle
|
|
508
|
+
// A bird that pecks twice, then rests
|
|
509
|
+
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);
|
|
510
|
+
part("cam", rotate = [0, 0, turn]) cam(peck, 25, "roller", 10);
|
|
511
|
+
part("roller", at = [0, cam_follower(peck, 25, turn, 10), 0]) difference() { circle(d = 10); circle(d = 3); }
|
|
512
|
+
```
|
|
513
|
+
|
|
514
|
+
### `cam_rise(a, a0, a1, height)`
|
|
515
|
+
|
|
516
|
+
A smooth (cycloidal) rise of `height` between angles `a0` and `a1`: 0
|
|
517
|
+
before, `height` after. Add and take away rises to make dwells, rises and
|
|
518
|
+
falls.
|
|
519
|
+
|
|
520
|
+
### `cam_follower(lift, base_r, angle, roller_d = 0)`, `cam_pressure(lift, base_r, roller_d = 0)`
|
|
521
|
+
|
|
522
|
+
How high the follower's tip, or its roller's centre, stands above the
|
|
523
|
+
cam's axle at `angle`, to place it from the same curve. `cam_pressure()` is
|
|
524
|
+
the steepest pressure angle over a turn: keep it under about 30 degrees,
|
|
525
|
+
with a bigger base circle or a longer rise, or the follower jams.
|
|
526
|
+
|
|
527
|
+
### `cam_pitch(lift, base_r, roller_d = 0, steps = 180)`
|
|
528
|
+
|
|
529
|
+
The curve the follower's tip or roller centre follows, in the cam's turn.
|
|
530
|
+
|
|
531
|
+
### `geneva_wheel(slots, distance, pin_d = 6, bore = 6, clearance = 0.2)`, `geneva_lock(...)`, `geneva_crank(...)`
|
|
532
|
+
|
|
533
|
+
A Geneva drive: a driver turning all the time steps a wheel on one slot
|
|
534
|
+
each turn and locks it in between, for counters, calendars and carousels
|
|
535
|
+
that stop to show each scene. The driver's axle is at the origin and the
|
|
536
|
+
wheel's `distance` along +x. The wheel and the locking disc lie side by
|
|
537
|
+
side in one plane; the crank above the disc carries a dowel pin of `pin_d`
|
|
538
|
+
that runs in the slots. With many slots the wheel comes close to the
|
|
539
|
+
driver's axle, and `geneva_lock()` says how small the bore must be.
|
|
540
|
+
|
|
541
|
+
```kerf
|
|
542
|
+
use <kerf/gears>
|
|
543
|
+
|
|
544
|
+
$fn = 48;
|
|
545
|
+
a = 0; // the driver's turn
|
|
546
|
+
part("wheel", at = [60, 0, 0], rotate = [0, 0, geneva_turn(6, 60, a)]) geneva_wheel(6, 60, 6);
|
|
547
|
+
part("lock", at = [0, 0, 0], rotate = [0, 0, a]) geneva_lock(6, 60, 6);
|
|
548
|
+
part("crank", at = [0, 0, $thickness], rotate = [0, 0, a]) geneva_crank(6, 60, 6);
|
|
549
|
+
```
|
|
550
|
+
|
|
551
|
+
### `geneva_turn(slots, distance, angle)`
|
|
552
|
+
|
|
553
|
+
How far the wheel has turned (clockwise) when the driver has turned
|
|
554
|
+
`angle` anticlockwise from its pin pointing at the wheel: `-360 / slots`
|
|
555
|
+
for each whole turn. With `geneva_pin_radius()`, `geneva_wheel_radius()`
|
|
556
|
+
and `geneva_lock_radius()` for the sizes.
|
|
557
|
+
|
|
558
|
+
### `ratchet(teeth, r, depth, bore = 6, square = false)`, `pawl(teeth, r, depth, length, width = 8, bore = 3, at = 90, clearance = 0.2)`
|
|
559
|
+
|
|
560
|
+
A ratchet wheel that turns anticlockwise freely, and a pawl that stops it
|
|
561
|
+
turning back: for a crank that winds one way, a counter or a typewriter
|
|
562
|
+
carriage. The pawl is drawn where it works round the wheel's centre, its
|
|
563
|
+
tip on the tooth face nearest `at` degrees, so give it the wheel's
|
|
564
|
+
placement. It turns on a pin at `pawl_pivot()`, and gravity, a rubber band
|
|
565
|
+
or a spring wire keeps it down on the teeth.
|
|
566
|
+
|
|
567
|
+
```kerf
|
|
568
|
+
use <kerf/gears>
|
|
569
|
+
|
|
570
|
+
$fn = 32;
|
|
571
|
+
part("wheel", at = [0, 0, 0]) ratchet(12, 30, 5);
|
|
572
|
+
part("pawl", at = [0, 0, 0]) pawl(12, 30, 5);
|
|
573
|
+
```
|
|
574
|
+
|
|
575
|
+
### `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)`
|
|
576
|
+
|
|
577
|
+
Where the pawl's pivot pin goes round the wheel's centre, its outline, the
|
|
578
|
+
shortest it can be at a given width, the angle of the tooth face it rests
|
|
579
|
+
on, and how far it leans out from the wheel's edge to clear the teeth as
|
|
580
|
+
they pass. Left at 0, `length` is 0.8 × `r`, or the shortest that clears
|
|
581
|
+
the teeth on a small wheel; a `length` given shorter than that is an
|
|
582
|
+
error.
|
|
583
|
+
|
|
584
|
+
## Linkages
|
|
585
|
+
|
|
586
|
+
`use <kerf/linkage>`
|
|
587
|
+
|
|
588
|
+
Where the joints of a linkage are at a crank angle, so moving parts are
|
|
589
|
+
placed from the same numbers as the links' lengths: steam engine pistons,
|
|
590
|
+
typebars, walking legs, waving arms. Each takes the linkage drawn flat.
|
|
591
|
+
|
|
592
|
+
```kerf
|
|
593
|
+
use <kerf/linkage>
|
|
594
|
+
|
|
595
|
+
$fn = 32;
|
|
596
|
+
angle = 60; // the crank's turn
|
|
597
|
+
j = four_bar(80, 20, 70, 50, angle);
|
|
598
|
+
part("crank", at = [0, 0, 3], rotate = [0, 0, angle]) hull() { circle(d = 10); translate([20, 0]) circle(d = 10); }
|
|
599
|
+
part("rocker", at = [80, 0, 3], rotate = [0, 0, link_angle([80, 0], j[1])])
|
|
600
|
+
hull() { circle(d = 10); translate([50, 0]) circle(d = 10); }
|
|
601
|
+
```
|
|
602
|
+
|
|
603
|
+
### `circle_meet(a, ra, b, rb, side = 1)`
|
|
604
|
+
|
|
605
|
+
Where a circle of radius `ra` round `a` meets one of radius `rb` round `b`:
|
|
606
|
+
the point left of the line from `a` to `b`, or right of it with `side =
|
|
607
|
+
-1`. `undef` when they don't meet. Two links of those lengths from those
|
|
608
|
+
pivots join there.
|
|
609
|
+
|
|
610
|
+
### `slider_crank(r, l, angle, offset = 0)`, `slider_stroke(r, l, offset = 0)`
|
|
611
|
+
|
|
612
|
+
A crank of radius `r` round the origin drives a slider along `y = offset`
|
|
613
|
+
through a rod `l` long: `[crank pin, slider pin]` at the crank's `angle`,
|
|
614
|
+
or `undef` where the rod can't reach. `slider_stroke()` is how far the
|
|
615
|
+
slider travels.
|
|
616
|
+
|
|
617
|
+
### `four_bar(ground, crank, coupler, rocker, angle, side = 1)`, `four_bar_turns(ground, crank, coupler, rocker)`
|
|
618
|
+
|
|
619
|
+
A four-bar linkage with the crank's pivot at the origin and the rocker's at
|
|
620
|
+
`[ground, 0]`: `[crank end, rocker end]` at the crank's `angle`, or
|
|
621
|
+
`undef` where the links can't close. `four_bar_turns()` is true when the
|
|
622
|
+
crank turns all the way round (Grashof's rule).
|
|
623
|
+
|
|
624
|
+
### `link_angle(a, b)`
|
|
625
|
+
|
|
626
|
+
The angle of the line from `a` to `b`, to turn a link along it.
|
|
627
|
+
|
|
628
|
+
## Cones
|
|
629
|
+
|
|
630
|
+
`use <kerf/cones>`
|
|
631
|
+
|
|
632
|
+
Cones and cut-off cones cut flat from paper, card, veneer or thin plastic,
|
|
633
|
+
to roll up: gramophone horns, lampshades, funnels.
|
|
634
|
+
|
|
635
|
+
```kerf
|
|
636
|
+
use <kerf/cones>
|
|
637
|
+
|
|
638
|
+
$fn = 64;
|
|
639
|
+
part("shade") cone_flat(60, 25, 70, tab = 8);
|
|
640
|
+
```
|
|
641
|
+
|
|
642
|
+
### `cone_flat(r1, r2, h, tab = 0, steps = 0)`
|
|
643
|
+
|
|
644
|
+
The flat pattern of a cone of radius `r1` at one end, `r2` at the other,
|
|
645
|
+
`h` high: a ring sector with its apex at the origin, opening anticlockwise
|
|
646
|
+
from +x. `tab` adds a glue tab along the far edge with its fold scored.
|
|
647
|
+
Equal radii make a cylinder: a rectangle `2 * PI * r1` wide.
|
|
648
|
+
|
|
649
|
+
### `cone_pattern(r1, r2, h)`
|
|
650
|
+
|
|
651
|
+
The sector's `[outer radius, inner radius, angle, slant length]`.
|
|
652
|
+
|
|
470
653
|
## Lock
|
|
471
654
|
|
|
472
655
|
`use <kerf/lock>`
|
|
@@ -550,6 +733,40 @@ floor on the front, x positions (3 mm wide) or `[x, width]` pairs, and
|
|
|
550
733
|
naming both parts. The strips beside both slots must keep `$min_width`,
|
|
551
734
|
and a foot may not run into the front's slot: either stops with where.
|
|
552
735
|
|
|
736
|
+
## Fit and align
|
|
737
|
+
|
|
738
|
+
`use <kerf/fit>`
|
|
739
|
+
|
|
740
|
+
For a drawing whose size you don't know beforehand, such as an imported
|
|
741
|
+
SVG path, a silhouette or a symbol, these measure their children and
|
|
742
|
+
scale or move them, keeping every layer together. They are for drawings,
|
|
743
|
+
not parts: scaling a part would scale its joints but not its thickness.
|
|
744
|
+
|
|
745
|
+
```kerf
|
|
746
|
+
use <kerf/fit>
|
|
747
|
+
|
|
748
|
+
part("tag") {
|
|
749
|
+
rect([60, 40], r = 4);
|
|
750
|
+
engrave() translate([30, 20]) fit([44, 24], anchor = "center")
|
|
751
|
+
path("M0 0 L40 0 L50 30 L20 45 Z");
|
|
752
|
+
}
|
|
753
|
+
```
|
|
754
|
+
|
|
755
|
+
### `fit(size, mode = "contain", anchor = "bottom-left")`
|
|
756
|
+
|
|
757
|
+
The children scaled to `size` (`[w, h]`, or one number for a square).
|
|
758
|
+
`mode = "contain"` keeps their proportions and fits them inside;
|
|
759
|
+
`"stretch"` fills the size exactly. A drawing with no width or no height,
|
|
760
|
+
a straight line, is scaled by its other side. The result is placed by
|
|
761
|
+
`anchor`, as `align()` does.
|
|
762
|
+
|
|
763
|
+
### `align(anchor = "center")`, `anchor_point(anchor)`
|
|
764
|
+
|
|
765
|
+
The children moved so the point of their box that `anchor` names is at
|
|
766
|
+
the origin: `"center"`, `"left"`, `"right"`, `"top"`, `"bottom"`,
|
|
767
|
+
`"top-left"`, `"top-right"`, `"bottom-left"`, `"bottom-right"`, or
|
|
768
|
+
`[fx, fy]` as fractions of the box. `anchor_point()` gives those fractions.
|
|
769
|
+
|
|
553
770
|
## Sizes
|
|
554
771
|
|
|
555
772
|
`use <kerf/sizes>`
|
|
@@ -565,15 +782,35 @@ and boxes made to fit them.
|
|
|
565
782
|
standing; cards `"business"`, `"us business"`, `"credit"`, `"japan"`,
|
|
566
783
|
`"playing"`, `"bridge"`, `"tarot"`, `"postcard"` and `"us postcard"`, and
|
|
567
784
|
photos `"4x6"`, `"5x7"`, `"8x10"`, `"10x15"`, `"13x18"` and the instant
|
|
568
|
-
film sizes
|
|
785
|
+
film sizes `"instant mini"`, `"instant square"`, `"instant wide"` and
|
|
786
|
+
`"instant classic"`, lying down. An unknown name stops with the list of
|
|
787
|
+
known ones.
|
|
788
|
+
|
|
789
|
+
### `part_size(name)`
|
|
790
|
+
|
|
791
|
+
A bought part's sizes as a record: `body = [width, depth, height]`, and
|
|
792
|
+
for a part with a shaft its diameter `shaft`, the `shaft_length` it stands
|
|
793
|
+
out of the body and the `hole` to cut for it. `"music-18"` is an 18-note
|
|
794
|
+
wind-up music box movement (its shaft is the winding key's), and
|
|
795
|
+
`"quartz-clock"` a 56 mm quartz clock movement with the 16.5 mm shaft, for
|
|
796
|
+
dials up to `dial = 8` mm thick. `"marble-16"` and `"marble-25"` are
|
|
797
|
+
marbles. These are common retail sizes, which vary: measure yours.
|
|
798
|
+
|
|
799
|
+
```kerf
|
|
800
|
+
use <kerf/sizes>
|
|
801
|
+
|
|
802
|
+
m = part_size("quartz-clock");
|
|
803
|
+
part("dial") difference() { circle(d = 160); circle(d = m.hole); }
|
|
804
|
+
```
|
|
569
805
|
|
|
570
806
|
### `landscape(size)`, `portrait(size)`
|
|
571
807
|
|
|
572
808
|
A size turned to lie wider than tall, or to stand taller than wide.
|
|
573
809
|
|
|
574
|
-
### `lookup_size(name, table)`, `size_names(table)`
|
|
810
|
+
### `lookup_size(name, table)`, `size_names(table)`, `lookup_alias(name, aliases)`
|
|
575
811
|
|
|
576
|
-
The size of a name in a table of `[name, size]`,
|
|
812
|
+
The size of a name in a table of `[name, size]`, the names in it, and the
|
|
813
|
+
name an older name stands for in a table of `[old, new]`.
|
|
577
814
|
|
|
578
815
|
## Symbols
|
|
579
816
|
|
|
@@ -593,7 +830,7 @@ part("tag") {
|
|
|
593
830
|
}
|
|
594
831
|
```
|
|
595
832
|
|
|
596
|
-
### `symbol(name, size = 10, center = true, fill = "nonzero", box = "drawn")`
|
|
833
|
+
### `symbol(name, size = 10, center = true, fill = "nonzero", box = "drawn", solid = false, close, bridge)`
|
|
597
834
|
|
|
598
835
|
The symbol `size` mm across the longer side of what it draws, centred on
|
|
599
836
|
the origin, or with its bottom left corner there. With `box = "grid"`,
|
|
@@ -601,6 +838,12 @@ the origin, or with its bottom left corner there. With `box = "grid"`,
|
|
|
601
838
|
Material Design Icons), so icons from one set keep their sizes and places
|
|
602
839
|
relative to each other: paw prints in a trail, an icon swapped for another.
|
|
603
840
|
|
|
841
|
+
To cut a pictogram out rather than engrave it, `solid = true` gives one
|
|
842
|
+
silhouette, with gaps narrower than `2 * close` (default `size / 30`)
|
|
843
|
+
closed and holes filled, and the drawing's own detail engraved on it.
|
|
844
|
+
`bridge = w` also joins pieces too far apart to close, such as a moon
|
|
845
|
+
beside a mountain, with strips `w` wide.
|
|
846
|
+
|
|
604
847
|
### `symbol_names(category)`, `symbol_size(name, size = 10, box = "drawn")`, `symbol_source(name)`, `symbol_entry(name)`
|
|
605
848
|
|
|
606
849
|
The names of every symbol, or of one category; the `[width, height]` a
|
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.
|
|
@@ -138,6 +140,55 @@ part("back", at = [0, 55, 3], rotate = [75, 0, 0]) {
|
|
|
138
140
|
Parts that only touch cut nothing: a wall standing on a shelf without tabs
|
|
139
141
|
leaves it whole.
|
|
140
142
|
|
|
143
|
+
When tabs of two parts land in the same place in a third, as walls of two
|
|
144
|
+
storeys lining up over a floor, the check names both and where they meet,
|
|
145
|
+
so one can move its tabs along the edge.
|
|
146
|
+
|
|
147
|
+
A hook that goes in through its slot and then drops, as on a pegboard,
|
|
148
|
+
needs a slot taller than its tab: `slot_extra = [0, 6]` sweeps each slot
|
|
149
|
+
6 mm further along the receiving part's own y.
|
|
150
|
+
|
|
151
|
+
### Halving joints
|
|
152
|
+
|
|
153
|
+
Two plates that cross, as the dividers of an egg crate or the ribs and
|
|
154
|
+
rings of a lamp, each take a slot halfway through from opposite sides.
|
|
155
|
+
Give one of them `halving = ["Rib*"]` and both are cut: where they cross,
|
|
156
|
+
each gets a strip as wide as the other plate's section (wider when they
|
|
157
|
+
meet at an angle), `clearance` more, from the middle of the crossing out
|
|
158
|
+
through its own edge. The slots run the way that leaves both parts
|
|
159
|
+
soonest, so a ring is slotted from its inner rim and a rib notched from
|
|
160
|
+
its outer edge, and a slot stops at the first edge it meets, never across
|
|
161
|
+
a hole to the far side.
|
|
162
|
+
|
|
163
|
+
```kerf
|
|
164
|
+
part("Ring", at = [0, 0, 30], halving = ["Rib"])
|
|
165
|
+
difference() { circle(r = 55); circle(r = 45); }
|
|
166
|
+
part("Rib", qty = 4, at = [for (a = [0:90:270]) [-1.5 * sin(a), 1.5 * cos(a), 0]],
|
|
167
|
+
rotate = [for (a = [0:90:270]) [90, 0, a]]) translate([10, 0]) rect([50, 60]);
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
### Bores for axles and dowels
|
|
171
|
+
|
|
172
|
+
A mechanism's axles pass through several parts: the frame they turn in, and
|
|
173
|
+
the wheels, cams and cranks fixed on them. Declare the axle once as
|
|
174
|
+
hardware and let each part cut its own hole: `bores = ["Crank axle"]` cuts,
|
|
175
|
+
through this part, the section of the hardware labelled so (or of that
|
|
176
|
+
kind) wherever it passes through in the assembly. An axle at an angle cuts
|
|
177
|
+
the longer hole it needs, and a square or hexagonal rod its own shape.
|
|
178
|
+
|
|
179
|
+
The fit sets the room round the rod: `fit = "turn"` (the default, 0.3 mm on
|
|
180
|
+
the diameter) for a part that turns on it, `fit = "press"` (0.1 mm under)
|
|
181
|
+
for one held fast, or a number of millimetres. Measure your laser's kerf
|
|
182
|
+
and your dowels with `kerf/calibration`, and adjust.
|
|
183
|
+
|
|
184
|
+
```kerf
|
|
185
|
+
hardware("dowel", [30, -5, 20], [30, 40, 20], 6, label = "Crank axle");
|
|
186
|
+
part("Side", qty = 2, at = [[0, 3, 0], [0, 33, 0]], rotate = [90, 0, 0],
|
|
187
|
+
bores = ["Crank axle"]) rect([60, 40]);
|
|
188
|
+
part("Cam", at = [30, 18, 20], rotate = [90, 0, 0], bores = ["Crank axle"],
|
|
189
|
+
fit = "press") circle(d = 30);
|
|
190
|
+
```
|
|
191
|
+
|
|
141
192
|
### Bends
|
|
142
193
|
|
|
143
194
|
A living hinge bends a part, and the assembled view can show it bent.
|
|
@@ -188,28 +239,39 @@ from one point to another, a screw, a magnet, a strip of paper. `size` is
|
|
|
188
239
|
a diameter, or `[w, h]` for a flat piece. `kerf check` lists the hardware
|
|
189
240
|
with the parts, and the 3D view shows it.
|
|
190
241
|
|
|
242
|
+
`shape = "ball"` (or `sides = 0`) makes a ball of diameter `size` midway
|
|
243
|
+
between `from` and `to`, for a light bulb, a marble or a bead. A ball may
|
|
244
|
+
leave `to` out and sit at `from`: `hardware("bulb", [0, 0, 120], size = 60,
|
|
245
|
+
shape = "ball")`.
|
|
246
|
+
|
|
191
247
|
The kinds are these; a colour (`pink`, `yellow`, `red`, `green`, `blue`,
|
|
192
248
|
`orange`, `purple`, `black`, `grey`) works too, and any other kind warns
|
|
193
249
|
and shows grey. JavaScript gets the list as `HARDWARE_KINDS`.
|
|
194
250
|
|
|
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
|
-
| `
|
|
251
|
+
| Kind | What it is | Shown |
|
|
252
|
+
| ---------- | ------------------------------------------- | ---------------- |
|
|
253
|
+
| `dowel` | a wooden dowel or axle | matt, #e2c48f |
|
|
254
|
+
| `steel` | a steel rod, pin or axle | metal, #a7adb3 |
|
|
255
|
+
| `brass` | a brass rod, tube or pin | metal, #c9a227 |
|
|
256
|
+
| `screw` | a screw | metal, #9aa0a6 |
|
|
257
|
+
| `bolt` | a bolt | metal, #9aa0a6 |
|
|
258
|
+
| `nut` | a nut | metal, #9aa0a6 |
|
|
259
|
+
| `magnet` | a disc or block magnet | metal, #55585c |
|
|
260
|
+
| `paper` | a sheet or strip of paper | matt, #fbfaf6 |
|
|
261
|
+
| `card` | card stock | matt, #f4f1e8 |
|
|
262
|
+
| `felt` | felt pads or lining | matt, #6f6a64 |
|
|
263
|
+
| `elastic` | an elastic band or cord | matt, #262626 |
|
|
264
|
+
| `cord` | cord, string or thread | matt, #b23a3a |
|
|
265
|
+
| `ribbon` | ribbon or tape | matt, #c2485a |
|
|
266
|
+
| `wire` | wire | metal, #b87333 |
|
|
267
|
+
| `led` | an LED or a strip of them | glowing, #fff4c2 |
|
|
268
|
+
| `bulb` | a light bulb | glowing, #fff4c2 |
|
|
269
|
+
| `ball` | a marble, ball or bead | matt, #8fb8d8 |
|
|
270
|
+
| `tube` | a tube or hollow arbor | metal, #c9a227 |
|
|
271
|
+
| `lens` | a lens | matt, #d6ecf3 |
|
|
272
|
+
| `mirror` | a mirror | metal, #c8d3da |
|
|
273
|
+
| `movement` | a bought clock, music box or motor movement | matt, #3d3d3d |
|
|
274
|
+
| `white` | anything white | matt, #f7f7f4 |
|
|
213
275
|
|
|
214
276
|
```kerf
|
|
215
277
|
step("Stand the walls in the base") {
|
|
@@ -266,6 +328,12 @@ ones before the rows are packed: the rings of a stacked vase or globe each
|
|
|
266
328
|
inside the next, washers inside a wheel. A part goes into a hole only
|
|
267
329
|
where its outline, `$gap` all round, fits.
|
|
268
330
|
|
|
331
|
+
Copies of a curved part are packed in rows, every other one turned 180
|
|
332
|
+
degrees and slid up against the one before, `$gap` clear, when that takes
|
|
333
|
+
much less room than their boxes side by side: S-shaped ribs, crescents and
|
|
334
|
+
L brackets nest into each other, so 24 lamp ribs that took four sheets fit
|
|
335
|
+
on one. Rectangles and other parts that don't nest are packed as before.
|
|
336
|
+
|
|
269
337
|
## One file per sheet
|
|
270
338
|
|
|
271
339
|
A combined SVG stacks all sheets in one preview. For the material example
|
package/docs/versions.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Versions
|
|
2
2
|
|
|
3
|
-
KerfScript 0.
|
|
3
|
+
KerfScript 0.9.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.9.0`.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mylasertools/kerfscript",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.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",
|