@mylasertools/kerfscript 0.10.0 → 0.11.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.
- package/CHANGELOG.md +207 -0
- package/LANGUAGE.md +90 -42
- package/dist/assembly.d.cts +20 -1
- package/dist/assembly.d.ts +20 -1
- package/dist/cli.js +2265 -383
- package/dist/colors.d.cts +4 -0
- package/dist/colors.d.ts +4 -0
- package/dist/effects.d.cts +2 -2
- package/dist/effects.d.ts +2 -2
- package/dist/evaluator.d.cts +9 -1
- package/dist/evaluator.d.ts +9 -1
- package/dist/export/mesh.d.cts +16 -3
- package/dist/export/mesh.d.ts +16 -3
- package/dist/export/model.d.cts +8 -3
- package/dist/export/model.d.ts +8 -3
- package/dist/export/pages.d.cts +23 -0
- package/dist/export/pages.d.ts +23 -0
- package/dist/geometry.d.cts +20 -0
- package/dist/geometry.d.ts +20 -0
- package/dist/hardware.d.cts +2 -0
- package/dist/hardware.d.ts +2 -0
- package/dist/highlight.cjs +1 -1
- package/dist/highlight.js +1 -1
- package/dist/index.cjs +1319 -83
- package/dist/index.d.cts +4 -2
- package/dist/index.d.ts +4 -2
- package/dist/index.js +1319 -83
- package/dist/instructions.d.cts +27 -0
- package/dist/instructions.d.ts +27 -0
- package/dist/language.cjs +1288 -54
- package/dist/language.js +1288 -54
- package/dist/libraries.cjs +1269 -40
- package/dist/libraries.js +1269 -40
- 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 +5 -0
- package/dist/render.d.ts +5 -0
- package/dist/signatures.cjs +75 -4
- package/dist/signatures.js +75 -4
- package/dist/text.d.cts +23 -0
- package/dist/text.d.ts +23 -0
- package/dist/verify/types.d.cts +6 -0
- package/dist/verify/types.d.ts +6 -0
- package/docs/3d-files.md +34 -13
- package/docs/cli.md +12 -1
- package/docs/customizer.md +13 -0
- package/docs/javascript.md +6 -1
- package/docs/layers.md +24 -1
- package/docs/library.md +462 -18
- package/docs/parts-and-sheets.md +205 -28
- package/docs/verification.md +1 -1
- package/docs/versions.md +2 -2
- package/package.json +1 -1
package/dist/libraries.cjs
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/*! @mylasertools/kerfscript | (c) MyLaserTools | AGPL-3.0-only or commercial licence, see COMMERCIAL-LICENSE.md. Includes Clipper2 (BSL-1.0), opentype.js, tiny-inflate and string.prototype.codepointat (MIT), see THIRD-PARTY-NOTICES.md. */
|
|
2
|
-
"use strict";var B=Object.defineProperty;var
|
|
3
|
-
`&&(t++,s=
|
|
4
|
-
`){
|
|
5
|
-
`,
|
|
6
|
-
`,
|
|
7
|
-
`;else if(m==="t")
|
|
8
|
-
`)throw new
|
|
2
|
+
"use strict";var B=Object.defineProperty;var u1=Object.getOwnPropertyDescriptor;var p1=Object.getOwnPropertyNames;var M1=Object.prototype.hasOwnProperty;var z1=(l,c)=>{for(var a in c)B(l,a,{get:c[a],enumerable:!0})},g1=(l,c,a,n)=>{if(c&&typeof c=="object"||typeof c=="function")for(let e of p1(c))!M1.call(l,e)&&e!==a&&B(l,e,{get:()=>c[e],enumerable:!(n=u1(c,e))||n.enumerable});return l};var b1=l=>g1(B({},"__esModule",{value:!0}),l);var E1={};z1(E1,{FOLDER:()=>k,LOCK:()=>C,LibraryError:()=>R,MANIFEST:()=>M,add:()=>$1,check:()=>T1,findProject:()=>X,install:()=>f1,installedPaths:()=>C1,integrity:()=>T,libraryFile:()=>o1,pack:()=>R1,readLock:()=>J,readManifest:()=>H,remove:()=>P1,resolver:()=>A1});module.exports=b1(E1);var h1=require("node:crypto"),u=require("node:fs"),d=require("node:path"),Z=require("node:zlib");var w1=(l,c=!0)=>`line ${l.line}${c?`, column ${l.col}`:""}${l.file?` in <${l.file}>`:""}`;var A=class extends Error{constructor(a,n){super(n?`${a} (${w1(n)})`:a);this.echoes=[];this.warnings=[];this.trace=[];this.traceMore=0;this.name="KerfError",this.reason=a,n&&(this.line=n.line,this.col=n.col,this.file=n.file)}addFrame(a,n,e){let t=this.trace.find(s=>s.name===n&&s.line===e.line&&s.col===e.col&&s.file===e.file);t?t.count++:this.trace.length>=50?this.traceMore++:this.trace.push({kind:a,name:n,line:e.line,col:e.col,...e.file&&{file:e.file},count:1})}},y1=["<=",">=","==","!=","&&","||","+","-","*","/","%","^","<",">","!","?",":","=",".",",",";","(",")","[","]","{","}","#"];function e1(l,c){let a=[],n=[],e=0,t=1,s=0,i=()=>({line:t,col:e-s+1,offset:e,...c&&{file:c}}),r=o=>{for(let f=0;f<o;f++)l[e]===`
|
|
3
|
+
`&&(t++,s=e+1),e++};for(;e<l.length;){let o=l[e];if(o===" "||o===" "||o==="\r"||o===`
|
|
4
|
+
`){r(1);continue}if(o==="/"&&l[e+1]==="/"){let h=l.indexOf(`
|
|
5
|
+
`,e),m=h<0?l.length:h,g=/^[ \t]*$/.test(l.slice(l.lastIndexOf(`
|
|
6
|
+
`,e-1)+1,e));n.push({text:l.slice(e+2,m).trim(),line:t,block:!1,own:g,start:e,end:m}),e=m;continue}if(o==="/"&&l[e+1]==="*"){let h=i(),m=l.indexOf("*/",e+2);if(m<0)throw new A("Unclosed block comment",h);n.push({text:l.slice(e+2,m).trim(),line:h.line,block:!0,own:!0,start:e,end:m+2}),r(m+2-e);continue}let f=i();if(/[0-9]/.test(o)||o==="."&&/[0-9]/.test(l[e+1]??"")){let h=/^(?:\d+\.?\d*|\.\d+)(?:[eE][+-]?\d+)?(?:(?:mm|cm|m|in|ft)(?![A-Za-z0-9_]))?/.exec(l.slice(e));a.push({type:"num",value:h[0],pos:f,end:e+h[0].length}),r(h[0].length);continue}if(/[A-Za-z_$]/.test(o)){let h=/^[A-Za-z_$][A-Za-z0-9_]*/.exec(l.slice(e));a.push({type:"id",value:h[0],pos:f,end:e+h[0].length}),r(h[0].length);continue}if(o==='"'){let h="";for(r(1);e<l.length&&l[e]!=='"';){if(l[e]==="\\"){let m=l[e+1];if(m==="n")h+=`
|
|
7
|
+
`;else if(m==="t")h+=" ";else if(m==="u"){let g=l.slice(e+2,e+6);if(!/^[0-9a-fA-F]{4}$/.test(g))throw new A("Bad \\u escape",i());h+=String.fromCharCode(parseInt(g,16)),r(4)}else h+=m;r(2);continue}if(l[e]===`
|
|
8
|
+
`)throw new A("Unclosed string",f);h+=l[e],r(1)}if(e>=l.length)throw new A("Unclosed string",f);r(1),a.push({type:"str",value:h,pos:f,end:e});continue}if(o==="<"){let h=a[a.length-1];if(h&&h.type==="id"&&(h.value==="use"||h.value==="include")){let m=/^<([^<>\r\n]+)>/.exec(l.slice(e,e+4097));if(m){a.push({type:"str",value:m[1],pos:f,end:e+m[0].length}),r(m[0].length);continue}}}let p=y1.find(h=>l.startsWith(h,e));if(!p)throw new A(`Unexpected character "${o}"`,f);a.push({type:"punct",value:p,pos:f,end:e+p.length}),r(p.length)}return a.push({type:"eof",value:"",pos:i(),end:e}),{tokens:a,comments:n}}var K=new Set(["module","function","if","else","for","let","each","use","include","true","false","undef"]);function n1(l,c){let{tokens:a,comments:n}=e1(l,c),e=new D(a),t=[];for(;!e.at("eof");)t.push(...e.statement());return{program:{body:t},comments:n}}var D=class l{constructor(c){this.tokens=c;this.i=0}peek(c=0){return this.tokens[Math.min(this.i+c,this.tokens.length-1)]}at(c,a,n=0){let e=this.peek(n);return e.type===c&&(a===void 0||e.value===a)}isP(c,a=0){return this.at("punct",c,a)}isK(c,a=0){return this.at("id",c,a)}next(){return this.tokens[this.i++]}fail(c,a=this.peek()){let n=a.type==="eof"?"end of file":`"${a.value}"`;throw new A(`${c}, found ${n}`,a.pos)}expectP(c){return this.isP(c)||this.fail(`Expected "${c}"`),this.next()}separator(c){this.isP(c)||(this.isP(",")||this.fail(`Expected "," or "${c}"`),this.next())}ident(){let c=this.peek();return(c.type!=="id"||K.has(c.value))&&this.fail("Expected a name"),this.next()}last(){return this.tokens[this.i-1].end}statement(){let c=this.stmt();for(let a of c)a.end=this.last();return c}stmt(){let c=this.peek();if(this.isP(";"))return this.next(),[];if(this.isP("{")){this.next();let s=[];for(;!this.isP("}");)this.at("eof")&&this.fail('Expected "}"'),s.push(...this.statement());return this.next(),[{kind:"block",body:s,pos:c.pos}]}if(this.isK("module")){this.next();let s=this.ident(),i=this.params();return[{kind:"module",name:s.value,params:i,body:this.body(),pos:c.pos,namePos:s.pos}]}if(this.isK("function")&&this.at("id",void 0,1)){this.next();let s=this.ident(),i=this.params();this.expectP("=");let r=this.expr();return this.expectP(";"),[{kind:"function",name:s.value,params:i,body:r,pos:c.pos,namePos:s.pos}]}if(this.isK("use")||this.isK("include")){this.next();let s=this.peek();return s.type!=="str"&&this.fail("Expected a library path like <kerf/box>"),this.next(),this.isP(";")&&this.next(),[{kind:"use",path:s.value,include:c.value==="include",pos:c.pos}]}if(this.isK("for"))return this.next(),[{kind:"for",assigns:this.assigns(),body:this.body(),pos:c.pos}];if(this.isK("intersection_for")&&this.isP("(",1))return this.next(),[{kind:"for",assigns:this.assigns(),body:this.body(),pos:c.pos,intersect:!0}];if(this.isK("if")){this.next(),this.expectP("(");let s=this.expr();this.expectP(")");let i=this.body(),r=[];return this.isK("else")&&(this.next(),r=this.body()),[{kind:"if",cond:s,then:i,else:r,pos:c.pos}]}if(this.isK("let")&&this.isP("(",1))return this.next(),[{kind:"let",assigns:this.assigns(),body:this.body(),pos:c.pos}];if(c.type==="id"&&this.isP("=",1)){let s=this.ident().value;this.next();let i=this.peek().pos.offset,r=this.expr(),o=this.expectP(";").pos.offset;return[{kind:"assign",name:s,value:r,span:[i,o],pos:c.pos}]}let a=null;(this.isP("*")||this.isP("!")||this.isP("#")||this.isP("%"))&&(a=this.next().value);let n=this.peek();(n.type!=="id"||K.has(n.value))&&this.fail("Expected a statement"),this.next();let e=this.args(),t=this.body();return[{kind:"call",name:n.value,args:e,children:t,modifier:a,pos:n.pos}]}body(){if(this.isP(";"))return this.next(),[];if(this.isP("{")){this.next();let c=[];for(;!this.isP("}");)this.at("eof")&&this.fail('Expected "}"'),c.push(...this.statement());return this.next(),c}return this.statement()}params(){this.expectP("(");let c=[];for(;!this.isP(")");){let a=this.ident(),n=null;this.isP("=")&&(this.next(),n=this.expr()),c.push({name:a.value,default:n,pos:a.pos}),this.separator(")")}return this.next(),c}args(){this.expectP("(");let c=[];for(;!this.isP(")");){if(this.at("id")&&this.isP("=",1)){let a=this.next();this.next(),c.push({name:a.value,value:this.expr(),pos:a.pos})}else c.push({name:null,value:this.expr()});this.separator(")")}return this.next(),c}assigns(){this.expectP("(");let c=[];for(;!this.isP(")");){let a=this.ident();this.expectP("="),c.push({name:a.value,value:this.expr(),pos:a.pos}),this.separator(")")}return this.next(),c}expr(){let c=this.peek();if(this.isK("function")&&this.isP("(",1)){this.next();let n=this.params(),e=this.expr();return{kind:"lambda",params:n,body:e,pos:c.pos,end:this.last()}}if(this.isK("let")&&this.isP("(",1)){this.next();let n=this.assigns(),e=this.expr();return{kind:"let",assigns:n,body:e,pos:c.pos,end:this.last()}}if(this.at("id")&&(c.value==="assert"||c.value==="echo")&&this.isP("(",1)){let n=this.i;this.next();let e={kind:"call",callee:{kind:"var",name:c.value,pos:c.pos},args:this.args(),pos:c.pos};if(this.startsValue())return{kind:"chain",check:e,body:this.expr(),pos:c.pos};this.i=n}let a=this.binary(0);if(this.isP("?")){this.next();let n=this.expr();this.expectP(":");let e=this.expr();return{kind:"ternary",cond:a,then:n,else:e,pos:c.pos}}return a}static{this.LEVELS=[["||"],["&&"],["==","!="],["<","<=",">",">="],["+","-"],["*","/","%"]]}binary(c){if(c>=l.LEVELS.length)return this.unary();let a=this.binary(c+1);for(;this.at("punct")&&l.LEVELS[c].includes(this.peek().value);){let n=this.next(),e=this.binary(c+1);a={kind:"binary",op:n.value,left:a,right:e,pos:n.pos}}return a}startsValue(){let c=this.peek();return c.type==="num"||c.type==="str"||c.type==="id"?!0:this.isP("[")||this.isP("(")||this.isP("{")||this.isP("!")||this.isP("-")}unary(){if((this.isK("let")||this.isK("function"))&&this.isP("(",1))return this.expr();if(this.isP("-")||this.isP("!")||this.isP("+")){let c=this.next();return{kind:"unary",op:c.value,arg:this.unary(),pos:c.pos}}return this.power()}power(){let c=this.postfix();if(this.isP("^")){let a=this.next();return{kind:"binary",op:"^",left:c,right:this.unary(),pos:a.pos}}return c}postfix(){let c=this.primary();for(;;){let a=this.peek();if(this.isP("("))c={kind:"call",callee:c,args:this.args(),pos:c.pos};else if(this.isP("[")){this.next();let n=this.expr();this.expectP("]"),c={kind:"index",target:c,index:n,pos:a.pos}}else if(this.isP("."))this.next(),c={kind:"member",target:c,name:this.ident().value,pos:a.pos};else return c}}primary(){let c=this.peek();if(c.type==="num"){this.next();let a=/(mm|cm|m|in|ft)$/.exec(c.value);return a?{kind:"num",value:Number(c.value.slice(0,-a[1].length)),unit:a[1],pos:c.pos}:{kind:"num",value:Number(c.value),pos:c.pos}}if(c.type==="str")return this.next(),{kind:"str",value:c.value,pos:c.pos};if(c.type==="id")return c.value==="true"||c.value==="false"?(this.next(),{kind:"bool",value:c.value==="true",pos:c.pos}):c.value==="undef"?(this.next(),{kind:"undef",pos:c.pos}):(K.has(c.value)&&this.fail("Expected a value"),this.next(),{kind:"var",name:c.value,pos:c.pos});if(this.isP("(")){this.next();let a=this.expr();return this.expectP(")"),a}if(this.isP("["))return this.list();if(this.isP("{"))return this.record();this.fail("Expected a value")}record(){let c=this.expectP("{"),a=[];for(;!this.isP("}");){let n=this.ident();if(a.some(e=>e.name===n.value))throw new A(`Field ${n.value} is given twice`,n.pos);if(this.expectP("="),a.push({name:n.value,value:this.expr(),pos:n.pos}),!this.isP(","))break;this.next()}return this.expectP("}"),{kind:"record",fields:a,pos:c.pos}}list(){let c=this.expectP("[");if(this.isP("]"))return this.next(),{kind:"list",items:[],pos:c.pos};if(!this.isK("for")&&!this.isK("if")&&!this.isK("each")&&!(this.isK("let")&&this.isP("(",1))&&!(this.isP("(")&&(this.isK("for",1)||this.isK("if",1)))){let a=this.expr();if(this.isP(":")){this.next();let e=null,t=this.expr();return this.isP(":")&&(this.next(),e=t,t=this.expr()),this.expectP("]"),{kind:"range",start:a,step:e,end:t,pos:c.pos}}let n=[{kind:"item",expr:a}];return this.listRest(n,c.pos)}return this.listRest([],c.pos)}listRest(c,a){if(c.length){if(this.isP("]"))return this.next(),{kind:"list",items:c,pos:a};this.separator("]")}for(;!this.isP("]");)c.push(this.listItem()),this.separator("]");return this.next(),{kind:"list",items:c,pos:a}}listItem(){let c=this.peek();if(this.isK("for")&&this.isP("(",1)){this.next();let a=this.assigns(),n=this.listItem();return{kind:"for",assigns:a,body:n,pos:c.pos,end:this.last()}}if(this.isK("if")&&this.isP("(",1)){this.next(),this.expectP("(");let a=this.expr();this.expectP(")");let n=this.listItem(),e=null;return this.isK("else")&&(this.next(),e=this.listItem()),{kind:"if",cond:a,then:n,else:e}}if(this.isK("let")&&this.isP("(",1)){this.next();let a=this.assigns(),n=this.listItem();return{kind:"let",assigns:a,body:n,pos:c.pos,end:this.last()}}if(this.isK("each"))return this.next(),{kind:"each",expr:this.expr()};if(this.isP("(")&&(this.isK("for",1)||this.isK("if",1))){this.next();let a=this.listItem();return this.expectP(")"),a}return{kind:"item",expr:this.expr()}}};var t1={"kerf/box":`// kerf/box: finger-jointed boxes.
|
|
9
9
|
// Copyright (c) 2026 MyLaserTools. AGPL-3.0-only or MyLaserTools commercial licence.
|
|
10
10
|
|
|
11
11
|
// Box from its outer size [width, depth, height] in the current material.
|
|
@@ -194,6 +194,112 @@ module grid_dividers(size, cols = 2, rows = 2, clearance = 0.15, gap = 0.5, scoo
|
|
|
194
194
|
slotted_divider(d - 2 * gap, h, rows > 1 ? [for (i = [1:rows - 1]) d * i / rows - gap] : [],
|
|
195
195
|
"bottom", clearance, scoops ? rows : 0);
|
|
196
196
|
}
|
|
197
|
+
`,"kerf/drawers":`// kerf/drawers: a carcass of small numbered drawers in a grid, as for an
|
|
198
|
+
// advent calendar, behind a fa\xE7ade of any shape.
|
|
199
|
+
// Copyright (c) 2026 MyLaserTools. AGPL-3.0-only or MyLaserTools commercial licence.
|
|
200
|
+
//
|
|
201
|
+
// The carcass is a finger-jointed box open at the front, shelves and
|
|
202
|
+
// walls halved into each other inside it, and a drawer in each cell
|
|
203
|
+
// with its number engraved on the front and a notch or hole to pull it by.
|
|
204
|
+
// Drawn in the assembly with the carcass's front left bottom corner at the
|
|
205
|
+
// origin, the drawers facing -y.
|
|
206
|
+
|
|
207
|
+
use <kerf/dividers>
|
|
208
|
+
|
|
209
|
+
// The outer size [width, height, depth] of a carcass of \`cols\` by \`rows\`
|
|
210
|
+
// cells, each cell [w, h] inside, \`depth\` deep
|
|
211
|
+
function drawers_size(cols, rows, cell, depth) =
|
|
212
|
+
[cols * cell[0] + (cols + 1) * $thickness, rows * cell[1] + (rows + 1) * $thickness, depth];
|
|
213
|
+
|
|
214
|
+
// The number on each drawer, row by row from the top left: \`numbers\` if
|
|
215
|
+
// given, else 1 up, in an order shuffled by \`shuffle\` (a seed) when given
|
|
216
|
+
function drawers_numbers(n, numbers, shuffle) =
|
|
217
|
+
!is_undef(numbers) ? numbers
|
|
218
|
+
: is_undef(shuffle) ? [for (i = [1:n]) i]
|
|
219
|
+
: let (keys = rands(0, 1, n, shuffle))
|
|
220
|
+
[for (k = sort([for (i = [0:n - 1]) [keys[i], i + 1]])) k[1]];
|
|
221
|
+
|
|
222
|
+
// A carcass of \`cols\` by \`rows\` drawers, each cell \`cell\` = [w, h] inside
|
|
223
|
+
// and \`depth\` deep. Drawers run on the shelves \`ease\` mm clear all round,
|
|
224
|
+
// and pull out \`open\` of their depth in the assembled view. \`pull\` is
|
|
225
|
+
// "notch" (a dip in the front's top edge), "hole" (a finger hole) or
|
|
226
|
+
// "none"; numbers are engraved on the fronts unless \`numbers\` is false.
|
|
227
|
+
// Children are a fa\xE7ade, drawn on the carcass's front from its bottom left
|
|
228
|
+
// corner: the drawers' openings are cut through it and it is glued on.
|
|
229
|
+
module drawers(cols = 4, rows = 6, cell = [40, 30], depth = 60, numbers, shuffle, pull = "notch", ease = 0.8, clearance = 0.15, open = 0, font_size, label = "") {
|
|
230
|
+
t = $thickness;
|
|
231
|
+
function n(s) = label == "" ? s : str(label, " ", s);
|
|
232
|
+
size = drawers_size(cols, rows, cell, depth);
|
|
233
|
+
W = size[0];
|
|
234
|
+
H = size[1];
|
|
235
|
+
D = depth;
|
|
236
|
+
assert(cell[1] > 3 * t + 6, str("drawers(): a cell must be more than ", 3 * t + 6, " mm high for this thickness"));
|
|
237
|
+
assert(cell[0] > 4 * t + 6, str("drawers(): a cell must be more than ", 4 * t + 6, " mm wide for this thickness"));
|
|
238
|
+
assert(open >= 0 && open <= 0.6, "drawers(): open must be from 0 to 0.6, so the drawers stay in");
|
|
239
|
+
facade = $children > 0;
|
|
240
|
+
labels = numbers == false ? [] : drawers_numbers(cols * rows, numbers, shuffle);
|
|
241
|
+
step("Glue up the carcass") {
|
|
242
|
+
part(n("carcass floor"), at = [0, 0, 0]) finger_rect([W, D], ["flat", "out", "out", "out"]);
|
|
243
|
+
part(n("carcass top"), at = [0, 0, H - t]) finger_rect([W, D], ["flat", "out", "out", "out"]);
|
|
244
|
+
part(n("carcass back"), at = [0, D, 0], rotate = [90, 0, 0]) finger_rect([W, H], ["in", "out", "in", "out"]);
|
|
245
|
+
part(n("carcass side"), qty = 2, at = [[0, 0, 0], [W - t, 0, 0]], rotate = [90, 0, 90])
|
|
246
|
+
finger_rect([D, H], ["in", "in", "in", "flat"]);
|
|
247
|
+
}
|
|
248
|
+
// Shelves and walls halve into each other: each shelf slotted from the
|
|
249
|
+
// back, each wall from the front, half the depth; they stop 0.3 mm short
|
|
250
|
+
// of the carcass all round
|
|
251
|
+
g = 0.3;
|
|
252
|
+
inner = D - t - g;
|
|
253
|
+
walls = [for (i = [1:cols - 1]) i * (cell[0] + t) + t / 2];
|
|
254
|
+
shelves = [for (j = [1:rows - 1]) j * (cell[1] + t) + t / 2];
|
|
255
|
+
step("Slot the shelves and walls together and slide them in") {
|
|
256
|
+
if (rows > 1)
|
|
257
|
+
part(n("shelf"), qty = rows - 1, at = [for (z = shelves) [t + g, 0, z - t / 2]])
|
|
258
|
+
slotted_divider(W - 2 * t - 2 * g, inner, cols > 1 ? [for (x = walls) x - t - g] : [], "top", clearance);
|
|
259
|
+
if (cols > 1)
|
|
260
|
+
part(n("wall"), qty = cols - 1, at = [for (x = walls) [x + t / 2, 0, t + g]], rotate = [0, -90, 0])
|
|
261
|
+
slotted_divider(H - 2 * t - 2 * g, inner, rows > 1 ? [for (z = shelves) z - t - g] : [], "bottom", clearance);
|
|
262
|
+
}
|
|
263
|
+
if (facade)
|
|
264
|
+
step("Glue on the front")
|
|
265
|
+
part(n("front"), at = [0, 0, 0], rotate = [90, 0, 0])
|
|
266
|
+
difference() {
|
|
267
|
+
children();
|
|
268
|
+
for (i = [0:cols - 1], j = [0:rows - 1])
|
|
269
|
+
// The drawer's front, ease / 2 clear all round
|
|
270
|
+
translate([t + i * (cell[0] + t) + ease / 2, t + j * (cell[1] + t) - ease / 2])
|
|
271
|
+
rect([cell[0] - ease, cell[1]]);
|
|
272
|
+
}
|
|
273
|
+
// Each drawer's box, its front flush with the carcass or the fa\xE7ade
|
|
274
|
+
dw = cell[0] - 2 * ease;
|
|
275
|
+
dh = cell[1] - ease;
|
|
276
|
+
dd = D - t - 2;
|
|
277
|
+
y0 = (facade ? -t : 0) - open * dd;
|
|
278
|
+
step("Glue up each drawer and slide it in")
|
|
279
|
+
for (j = [0:rows - 1], i = [0:cols - 1]) {
|
|
280
|
+
k = (rows - 1 - j) * cols + i;
|
|
281
|
+
x = t + i * (cell[0] + t) + ease;
|
|
282
|
+
z = t + j * (cell[1] + t);
|
|
283
|
+
num = len(labels) ? labels[k] : undef;
|
|
284
|
+
name = str(n("drawer"), " ", is_undef(num) ? k + 1 : num);
|
|
285
|
+
part(str(name, " floor"), at = [x, y0, z]) finger_rect([dw, dd], "out");
|
|
286
|
+
part(str(name, " front"), at = [x, y0 + t, z], rotate = [90, 0, 0]) {
|
|
287
|
+
difference() {
|
|
288
|
+
finger_rect([dw, dh], ["in", "out", "flat", "out"]);
|
|
289
|
+
if (pull == "notch") translate([dw / 2, dh]) circle(d = min(18, dw / 2, (dh - t) * 0.8));
|
|
290
|
+
if (pull == "hole") translate([dw / 2, dh * 0.72]) circle(d = min(12, dh * 0.3, dw / 3));
|
|
291
|
+
}
|
|
292
|
+
if (!is_undef(num))
|
|
293
|
+
engrave() translate([dw / 2, pull == "hole" ? dh * 0.36 : dh * 0.42])
|
|
294
|
+
text(str(num), size = is_undef(font_size) ? min(dh * 0.45, dw * 0.4) : font_size,
|
|
295
|
+
fit = [dw * 0.7, pull == "hole" ? dh * 0.4 : dh * 0.5], halign = "center", valign = "center");
|
|
296
|
+
}
|
|
297
|
+
part(str(name, " back"), at = [x, y0 + dd, z], rotate = [90, 0, 0])
|
|
298
|
+
finger_rect([dw, dh], ["in", "out", "flat", "out"]);
|
|
299
|
+
part(str(name, " side"), qty = 2, at = [[x, y0, z], [x + dw - t, y0, z]], rotate = [90, 0, 90])
|
|
300
|
+
finger_rect([dd, dh], ["in", "in", "flat", "in"]);
|
|
301
|
+
}
|
|
302
|
+
}
|
|
197
303
|
`,"kerf/enclosure":`// kerf/enclosure: boxes with a screwed-on lid, for electronics and parts
|
|
198
304
|
// you need to get back to.
|
|
199
305
|
// Copyright (c) 2026 MyLaserTools. AGPL-3.0-only or MyLaserTools commercial licence.
|
|
@@ -275,6 +381,589 @@ module vents(size, slot = 3, pitch = 6) {
|
|
|
275
381
|
translate([0, ends]) circle(d = slot, $fn = 24);
|
|
276
382
|
}
|
|
277
383
|
}
|
|
384
|
+
`,"kerf/figures":`// kerf/figures: layered characters for ornaments, standees, scenes and
|
|
385
|
+
// cards: Christmas, Easter, Halloween and nativity figures and animals.
|
|
386
|
+
// Copyright (c) 2026 MyLaserTools. AGPL-3.0-only or MyLaserTools commercial licence.
|
|
387
|
+
// The figures are drawn for this library; none is copied from other art.
|
|
388
|
+
//
|
|
389
|
+
// A figure is built in layers, as layered wood art is. The "outline" is a
|
|
390
|
+
// backer of its whole silhouette, a border wider than the rest. On it lie
|
|
391
|
+
// the coloured pieces of its "clothes" (a coat, for an animal) and its
|
|
392
|
+
// "face" (skin, bellies, beaks, ears), side by side with a thin gap between
|
|
393
|
+
// them, so the backer shows as lines. On those lie the "details": eyes,
|
|
394
|
+
// noses, buttons. Each layer comes in one or more colours.
|
|
395
|
+
//
|
|
396
|
+
// Each figure is drawn 100 units tall, standing on y = 0 and centred on
|
|
397
|
+
// x = 0, as a list of pieces in painter's order: each piece of clothes or
|
|
398
|
+
// face loses what the pieces after it cover. A piece is [layer, colour,
|
|
399
|
+
// shapes], the shapes a list of:
|
|
400
|
+
// ["c", x, y, r] a circle
|
|
401
|
+
// ["e", x, y, rx, ry, angle] an ellipse, turned by angle
|
|
402
|
+
// ["k", x1, y1, x2, y2, r1, r2] a round-ended stroke from one end
|
|
403
|
+
// to the other, r1 wide at the first
|
|
404
|
+
// and r2 (r1 if left out) at the last
|
|
405
|
+
// ["r", x, y, w, h, r, angle] a rectangle round its centre, its
|
|
406
|
+
// corners rounded by r
|
|
407
|
+
// ["p", points] a polygon
|
|
408
|
+
// ["s", points] a closed smooth curve through points
|
|
409
|
+
// ["a", x, y, r, a0, a1, w] an arc w wide, as a smile
|
|
410
|
+
// ["m", shapes] the shapes and their mirror image
|
|
411
|
+
// ["h", shapes] the hull of the shapes
|
|
412
|
+
// ["-", shapes, minus] the shapes less the minus shapes
|
|
413
|
+
|
|
414
|
+
// The casts of figures
|
|
415
|
+
function figure_casts() = ["christmas", "easter", "halloween", "nativity", "animals"];
|
|
416
|
+
|
|
417
|
+
// The names of the figures, every one or those of one cast
|
|
418
|
+
function figure_names(cast) =
|
|
419
|
+
assert(is_undef(cast) || len([for (c = figure_casts()) if (c == cast) c]) > 0,
|
|
420
|
+
str("Unknown cast \\"", cast, "\\". Known: ", join(figure_casts(), ", ")))
|
|
421
|
+
[for (f = FIGURES) if (is_undef(cast) || f[1] == cast) f[0]];
|
|
422
|
+
|
|
423
|
+
// A figure's entry: [name, cast, outline colour, pieces]
|
|
424
|
+
function figure_entry(name) =
|
|
425
|
+
let (k = lower(name), hit = [for (f = FIGURES) if (f[0] == k) f])
|
|
426
|
+
len(hit) ? hit[0] : assert(false, str("Unknown figure \\"", name, "\\". Known: ", join(figure_names(), ", ")));
|
|
427
|
+
|
|
428
|
+
// The parts a figure is built of, as [layer, colour], bottom up: the
|
|
429
|
+
// outline, then each colour of clothes and face, then of details
|
|
430
|
+
function figure_layers(name) =
|
|
431
|
+
let (
|
|
432
|
+
e = figure_entry(name),
|
|
433
|
+
pieces = e[3],
|
|
434
|
+
middle = figure_unique([for (p = pieces) if (p[0] != "details") [p[0], p[1]]]),
|
|
435
|
+
top = figure_unique([for (p = pieces) if (p[0] == "details") [p[0], p[1]]])
|
|
436
|
+
)
|
|
437
|
+
concat([["outline", e[2]]], middle, top);
|
|
438
|
+
|
|
439
|
+
// The list without repeats, in the order first seen
|
|
440
|
+
function figure_unique(list) =
|
|
441
|
+
[for (i = [0:len(list) - 1]) if (len([for (j = [0:i - 1]) if (i > 0 && list[j] == list[i]) 1]) == 0) list[i]];
|
|
442
|
+
|
|
443
|
+
// The shapes of a figure's piece list, in its own units
|
|
444
|
+
module figure_shapes(shapes) {
|
|
445
|
+
for (q = shapes) {
|
|
446
|
+
if (q[0] == "c") translate([q[1], q[2]]) circle(r = q[3]);
|
|
447
|
+
else if (q[0] == "e") translate([q[1], q[2]]) rotate(is_undef(q[5]) ? 0 : q[5]) ellipse(r = [q[3], q[4]]);
|
|
448
|
+
else if (q[0] == "k")
|
|
449
|
+
hull() {
|
|
450
|
+
translate([q[1], q[2]]) circle(r = q[5]);
|
|
451
|
+
translate([q[3], q[4]]) circle(r = is_undef(q[6]) ? q[5] : q[6]);
|
|
452
|
+
}
|
|
453
|
+
else if (q[0] == "r")
|
|
454
|
+
translate([q[1], q[2]]) rotate(is_undef(q[6]) ? 0 : q[6])
|
|
455
|
+
rect([q[3], q[4]], center = true, r = min(is_undef(q[5]) ? 0 : q[5], q[3] / 2 - 0.01, q[4] / 2 - 0.01));
|
|
456
|
+
else if (q[0] == "p") polygon(q[1]);
|
|
457
|
+
else if (q[0] == "s") polygon(spline_points(q[1], closed = true));
|
|
458
|
+
else if (q[0] == "a")
|
|
459
|
+
stroke(q[6]) polyline([for (i = [0:16]) let (a = q[4] + (q[5] - q[4]) * i / 16) [q[1] + q[3] * cos(a), q[2] + q[3] * sin(a)]]);
|
|
460
|
+
else if (q[0] == "m") {
|
|
461
|
+
figure_shapes(q[1]);
|
|
462
|
+
mirror([1, 0]) figure_shapes(q[1]);
|
|
463
|
+
} else if (q[0] == "h") hull() figure_shapes(q[1]);
|
|
464
|
+
else if (q[0] == "-")
|
|
465
|
+
difference() {
|
|
466
|
+
figure_shapes(q[1]);
|
|
467
|
+
figure_shapes(q[2]);
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
// One layer of a figure: "outline", "clothes", "face" or "details", in
|
|
473
|
+
// every colour or only \`color\`. The outline is \`height\` mm tall, standing
|
|
474
|
+
// on y = 0 and centred on x = 0, \`border\` mm wider all round than the
|
|
475
|
+
// pieces on it; pieces of clothes and face keep \`gap\` mm apart, as do
|
|
476
|
+
// details, and lose any sliver narrower than \`min_width\` mm.
|
|
477
|
+
module figure_layer(name, layer, height = 100, color, border = 2, gap = 0.6, min_width = 1.6) {
|
|
478
|
+
e = figure_entry(name);
|
|
479
|
+
pieces = e[3];
|
|
480
|
+
n = len(pieces);
|
|
481
|
+
middle = [for (k = [0:n - 1]) if (pieces[k][0] != "details") k];
|
|
482
|
+
assert(len([for (l = ["outline", "clothes", "face", "details"]) if (l == layer) l]) > 0,
|
|
483
|
+
str("figure_layer(): layer must be \\"outline\\", \\"clothes\\", \\"face\\" or \\"details\\", got ", layer));
|
|
484
|
+
assert(is_num(height) && height > 2 * border + 1, "figure_layer(): height must be more than twice the border");
|
|
485
|
+
measure() {
|
|
486
|
+
for (k = [0:n - 1]) figure_shapes(pieces[k][2]);
|
|
487
|
+
let (b = $bounds, s = (height - 2 * border) / (b[3] - b[1]), at = [-(b[0] + b[2]) / 2, -b[1]]) {
|
|
488
|
+
if (layer == "outline") {
|
|
489
|
+
offset(r = border) translate([0, border]) scale(s) translate(at)
|
|
490
|
+
for (k = [0:n - 1]) figure_shapes(pieces[k][2]);
|
|
491
|
+
} else {
|
|
492
|
+
// Each piece loses what the pieces after it on its layer cover, a
|
|
493
|
+
// gap wider, and anything narrower than min_width; details stay on
|
|
494
|
+
// the clothes and face
|
|
495
|
+
same = [for (k = [0:n - 1]) if ((pieces[k][0] == "details") == (layer == "details")) k];
|
|
496
|
+
for (k = same)
|
|
497
|
+
if ((layer == "details" || pieces[k][0] == layer) && (is_undef(color) || pieces[k][1] == color))
|
|
498
|
+
offset(r = min_width / 2) offset(r = -min_width / 2)
|
|
499
|
+
difference() {
|
|
500
|
+
intersection() {
|
|
501
|
+
translate([0, border]) scale(s) translate(at) figure_shapes(pieces[k][2]);
|
|
502
|
+
if (layer == "details")
|
|
503
|
+
offset(delta = -gap) translate([0, border]) scale(s) translate(at)
|
|
504
|
+
for (j = middle) figure_shapes(pieces[j][2]);
|
|
505
|
+
}
|
|
506
|
+
offset(delta = gap) translate([0, border]) scale(s) translate(at)
|
|
507
|
+
for (j = same) if (j > k) figure_shapes(pieces[j][2]);
|
|
508
|
+
}
|
|
509
|
+
}
|
|
510
|
+
}
|
|
511
|
+
}
|
|
512
|
+
}
|
|
513
|
+
|
|
514
|
+
// A figure cut from one sheet, \`height\` mm tall: its outline cut, the
|
|
515
|
+
// lines between its coloured pieces scored and its details engraved
|
|
516
|
+
module figure(name, height = 100, border = 2, gap = 0.6) {
|
|
517
|
+
figure_layer(name, "outline", height, border = border, gap = gap);
|
|
518
|
+
score() for (l = ["clothes", "face"]) outline() figure_layer(name, l, height, border = border, gap = gap);
|
|
519
|
+
engrave() figure_layer(name, "details", height, border = border, gap = gap);
|
|
520
|
+
}
|
|
521
|
+
|
|
522
|
+
// A figure as layered parts, \`height\` mm tall: the outline at \`at\`, turned
|
|
523
|
+
// by \`rotate\`, its clothes and face glued on it and its details on those,
|
|
524
|
+
// one part for each colour of each layer, painted that colour. The parts
|
|
525
|
+
// are named after \`label\` (the figure's name), as "bunny face pink".
|
|
526
|
+
module figure_parts(name, height = 100, at = [0, 0, 0], rotate = [0, 0, 0], label, border = 2, gap = 0.6, qty = 1) {
|
|
527
|
+
base = is_undef(label) ? lower(name) : label;
|
|
528
|
+
layers = figure_layers(name);
|
|
529
|
+
middle = [for (l = layers) if (l[0] == "clothes" || l[0] == "face") l];
|
|
530
|
+
part(str(base, " outline"), qty = qty, at = at, rotate = rotate, paint = layers[0][1])
|
|
531
|
+
figure_layer(name, "outline", height, border = border, gap = gap);
|
|
532
|
+
// A part too small to cut at this height is left out
|
|
533
|
+
for (l = middle)
|
|
534
|
+
measure() {
|
|
535
|
+
figure_layer(name, l[0], height, l[1], border = border, gap = gap);
|
|
536
|
+
if (!is_undef($bounds))
|
|
537
|
+
part(str(base, " ", l[0], " ", l[1]), qty = qty, glue = str(base, " outline"), paint = l[1], pieces = "any")
|
|
538
|
+
figure_layer(name, l[0], height, l[1], border = border, gap = gap);
|
|
539
|
+
}
|
|
540
|
+
figure_details(name, height, base, qty, border, gap);
|
|
541
|
+
}
|
|
542
|
+
|
|
543
|
+
// A figure's details as painted parts named after \`base\`, glued on the
|
|
544
|
+
// first of its clothes and face parts, from the \`k\`-th, that is big enough
|
|
545
|
+
// to cut at this height
|
|
546
|
+
module figure_details(name, height, base, qty = 1, border = 2, gap = 0.6, k = 0) {
|
|
547
|
+
layers = figure_layers(name);
|
|
548
|
+
middle = [for (l = layers) if (l[0] == "clothes" || l[0] == "face") l];
|
|
549
|
+
if (k < len(middle))
|
|
550
|
+
measure() {
|
|
551
|
+
figure_layer(name, middle[k][0], height, middle[k][1], border = border, gap = gap);
|
|
552
|
+
if (is_undef($bounds)) figure_details(name, height, base, qty, border, gap, k + 1);
|
|
553
|
+
else
|
|
554
|
+
for (l = layers)
|
|
555
|
+
if (l[0] == "details")
|
|
556
|
+
measure() {
|
|
557
|
+
figure_layer(name, "details", height, l[1], border = border, gap = gap);
|
|
558
|
+
if (!is_undef($bounds))
|
|
559
|
+
part(str(base, " details ", l[1]), qty = qty, glue = str(base, " ", middle[k][0], " ", middle[k][1]), paint = l[1], pieces = "any")
|
|
560
|
+
figure_layer(name, "details", height, l[1], border = border, gap = gap);
|
|
561
|
+
}
|
|
562
|
+
}
|
|
563
|
+
}
|
|
564
|
+
|
|
565
|
+
// The figures: [name, cast, outline colour, pieces], each piece [layer,
|
|
566
|
+
// colour, shapes] in painter's order
|
|
567
|
+
FIGURES = [
|
|
568
|
+
// Christmas
|
|
569
|
+
["santa", "christmas", "dark brown", [
|
|
570
|
+
["clothes", "black", [["m", [["r", -8, 4, 12, 8, 3, 0]]]]],
|
|
571
|
+
["clothes", "red", [
|
|
572
|
+
["h", [["c", -16, 13, 4], ["c", 16, 13, 4], ["c", -12, 42, 8], ["c", 12, 42, 8]]],
|
|
573
|
+
["m", [["k", -15, 44, -24, 26, 6, 5]]]
|
|
574
|
+
]],
|
|
575
|
+
["face", "white", [["r", 0, 12, 40, 6, 3, 0], ["r", 0, 32, 6, 30, 2, 0]]],
|
|
576
|
+
["clothes", "black", [["r", 0, 31, 36, 5, 0, 0], ["m", [["c", -25, 21, 4.5]]]]],
|
|
577
|
+
["face", "white", [["m", [["r", -24, 26.5, 11, 4.5, 2, -20]]]]],
|
|
578
|
+
["face", "skin", [["e", 0, 63, 11, 9.5, 0]]],
|
|
579
|
+
["face", "white", [["s", [[-13, 61], [-11, 52], [-6, 46], [0, 44], [6, 46], [11, 52], [13, 61], [0, 58]]]]],
|
|
580
|
+
["clothes", "red", [["h", [["c", -12, 74, 2.5], ["c", 12, 74, 2.5], ["c", 16, 92, 2]]]]],
|
|
581
|
+
["face", "white", [["r", 0, 72, 30, 6.5, 3.2, 0], ["c", 17, 93, 5]]],
|
|
582
|
+
["details", "black", [["m", [["c", -4.5, 65.5, 1.8]]]]],
|
|
583
|
+
["details", "white", [["m", [["e", -4.2, 58.5, 4.5, 2.3, 12]]]]],
|
|
584
|
+
["details", "pink", [["c", 0, 61.5, 2.3]]],
|
|
585
|
+
["details", "yellow", [["r", 0, 31, 7, 6, 1, 0]]]
|
|
586
|
+
]],
|
|
587
|
+
["elf", "christmas", "dark brown", [
|
|
588
|
+
["clothes", "red", [["m", [["r", -6, 10, 6, 16, 2, 0]]]]],
|
|
589
|
+
["clothes", "dark brown", [["m", [["k", -9, 3.5, -15, 6, 3.5, 2]]]]],
|
|
590
|
+
["clothes", "green", [
|
|
591
|
+
["h", [["c", -10, 42, 6], ["c", 10, 42, 6], ["c", -14, 22, 5], ["c", 14, 22, 5]]],
|
|
592
|
+
["p", [[-19, 22], [-16, 13], [-11, 19], [-6, 13], [-1, 19], [4, 13], [9, 19], [14, 13], [19, 22]]],
|
|
593
|
+
["m", [["k", -14, 44, -21, 28, 5, 4.5]]]
|
|
594
|
+
]],
|
|
595
|
+
["clothes", "black", [["r", 0, 29, 32, 4.5, 0, 0]]],
|
|
596
|
+
["face", "skin", [["m", [["c", -22, 25, 4.2]]]]],
|
|
597
|
+
["face", "skin", [["m", [["p", [[-9, 64], [-20, 70], [-9, 57]]]]], ["c", 0, 61, 11]]],
|
|
598
|
+
["clothes", "green", [["h", [["c", -11, 70, 2.2], ["c", 11, 70, 2.2], ["c", 21, 89, 1.8]]]]],
|
|
599
|
+
["clothes", "red", [["r", 0, 69, 27, 5, 2.5, 0], ["c", 22, 90, 3.5]]],
|
|
600
|
+
["details", "black", [["m", [["c", -4.5, 62, 1.8]]]]],
|
|
601
|
+
["details", "pink", [["m", [["e", -7, 57.5, 2.6, 1.8, 0]]], ["c", 0, 59, 1.8]]],
|
|
602
|
+
["details", "yellow", [["r", 0, 29, 6, 5.5, 1, 0]]]
|
|
603
|
+
]],
|
|
604
|
+
["gnome", "christmas", "dark brown", [
|
|
605
|
+
["clothes", "dark brown", [["m", [["e", -8, 4, 8, 4, 0]]]]],
|
|
606
|
+
["clothes", "blue", [["h", [["c", -13, 9, 4], ["c", 13, 9, 4], ["c", -10, 32, 6], ["c", 10, 32, 6]]]]],
|
|
607
|
+
["face", "white", [["s", [[-15, 48], [15, 48], [13, 32], [7, 18], [0, 12], [-7, 18], [-13, 32]]]]],
|
|
608
|
+
["clothes", "red", [["p", [[-18, 46], [18, 46], [8, 82], [1, 97], [-3, 86]]]]],
|
|
609
|
+
["face", "skin", [["e", 0, 45.5, 6, 5, 0]]],
|
|
610
|
+
["details", "white", [["c", -6, 60, 1.8], ["c", 4, 68, 1.8], ["c", -2, 77, 1.8], ["c", 8, 55, 1.8]]]
|
|
611
|
+
]],
|
|
612
|
+
["angel", "christmas", "dark brown", [
|
|
613
|
+
["clothes", "white", [["m", [["e", -18, 50, 12, 20, -25]]]]],
|
|
614
|
+
["clothes", "light blue", [
|
|
615
|
+
["h", [["c", -6, 46, 6], ["c", 6, 46, 6], ["c", -19, 4, 3], ["c", 19, 4, 3]]]
|
|
616
|
+
]],
|
|
617
|
+
["clothes", "light blue", [["m", [["k", -8, 47, -4, 33, 4.5, 4]]]]],
|
|
618
|
+
["face", "skin", [["c", 0, 31, 4.2]]],
|
|
619
|
+
["face", "yellow", [["c", 0, 64, 12.5], ["m", [["e", -9, 56, 4.5, 8, 0]]]]],
|
|
620
|
+
["face", "skin", [["e", 0, 61, 8.5, 9, 0]]],
|
|
621
|
+
["clothes", "gold", [["-", [["e", 0, 79, 11, 3.8, 0]], [["e", 0, 79, 7, 1.6, 0]]]]],
|
|
622
|
+
["details", "black", [["m", [["c", -3.5, 62, 1.6]]]]],
|
|
623
|
+
["details", "pink", [["m", [["e", -6, 58, 2.2, 1.5, 0]]]]],
|
|
624
|
+
["details", "white", [["c", 0, 24, 2], ["c", -6, 14, 2], ["c", 6, 14, 2]]]
|
|
625
|
+
]],
|
|
626
|
+
["reindeer", "christmas", "dark brown", [
|
|
627
|
+
["clothes", "tan", [["m", [["k", -7, 70, -14, 93, 2.6, 2], ["k", -11, 82, -21, 86, 2.2, 1.8], ["k", -13, 89, -7, 96, 2, 1.6]]]]],
|
|
628
|
+
["clothes", "dark brown", [["m", [["r", -8, 4, 8, 8, 2.5, 0]]]]],
|
|
629
|
+
["clothes", "light brown", [
|
|
630
|
+
["e", 0, 24, 15, 18, 0],
|
|
631
|
+
["m", [["r", -8, 9, 7, 12, 2.5, 0]]],
|
|
632
|
+
["m", [["e", -16, 67, 7.5, 3.5, 25]]],
|
|
633
|
+
["e", 0, 58, 13, 15, 0]
|
|
634
|
+
]],
|
|
635
|
+
["face", "pink", [["m", [["e", -16, 67, 4.5, 1.8, 25]]]]],
|
|
636
|
+
["face", "beige", [["e", 0, 21, 9, 11, 0], ["e", 0, 49, 9, 7, 0]]],
|
|
637
|
+
["clothes", "green", [["r", 0, 40, 26, 6, 3, 0], ["r", 9, 33, 6, 12, 2, -10]]],
|
|
638
|
+
["details", "black", [["m", [["c", -5, 59, 2]]]]],
|
|
639
|
+
["details", "red", [["c", 0, 51.5, 4]]]
|
|
640
|
+
]],
|
|
641
|
+
["gingerbread", "christmas", "dark brown", [
|
|
642
|
+
["clothes", "light brown", [
|
|
643
|
+
["c", 0, 75, 15],
|
|
644
|
+
["r", 0, 39, 26, 36, 6, 0],
|
|
645
|
+
["k", -24, 52, 24, 52, 7, 7],
|
|
646
|
+
["m", [["k", -8, 30, -15, 7, 7, 7]]]
|
|
647
|
+
]],
|
|
648
|
+
["details", "white", [
|
|
649
|
+
["m", [["a", -27, 52, 5, -60, 60, 2], ["a", -15, 8, 5, 25, 155, 2]]],
|
|
650
|
+
["a", 0, 73, 6, 210, 330, 2]
|
|
651
|
+
]],
|
|
652
|
+
["details", "black", [["m", [["c", -5, 78, 2]]]]],
|
|
653
|
+
["details", "red", [["c", 0, 49, 2.8], ["c", 0, 31, 2.8]]],
|
|
654
|
+
["details", "green", [["c", 0, 40, 2.8]]],
|
|
655
|
+
["details", "pink", [["m", [["c", -9, 72, 2]]]]]
|
|
656
|
+
]],
|
|
657
|
+
["snowman", "christmas", "dark brown", [
|
|
658
|
+
["clothes", "dark brown", [["m", [["k", -13, 54, -29, 65, 1.9, 1.4], ["k", -24, 62, -27, 69, 1.4, 1.2]]]]],
|
|
659
|
+
["clothes", "white", [["c", 0, 21, 21], ["c", 0, 51, 15], ["c", 0, 76, 11]]],
|
|
660
|
+
["clothes", "red", [["r", 0, 66, 25, 6, 3, 0], ["r", 8, 57, 6, 14, 2, -10]]],
|
|
661
|
+
["clothes", "black", [["r", 0, 85, 26, 3.5, 1.5, 0], ["r", 0, 93, 16, 14, 1.5, 0]]],
|
|
662
|
+
["clothes", "red", [["r", 0, 88.5, 16, 3, 0, 0]]],
|
|
663
|
+
["details", "black", [["m", [["c", -4, 78, 1.8]]], ["c", 0, 53, 2], ["c", 0, 45, 2], ["c", 0, 26, 2.4]]],
|
|
664
|
+
["details", "orange", [["p", [[0, 76], [0, 72.5], [11, 73.5]]]]],
|
|
665
|
+
["details", "pink", [["m", [["c", -7, 73.5, 1.6]]]]]
|
|
666
|
+
]],
|
|
667
|
+
|
|
668
|
+
// Easter
|
|
669
|
+
["bunny", "easter", "dark grey", [
|
|
670
|
+
["clothes", "light grey", [
|
|
671
|
+
["m", [["k", -9, 64, -15, 93, 6.5, 5.5]]],
|
|
672
|
+
["m", [["e", -11, 5, 10, 5.5, 0]]],
|
|
673
|
+
["e", 0, 26, 19, 21, 0],
|
|
674
|
+
["e", 0, 53, 21, 17, 0]
|
|
675
|
+
]],
|
|
676
|
+
["face", "pink", [["m", [["k", -10, 71, -14.5, 90, 3, 2.5]]]]],
|
|
677
|
+
["face", "white", [["m", [["e", -5, 46, 7, 5.5, 0]]], ["e", 0, 24, 12.5, 13, 0]]],
|
|
678
|
+
["face", "light blue", [["e", 0, 21, 9, 11.5, 0]]],
|
|
679
|
+
["clothes", "light grey", [["m", [["e", -10, 25, 5, 8, -40]]]]],
|
|
680
|
+
["details", "black", [["m", [["c", -8, 56, 2.6]]]]],
|
|
681
|
+
["details", "pink", [["e", 0, 50.5, 3, 2.2, 0]]],
|
|
682
|
+
["details", "yellow", [["m", [["c", -4.5, 15, 1.5]]], ["c", 0, 12.5, 1.5]]]
|
|
683
|
+
]],
|
|
684
|
+
["chick", "easter", "dark brown", [
|
|
685
|
+
["clothes", "yellow", [
|
|
686
|
+
["e", 0, 36, 25, 24, 0],
|
|
687
|
+
["c", 0, 62, 18],
|
|
688
|
+
["k", 0, 78, -4, 89, 3, 1.8],
|
|
689
|
+
["k", 0, 78, 4.5, 87, 3, 1.6]
|
|
690
|
+
]],
|
|
691
|
+
["clothes", "yellow", [["m", [["e", -22, 40, 6.5, 11, 30]]]]],
|
|
692
|
+
["face", "orange", [["h", [["c", -4.5, 59.5, 1.6], ["c", 4.5, 59.5, 1.6], ["c", 0, 53, 1.6]]]]],
|
|
693
|
+
["face", "white", [["p", concat(
|
|
694
|
+
[for (a = [180:10:360]) [27 * cos(a), 27 + 26 * sin(a)]],
|
|
695
|
+
[for (i = [0:8]) [27 - i * 6.75, i % 2 == 0 ? 27 : 34]]
|
|
696
|
+
)]]],
|
|
697
|
+
["details", "black", [["m", [["c", -7, 66, 2.6]]]]],
|
|
698
|
+
["details", "pink", [["m", [["e", -12.5, 58.5, 3.2, 2.2, 0]]]]]
|
|
699
|
+
]],
|
|
700
|
+
["lamb", "easter", "dark grey", [
|
|
701
|
+
["face", "dark grey", [["m", [["r", -10, 9, 6.5, 18, 2.5, 0]]]]],
|
|
702
|
+
["clothes", "cream", [
|
|
703
|
+
["e", 0, 33, 23, 16, 0],
|
|
704
|
+
for (a = [0:30:330]) ["c", 21 * cos(a), 33 + 15 * sin(a), 6.5]
|
|
705
|
+
]],
|
|
706
|
+
["face", "skin", [["m", [["e", -15.5, 61, 8, 3.8, -25]]], ["e", 0, 57, 11.5, 13.5, 0]]],
|
|
707
|
+
["clothes", "cream", [["c", -6.5, 70, 5.5], ["c", 0, 73, 5.5], ["c", 6.5, 70, 5.5]]],
|
|
708
|
+
["details", "black", [["m", [["c", -5, 58, 2.3]]]]],
|
|
709
|
+
["details", "pink", [["e", 0, 50, 3, 2, 0], ["m", [["c", -8, 52.5, 1.8]]]]]
|
|
710
|
+
]],
|
|
711
|
+
|
|
712
|
+
// Halloween
|
|
713
|
+
["ghost", "halloween", "dark grey", [
|
|
714
|
+
["clothes", "white", [
|
|
715
|
+
["h", [["c", 0, 68, 22], ["r", 0, 28, 44, 8, 0, 0]]],
|
|
716
|
+
for (x = [-16.5, -5.5, 5.5, 16.5]) ["c", x, 24, 5.5],
|
|
717
|
+
["m", [["e", -23, 46, 8, 4, 35]]]
|
|
718
|
+
]],
|
|
719
|
+
["details", "black", [["m", [["e", -7.5, 64, 3, 4.5, 0]]], ["e", 0, 51, 4, 5.5, 0]]],
|
|
720
|
+
["details", "pink", [["m", [["e", -13, 57, 3, 2, 0]]]]]
|
|
721
|
+
]],
|
|
722
|
+
["witch", "halloween", "dark brown", [
|
|
723
|
+
["clothes", "black", [["m", [["e", -6, 4, 6, 3.5, 0]]]]],
|
|
724
|
+
["clothes", "purple", [["h", [["c", -6, 44, 6], ["c", 6, 44, 6], ["c", -18, 8, 3], ["c", 18, 8, 3]]]]],
|
|
725
|
+
["clothes", "purple", [["m", [["k", -9, 46, -21, 30, 5, 4]]]]],
|
|
726
|
+
["face", "light green", [["m", [["c", -22, 27, 3.8]]]]],
|
|
727
|
+
["face", "light green", [["c", 0, 62, 10]]],
|
|
728
|
+
["face", "orange", [["m", [["e", -10.5, 56, 4, 10, 10]]]]],
|
|
729
|
+
["clothes", "black", [["r", 0, 71, 38, 4.5, 2.2, -4], ["h", [["c", -10, 72, 2], ["c", 10, 72, 2], ["c", 9, 97, 1.5]]]]],
|
|
730
|
+
["clothes", "purple", [["r", 0, 75.5, 21, 4.5, 0, 0]]],
|
|
731
|
+
["details", "black", [["m", [["c", -4, 63, 1.8]]]]],
|
|
732
|
+
["details", "pink", [["m", [["e", -6.5, 58.5, 2.2, 1.5, 0]]]]],
|
|
733
|
+
["details", "yellow", [["r", 0, 75.5, 5, 4, 0.8, 0]]]
|
|
734
|
+
]],
|
|
735
|
+
["pumpkin", "halloween", "dark brown", [
|
|
736
|
+
["clothes", "green", [["k", 0, 66, 4, 82, 4, 2.8]]],
|
|
737
|
+
["clothes", "orange", [["m", [["e", -15, 34, 17, 32, 0]]]]],
|
|
738
|
+
["clothes", "orange", [["e", 0, 34, 15, 34, 0]]],
|
|
739
|
+
["details", "black", [
|
|
740
|
+
["m", [["p", [[-14, 40], [-4, 40], [-9, 49]]]]],
|
|
741
|
+
["p", [[-3, 33], [3, 33], [0, 37]]],
|
|
742
|
+
["p", [[-17, 25], [-12, 22], [-8, 25], [-4, 20], [0, 24], [4, 20], [8, 25], [12, 22], [17, 25], [12, 15], [-12, 15]]]
|
|
743
|
+
]]
|
|
744
|
+
]],
|
|
745
|
+
["bat", "halloween", "dark grey", [
|
|
746
|
+
["clothes", "black", [
|
|
747
|
+
["m", [["p", [[-4, 52], [-15, 64], [-26, 64], [-36, 56], [-31, 52], [-28, 45], [-22, 48], [-18, 41], [-12, 46], [-6, 41]]]]],
|
|
748
|
+
["e", 0, 48, 9.5, 14, 0],
|
|
749
|
+
["c", 0, 63, 9.5],
|
|
750
|
+
["m", [["p", [[-8.5, 66], [-8, 77], [-2, 70]]]]]
|
|
751
|
+
]],
|
|
752
|
+
["face", "purple", [["e", 0, 45, 5.5, 8.5, 0]]],
|
|
753
|
+
["details", "yellow", [["m", [["c", -3.8, 64, 2.2]]]]],
|
|
754
|
+
["details", "pink", [["m", [["c", -6.5, 59.5, 1.4]]]]]
|
|
755
|
+
]],
|
|
756
|
+
["skeleton", "halloween", "dark grey", [
|
|
757
|
+
["clothes", "black", [
|
|
758
|
+
["m", [["r", -6, 10, 8, 20, 3, 0]]],
|
|
759
|
+
["h", [["c", -9, 45, 5], ["c", 9, 45, 5], ["c", -10, 21, 5], ["c", 10, 21, 5]]],
|
|
760
|
+
["m", [["k", -13, 47, -19, 28, 4.5, 4]]]
|
|
761
|
+
]],
|
|
762
|
+
["face", "white", [
|
|
763
|
+
["r", 0, 32, 3, 24, 1.5, 0],
|
|
764
|
+
["m", [["k", -1, 44, -8.5, 42, 1.4], ["k", -1, 39, -8.5, 37, 1.4], ["k", -1, 34, -7.5, 32, 1.4]]],
|
|
765
|
+
["e", 0, 20, 7, 3.2, 0],
|
|
766
|
+
["m", [["r", -6, 10, 2.8, 15, 1.4, 0], ["k", -14, 45, -18.5, 30, 1.4]]]
|
|
767
|
+
]],
|
|
768
|
+
["face", "white", [["c", 0, 66, 13], ["r", 0, 54, 14, 8, 3, 0]]],
|
|
769
|
+
["details", "black", [["m", [["c", -5, 66, 3.6]]], ["p", [[-1.6, 59.5], [1.6, 59.5], [0, 62.5]]]]]
|
|
770
|
+
]],
|
|
771
|
+
|
|
772
|
+
// Nativity
|
|
773
|
+
["mary", "nativity", "dark brown", [
|
|
774
|
+
["clothes", "blue", [["h", [["c", 0, 64, 13.5], ["c", -18, 4, 3], ["c", 18, 4, 3]]]]],
|
|
775
|
+
["clothes", "white", [["h", [["c", 0, 46, 6], ["c", -9, 4, 3], ["c", 9, 4, 3]]]]],
|
|
776
|
+
["face", "dark brown", [["e", 0, 63, 10, 11.5, 0]]],
|
|
777
|
+
["face", "skin", [["e", 0, 61, 7.5, 8.5, 0], ["e", 0, 36, 5, 4, 0]]],
|
|
778
|
+
["details", "black", [["m", [["c", -3, 62, 1.4]]]]],
|
|
779
|
+
["details", "pink", [["m", [["e", -5, 58, 1.8, 1.2, 0]]]]]
|
|
780
|
+
]],
|
|
781
|
+
["joseph", "nativity", "dark brown", [
|
|
782
|
+
["clothes", "light brown", [["r", 22, 42, 3.2, 84, 1.6, 0]]],
|
|
783
|
+
["clothes", "brown", [["h", [["c", -9, 46, 6], ["c", 9, 46, 6], ["c", -17, 4, 3], ["c", 17, 4, 3]]]]],
|
|
784
|
+
["clothes", "green", [["p", [[-15, 50], [-6, 52], [12, 6], [3, 4]]]]],
|
|
785
|
+
["clothes", "brown", [["k", 7, 49, 18, 45, 4.5, 4]]],
|
|
786
|
+
["face", "skin", [["c", 20, 45, 4]]],
|
|
787
|
+
["face", "beige", [["e", 0, 65, 11, 12.5, 0], ["m", [["r", -9, 54, 5, 14, 2, 0]]]]],
|
|
788
|
+
["face", "skin", [["e", 0, 62, 7.5, 8, 0]]],
|
|
789
|
+
["face", "dark brown", [["-", [["e", 0, 58, 8, 9, 0]], [["r", 0, 66, 20, 12, 0, 0]]]]],
|
|
790
|
+
["clothes", "red", [["r", 0, 71, 21, 3.5, 1.5, 0]]],
|
|
791
|
+
["details", "black", [["m", [["c", -3.2, 63.5, 1.4]]]]]
|
|
792
|
+
]],
|
|
793
|
+
["baby", "nativity", "dark brown", [
|
|
794
|
+
["clothes", "light brown", [["m", [["r", -17, 5, 4, 10, 1, 0]]], ["p", [[-26, 22], [26, 22], [19, 7], [-19, 7]]]]],
|
|
795
|
+
["clothes", "yellow", [["p", [[-27, 21], [-24, 27], [-19, 22], [-14, 28], [-9, 22], [-4, 28], [1, 22], [6, 28], [11, 22], [16, 28], [21, 22], [25, 27], [27, 21]]]]],
|
|
796
|
+
["clothes", "white", [["e", -4, 27, 15, 6, 0]]],
|
|
797
|
+
["clothes", "cream", [["r", -9, 27, 2.5, 11, 1, 0], ["r", -1, 27, 2.5, 12, 1, 0]]],
|
|
798
|
+
["face", "skin", [["c", 15, 29, 6]]],
|
|
799
|
+
["details", "black", [["c", 13, 30, 1.1], ["c", 17.5, 30, 1.1]]],
|
|
800
|
+
["details", "pink", [["c", 12, 27.5, 1.3], ["c", 19, 27.5, 1.3]]]
|
|
801
|
+
]],
|
|
802
|
+
["shepherd", "nativity", "dark brown", [
|
|
803
|
+
["clothes", "light brown", [["r", 24, 41, 3, 80, 1.5, 0], ["a", 20, 81, 4, 0, 180, 3]]],
|
|
804
|
+
["clothes", "brown", [["h", [["c", -8, 46, 6], ["c", 8, 46, 6], ["c", -16, 4, 3], ["c", 16, 4, 3]]]]],
|
|
805
|
+
["clothes", "cream", [["p", [[-14, 50], [14, 50], [11, 36], [-11, 36]]]]],
|
|
806
|
+
["clothes", "brown", [["k", 6, 48, 20, 44, 4.5, 4]]],
|
|
807
|
+
["face", "skin", [["c", 22, 44, 4]]],
|
|
808
|
+
["face", "beige", [["e", 0, 65, 11, 12.5, 0], ["m", [["r", -9, 54, 5, 14, 2, 0]]]]],
|
|
809
|
+
["face", "skin", [["e", 0, 62, 7.5, 8, 0]]],
|
|
810
|
+
["clothes", "blue", [["r", 0, 71, 21, 3.5, 1.5, 0]]],
|
|
811
|
+
["details", "black", [["m", [["c", -3.2, 63, 1.4]]]]],
|
|
812
|
+
["details", "pink", [["m", [["e", -5, 59, 1.8, 1.2, 0]]]]]
|
|
813
|
+
]],
|
|
814
|
+
["caspar", "nativity", "dark brown", [
|
|
815
|
+
["clothes", "purple", [["h", [["c", -9, 46, 7], ["c", 9, 46, 7], ["c", -19, 4, 3], ["c", 19, 4, 3]]]]],
|
|
816
|
+
["clothes", "gold", [["r", 0, 25, 6, 44, 2, 0]]],
|
|
817
|
+
["clothes", "purple", [["m", [["k", -12, 47, -5, 34, 5, 4.5]]]]],
|
|
818
|
+
["face", "skin", [["m", [["c", -6, 33, 3.5]]]]],
|
|
819
|
+
["clothes", "gold", [["r", 0, 33, 11, 9, 1.5, 0]]],
|
|
820
|
+
["face", "skin", [["e", 0, 62, 8.5, 9.5, 0]]],
|
|
821
|
+
["face", "white", [["-", [["e", 0, 57, 9, 9.5, 0]], [["r", 0, 66, 20, 12, 0, 0]]]]],
|
|
822
|
+
["clothes", "gold", [["p", [[-9, 69], [9, 69], [10, 80], [5, 75], [0, 82], [-5, 75], [-10, 80]]]]],
|
|
823
|
+
["details", "red", [["c", 0, 33, 2]]],
|
|
824
|
+
["details", "black", [["m", [["c", -3.5, 63.5, 1.5]]]]]
|
|
825
|
+
]],
|
|
826
|
+
["melchior", "nativity", "dark brown", [
|
|
827
|
+
["clothes", "red", [["h", [["c", -9, 46, 7], ["c", 9, 46, 7], ["c", -19, 4, 3], ["c", 19, 4, 3]]]]],
|
|
828
|
+
["clothes", "gold", [["r", 0, 6, 34, 5, 2, 0]]],
|
|
829
|
+
["clothes", "red", [["m", [["k", -12, 47, -5, 34, 5, 4.5]]]]],
|
|
830
|
+
["face", "peach", [["m", [["c", -6, 33, 3.5]]]]],
|
|
831
|
+
["clothes", "gold", [["h", [["c", -4, 30, 2], ["c", 4, 30, 2], ["c", 0, 39, 3.5]]]]],
|
|
832
|
+
["face", "peach", [["e", 0, 62, 8.5, 9.5, 0]]],
|
|
833
|
+
["face", "dark brown", [["-", [["e", 0, 57, 9, 9.5, 0]], [["r", 0, 66, 20, 12, 0, 0]]]]],
|
|
834
|
+
["clothes", "gold", [["p", [[-9, 69], [9, 69], [11, 82], [4.5, 76], [0, 84], [-4.5, 76], [-11, 82]]]]],
|
|
835
|
+
["details", "green", [["c", 0, 72.5, 1.8]]],
|
|
836
|
+
["details", "black", [["m", [["c", -3.5, 63.5, 1.5]]]]]
|
|
837
|
+
]],
|
|
838
|
+
["balthasar", "nativity", "dark brown", [
|
|
839
|
+
["clothes", "green", [["h", [["c", -9, 46, 7], ["c", 9, 46, 7], ["c", -19, 4, 3], ["c", 19, 4, 3]]]]],
|
|
840
|
+
["clothes", "gold", [["m", [["r", -12, 25, 3.5, 42, 1.5, 6]]]]],
|
|
841
|
+
["clothes", "green", [["m", [["k", -12, 47, -5, 34, 5, 4.5]]]]],
|
|
842
|
+
["face", "brown", [["m", [["c", -6, 33, 3.5]]]]],
|
|
843
|
+
["clothes", "gold", [["e", 0, 34, 6, 7, 0]]],
|
|
844
|
+
["face", "brown", [["e", 0, 62, 8.5, 9.5, 0]]],
|
|
845
|
+
["clothes", "white", [["h", [["c", -9, 70, 3.5], ["c", 9, 70, 3.5], ["c", 0, 80, 7]]]]],
|
|
846
|
+
["details", "red", [["c", 0, 72, 2]]],
|
|
847
|
+
["details", "black", [["m", [["c", -3.5, 63.5, 1.5]]]]],
|
|
848
|
+
["details", "pink", [["e", 0, 57, 2.6, 1.3, 0]]]
|
|
849
|
+
]],
|
|
850
|
+
["ox", "nativity", "dark brown", [
|
|
851
|
+
["clothes", "cream", [["m", [["k", -14, 70, -26, 74, 3, 2], ["k", -26, 74, -27, 82, 2, 1.4]]]]],
|
|
852
|
+
["clothes", "brown", [
|
|
853
|
+
["m", [["r", -12, 7, 8, 14, 2.5, 0]]],
|
|
854
|
+
["e", 0, 28, 22, 18, 0],
|
|
855
|
+
["m", [["e", -19, 62, 8, 4, 15]]],
|
|
856
|
+
["e", 0, 58, 15, 16, 0]
|
|
857
|
+
]],
|
|
858
|
+
["face", "pink", [["m", [["e", -19, 62, 4.5, 2, 15]]]]],
|
|
859
|
+
["face", "beige", [["e", 0, 47, 12, 8, 0], ["c", 0, 69, 4]]],
|
|
860
|
+
["clothes", "dark brown", [["m", [["r", -12, 3, 8, 6, 2, 0]]]]],
|
|
861
|
+
["details", "black", [["m", [["c", -6.5, 60, 2.2]]]]],
|
|
862
|
+
["details", "dark brown", [["m", [["e", -4, 46.5, 1.8, 2.4, 0]]]]]
|
|
863
|
+
]],
|
|
864
|
+
["donkey", "nativity", "dark brown", [
|
|
865
|
+
["clothes", "grey", [
|
|
866
|
+
["m", [["r", -11, 8, 7, 16, 2.5, 0]]],
|
|
867
|
+
["e", 0, 28, 19, 17, 0],
|
|
868
|
+
["m", [["k", -7, 66, -12, 92, 5, 3.5]]],
|
|
869
|
+
["e", 0, 56, 12, 16, 0]
|
|
870
|
+
]],
|
|
871
|
+
["face", "light grey", [["m", [["k", -7.5, 70, -11.5, 88, 2.4, 1.6]]]]],
|
|
872
|
+
["face", "white", [["e", 0, 45, 10, 8, 0], ["e", 0, 24, 10, 10, 0]]],
|
|
873
|
+
["clothes", "dark grey", [["m", [["r", -11, 3, 7, 6, 2, 0]]], ["k", 0, 64, 0, 74, 3, 2.5]]],
|
|
874
|
+
["details", "black", [["m", [["c", -6, 58, 2.2]]]]],
|
|
875
|
+
["details", "dark grey", [["m", [["e", -3.5, 44, 1.6, 2.2, 0]]]]]
|
|
876
|
+
]],
|
|
877
|
+
["sheep", "nativity", "dark grey", [
|
|
878
|
+
["face", "black", [["m", [["r", -11, 9, 6, 18, 2.5, 0]]]]],
|
|
879
|
+
["clothes", "white", [
|
|
880
|
+
["e", 0, 35, 26, 18, 0],
|
|
881
|
+
for (a = [0:30:330]) ["c", 24 * cos(a), 35 + 17 * sin(a), 7]
|
|
882
|
+
]],
|
|
883
|
+
["face", "black", [["m", [["e", -16, 64, 8, 3.6, -25]]], ["e", 0, 59, 11, 14, 0]]],
|
|
884
|
+
["clothes", "white", [["c", -6.5, 72, 5.5], ["c", 0, 75, 5.5], ["c", 6.5, 72, 5.5]]],
|
|
885
|
+
["details", "white", [["m", [["c", -5, 60, 2.2]]]]],
|
|
886
|
+
["details", "pink", [["e", 0, 51.5, 3, 2, 0]]]
|
|
887
|
+
]],
|
|
888
|
+
|
|
889
|
+
// Animals
|
|
890
|
+
["bear", "animals", "dark brown", [
|
|
891
|
+
["clothes", "brown", [
|
|
892
|
+
["m", [["e", -13, 8, 9, 7.5, 0]]],
|
|
893
|
+
["e", 0, 28, 20, 20, 0],
|
|
894
|
+
["m", [["e", -18, 34, 6, 10, -30]]],
|
|
895
|
+
["m", [["c", -14, 75, 6.5]]],
|
|
896
|
+
["c", 0, 62, 17]
|
|
897
|
+
]],
|
|
898
|
+
["face", "beige", [["m", [["c", -14, 75, 3.5], ["e", -13, 7, 5, 4, 0]]], ["e", 0, 26, 12, 13, 0], ["e", 0, 56, 8, 6.5, 0]]],
|
|
899
|
+
["details", "black", [["m", [["c", -6, 65, 2.4]]], ["e", 0, 58.5, 3.2, 2.4, 0]]],
|
|
900
|
+
["details", "pink", [["m", [["e", -11, 57, 2.4, 1.6, 0]]]]]
|
|
901
|
+
]],
|
|
902
|
+
["fox", "animals", "dark brown", [
|
|
903
|
+
["clothes", "orange", [["e", 20, 18, 9, 18, 35]]],
|
|
904
|
+
["face", "white", [["e", 27, 30, 5, 6, 35]]],
|
|
905
|
+
["clothes", "orange", [
|
|
906
|
+
["h", [["c", -10, 12, 7], ["c", 10, 12, 7], ["c", 0, 40, 10]]],
|
|
907
|
+
["m", [["p", [[-16, 66], [-18, 86], [-5, 72]]]]],
|
|
908
|
+
["p", [[-19, 66], [19, 66], [16, 56], [0, 44], [-16, 56]]]
|
|
909
|
+
]],
|
|
910
|
+
["face", "dark brown", [["m", [["p", [[-13.5, 70.5], [-15, 79], [-9.5, 73]]]]]]],
|
|
911
|
+
["face", "white", [["p", [[-12, 58], [0, 46], [12, 58], [0, 55]]], ["e", 0, 28, 7, 12, 0]]],
|
|
912
|
+
["clothes", "dark brown", [["m", [["e", -7, 4, 4.5, 3, 0]]]]],
|
|
913
|
+
["details", "black", [["m", [["e", -6.5, 60, 1.8, 2.4, 0]]], ["c", 0, 47.5, 2.4]]]
|
|
914
|
+
]],
|
|
915
|
+
["cat", "animals", "dark grey", [
|
|
916
|
+
["clothes", "grey", [["k", 14, 6, 26, 30, 3.5, 3], ["c", 26, 34, 4]]],
|
|
917
|
+
["clothes", "grey", [
|
|
918
|
+
["h", [["c", -11, 9, 7], ["c", 11, 9, 7], ["c", 0, 38, 10]]],
|
|
919
|
+
["m", [["p", [[-15, 60], [-15, 77], [-4, 66]]]]],
|
|
920
|
+
["e", 0, 57, 15, 12.5, 0]
|
|
921
|
+
]],
|
|
922
|
+
["face", "pink", [["m", [["p", [[-13, 63], [-13.3, 72.5], [-7, 66]]]]]]],
|
|
923
|
+
["face", "white", [["e", 0, 26, 7, 13, 0], ["m", [["e", -3.5, 52, 4.5, 3.5, 0]]], ["m", [["e", -7, 4, 4, 3, 0]]]]],
|
|
924
|
+
["details", "light green", [["m", [["e", -6.5, 59, 2.4, 2.8, 0]]]]],
|
|
925
|
+
["details", "pink", [["p", [[-1.8, 55.5], [1.8, 55.5], [0, 53.5]]]]]
|
|
926
|
+
]],
|
|
927
|
+
["dog", "animals", "dark brown", [
|
|
928
|
+
["clothes", "tan", [["k", 14, 6, 25, 20, 3.5, 3]]],
|
|
929
|
+
["clothes", "tan", [
|
|
930
|
+
["h", [["c", -11, 9, 7], ["c", 11, 9, 7], ["c", 0, 38, 10]]],
|
|
931
|
+
["e", 0, 58, 15, 13.5, 0]
|
|
932
|
+
]],
|
|
933
|
+
["clothes", "brown", [["m", [["e", -15, 56, 5.5, 12, -15]]]]],
|
|
934
|
+
["face", "white", [["e", 0, 51, 7.5, 6, 0], ["e", 0, 26, 6.5, 11, 0], ["m", [["e", -7, 4, 4, 3, 0]]]]],
|
|
935
|
+
["clothes", "red", [["r", 0, 43, 19, 4, 2, 0]]],
|
|
936
|
+
["details", "black", [["m", [["c", -6, 61, 2.2]]], ["e", 0, 54, 3, 2.2, 0]]],
|
|
937
|
+
["details", "yellow", [["c", 0, 39.5, 2.4]]]
|
|
938
|
+
]],
|
|
939
|
+
["owl", "animals", "dark brown", [
|
|
940
|
+
["clothes", "brown", [
|
|
941
|
+
["e", 0, 40, 22, 30, 0],
|
|
942
|
+
["m", [["p", [[-18, 60], [-20, 78], [-8, 66]]]]]
|
|
943
|
+
]],
|
|
944
|
+
["face", "light brown", [["e", 0, 30, 14, 18, 0]]],
|
|
945
|
+
["clothes", "brown", [["m", [["e", -18, 36, 7, 15, 12]]]]],
|
|
946
|
+
["face", "beige", [["m", [["c", -8.5, 58, 9]]]]],
|
|
947
|
+
["face", "orange", [["p", [[-3, 53], [3, 53], [0, 47]]], ["m", [["e", -6, 9.5, 4.5, 3, 0]]]]],
|
|
948
|
+
["details", "black", [["m", [["c", -8.5, 58, 4]]]]],
|
|
949
|
+
["details", "brown", [
|
|
950
|
+
for (p = [[-6, 32], [0, 34], [6, 32], [-3, 26], [3, 26], [0, 19]]) ["a", p[0], p[1], 3, 200, 340, 1.8]
|
|
951
|
+
]]
|
|
952
|
+
]],
|
|
953
|
+
["deer", "animals", "dark brown", [
|
|
954
|
+
["clothes", "light brown", [
|
|
955
|
+
["m", [["r", -8, 10, 6, 20, 2.5, 0]]],
|
|
956
|
+
["e", 0, 32, 15, 16, 0],
|
|
957
|
+
["m", [["e", -15, 70, 9, 4.5, 30]]],
|
|
958
|
+
["e", 0, 62, 11, 14, 0]
|
|
959
|
+
]],
|
|
960
|
+
["face", "pink", [["m", [["e", -15, 70, 5.5, 2.2, 30]]]]],
|
|
961
|
+
["face", "beige", [["e", 0, 53, 7, 6, 0], ["e", 0, 28, 8, 10, 0]]],
|
|
962
|
+
["clothes", "dark brown", [["m", [["r", -8, 2.5, 6, 5, 1.5, 0]]]]],
|
|
963
|
+
["details", "black", [["m", [["c", -5, 63, 2.2]]], ["e", 0, 56, 2.6, 2, 0]]],
|
|
964
|
+
["details", "white", [["c", -10, 39, 1.6], ["c", 11, 41, 1.6], ["c", -8, 30, 1.4], ["c", 10, 25, 1.4], ["c", -11, 21, 1.4]]]
|
|
965
|
+
]]
|
|
966
|
+
];
|
|
278
967
|
`,"kerf/fit":`// kerf/fit: drawings scaled to a size and placed by a point of their box.
|
|
279
968
|
// Copyright (c) 2026 MyLaserTools. AGPL-3.0-only or MyLaserTools commercial licence.
|
|
280
969
|
//
|
|
@@ -1171,17 +1860,72 @@ module narrow_hinge(size, spacing = 1.5, bridge = 1.5) {
|
|
|
1171
1860
|
if (i % 2 == 0) line([x, -1], [x, h - bridge]); else line([x, bridge], [x, h + 1]);
|
|
1172
1861
|
}
|
|
1173
1862
|
|
|
1863
|
+
// The points a strip's middle follows round the corner at \`p\`, coming from
|
|
1864
|
+
// \`a\` and going on to \`b\`: an arc of radius \`r\` inside (the middle of the
|
|
1865
|
+
// sheet tangent to both sides) where both sides are at least \`straight\`
|
|
1866
|
+
// long, else \`p\` itself. A corner too tight for its sides rounds to the
|
|
1867
|
+
// radius that fits half of each.
|
|
1868
|
+
function strip_corner(a, p, b, straight = 10, r = undef) =
|
|
1869
|
+
let (
|
|
1870
|
+
R = (is_undef(r) ? 2 * $thickness : r) + $thickness / 2,
|
|
1871
|
+
u = p - a, v = b - p, lu = norm(u), lv = norm(v),
|
|
1872
|
+
h0 = atan2(u[1], u[0]), d0 = atan2(v[1], v[0]) - h0,
|
|
1873
|
+
turn = d0 > 180 ? d0 - 360 : d0 < -180 ? d0 + 360 : d0
|
|
1874
|
+
)
|
|
1875
|
+
lu < straight || lv < straight || abs(turn) <= 0.01 || abs(turn) >= 179.99 ? [p]
|
|
1876
|
+
: let (
|
|
1877
|
+
// How far back the arc starts from the corner, and its radius
|
|
1878
|
+
set = min(R * tan(abs(turn) / 2), lu / 2, lv / 2),
|
|
1879
|
+
rad = set / tan(abs(turn) / 2),
|
|
1880
|
+
side = turn > 0 ? 1 : -1,
|
|
1881
|
+
c = p - set * u / lu + side * rad * [-sin(h0), cos(h0)],
|
|
1882
|
+
m = max(ceil(abs(turn) / 5), ceil(rad * abs(turn) * PI / 180 / (max(straight, 1) / 2)))
|
|
1883
|
+
) [for (k = [0:m]) let (g = h0 + turn * k / m) c + side * rad * [sin(g), -cos(g)]];
|
|
1884
|
+
|
|
1885
|
+
// \`path\` with each sharp corner, where two segments at least \`straight\`
|
|
1886
|
+
// long meet, rounded as strip_corner() rounds it: the path a strip that
|
|
1887
|
+
// bends round radius \`r\` there follows. The strip is as long as this path,
|
|
1888
|
+
// and ends where it does.
|
|
1889
|
+
function strip_path(path, straight = 10, r = undef) =
|
|
1890
|
+
let (
|
|
1891
|
+
pts = [for (i = [0:len(path) - 1]) if (i == 0 || norm(path[i] - path[i - 1]) > 1e-9) path[i]],
|
|
1892
|
+
n = len(pts),
|
|
1893
|
+
all = n < 3 ? pts : concat([pts[0]], [for (i = [1:n - 2]) each strip_corner(pts[i - 1], pts[i], pts[i + 1], straight, r)], [pts[n - 1]])
|
|
1894
|
+
)
|
|
1895
|
+
// Two arcs on one short side meet at its middle: that point once, so no
|
|
1896
|
+
// segment is too short to have a heading
|
|
1897
|
+
[for (i = [0:len(all) - 1]) if (i == 0 || norm(all[i] - all[i - 1]) > 1e-6) all[i]];
|
|
1898
|
+
|
|
1899
|
+
// A closed outline with its sharp corners rounded as strip_path() rounds a
|
|
1900
|
+
// path's, each judged by its whole sides: the loop a strip round it follows
|
|
1901
|
+
function strip_loop(outline, straight = 10, r = undef) =
|
|
1902
|
+
let (
|
|
1903
|
+
n0 = len(outline),
|
|
1904
|
+
o = norm(outline[n0 - 1] - outline[0]) < 1e-9 ? slice(outline, 0, n0 - 1) : outline,
|
|
1905
|
+
pts = [for (i = [0:len(o) - 1]) if (i == 0 || norm(o[i] - o[i - 1]) > 1e-9) o[i]],
|
|
1906
|
+
m = len(pts),
|
|
1907
|
+
all = [for (i = [0:m - 1]) each strip_corner(pts[(i + m - 1) % m], pts[i], pts[(i + 1) % m], straight, r)],
|
|
1908
|
+
k = len(all)
|
|
1909
|
+
)
|
|
1910
|
+
// Two arcs on one short side meet at its middle: that point once
|
|
1911
|
+
[for (i = [0:k - 1]) if (norm(all[i] - all[(i + k - 1) % k]) > 1e-6) all[i]];
|
|
1912
|
+
|
|
1174
1913
|
// The bends of a strip that follows \`path\`, a list of [x, y] points along
|
|
1175
1914
|
// its middle: [s0, s1, angle] for each curve, measured along the path,
|
|
1176
1915
|
// turning left positive. Segments shorter than \`straight\` are curve, the
|
|
1177
|
-
// rest straight; a sharp corner bends round radius \`r\`.
|
|
1916
|
+
// rest straight; a sharp corner bends round radius \`r\`. A curve whose
|
|
1917
|
+
// radius changes, as a tight fillet running into a wide arc, is several
|
|
1918
|
+
// bends end to end, one for each stretch of much the same radius.
|
|
1178
1919
|
function strip_bends(path, straight = 10, r = undef) =
|
|
1179
1920
|
let (
|
|
1180
1921
|
rr = is_undef(r) ? 2 * $thickness : r,
|
|
1181
|
-
|
|
1182
|
-
|
|
1922
|
+
// Sharp corners rounded; a point repeated, as where a straight run and
|
|
1923
|
+
// an arc share their end, has no heading of its own and is left out
|
|
1924
|
+
pts = strip_path(path, straight, r),
|
|
1925
|
+
n = len(pts),
|
|
1926
|
+
segs = [for (i = [0:n - 2]) norm(pts[i + 1] - pts[i])],
|
|
1183
1927
|
at = [for (i = [0:n - 1]) i == 0 ? 0 : sum([for (k = [0:i - 1]) segs[k]])],
|
|
1184
|
-
head = [for (i = [0:n - 2]) atan2(
|
|
1928
|
+
head = [for (i = [0:n - 2]) atan2(pts[i + 1][1] - pts[i][1], pts[i + 1][0] - pts[i][0])],
|
|
1185
1929
|
turn = [for (i = [1:n - 2]) let (d = head[i] - head[i - 1]) d > 180 ? d - 360 : d < -180 ? d + 360 : d],
|
|
1186
1930
|
// Each corner as [s0, s1, angle]: a short segment's turn spreads over
|
|
1187
1931
|
// it, a sharp corner's over a bend of radius rr
|
|
@@ -1192,7 +1936,23 @@ function strip_bends(path, straight = 10, r = undef) =
|
|
|
1192
1936
|
s1 = short_out ? at[i] + segs[i] / 2 : at[i] + half)
|
|
1193
1937
|
[s0, s1, turn[i - 1]]]
|
|
1194
1938
|
)
|
|
1195
|
-
|
|
1939
|
+
strip_join(corners);
|
|
1940
|
+
|
|
1941
|
+
// Joins bends that touch or overlap into one where they turn the same way
|
|
1942
|
+
// at much the same rate (within a quarter), so each bend keeps close to
|
|
1943
|
+
// one radius. Two that overlap but don't join meet halfway through the
|
|
1944
|
+
// overlap.
|
|
1945
|
+
function strip_join(list, i = 0, cur = undef, out = []) =
|
|
1946
|
+
i == len(list) ? (is_undef(cur) ? out : concat(out, [cur]))
|
|
1947
|
+
: is_undef(cur) ? strip_join(list, i + 1, list[i], out)
|
|
1948
|
+
: let (nx = list[i]) nx[0] > cur[1] + 0.01 ? strip_join(list, i + 1, nx, concat(out, [cur]))
|
|
1949
|
+
: let (p = cur[2] / (cur[1] - cur[0]), q = nx[2] / (nx[1] - nx[0]),
|
|
1950
|
+
alike = p * q > 0 && max(abs(p), abs(q)) <= 1.25 * min(abs(p), abs(q)))
|
|
1951
|
+
// Alike, or one within the other: one bend
|
|
1952
|
+
alike || nx[0] <= cur[0] || nx[1] <= cur[1]
|
|
1953
|
+
? strip_join(list, i + 1, [cur[0], max(cur[1], nx[1]), cur[2] + nx[2]], out)
|
|
1954
|
+
: nx[0] >= cur[1] ? strip_join(list, i + 1, nx, concat(out, [cur]))
|
|
1955
|
+
: let (m = (nx[0] + cur[1]) / 2) strip_join(list, i + 1, [m, nx[1], nx[2]], concat(out, [[cur[0], m, cur[2]]]));
|
|
1196
1956
|
|
|
1197
1957
|
// Joins bends that touch or overlap into one
|
|
1198
1958
|
function strip_merge(list, i = 0, cur = undef, out = []) =
|
|
@@ -1210,14 +1970,16 @@ function strip_merge(list, i = 0, cur = undef, out = []) =
|
|
|
1210
1970
|
// own slots for the tabs. The 3D view shows the strip bent.
|
|
1211
1971
|
module flex_strip(path, width, name = "strip", tabs = true, straight = 10, r = undef, spacing = 1.5, bridge = 3, narrow = false) {
|
|
1212
1972
|
t = $thickness;
|
|
1213
|
-
L = path_length(path);
|
|
1973
|
+
L = path_length(strip_path(path, straight, r));
|
|
1214
1974
|
bends = strip_bends(path, straight, r);
|
|
1975
|
+
// The hinges are cut over each stretch of bends end to end
|
|
1976
|
+
spans = strip_merge(bends);
|
|
1215
1977
|
h0 = heading_at(path, 0);
|
|
1216
1978
|
p0 = path[0] - t / 2 * [-sin(h0), cos(h0)];
|
|
1217
|
-
runs = [for (k = [0:len(
|
|
1979
|
+
runs = [for (k = [0:len(spans)]) [k == 0 ? 0 : spans[k - 1][1], k == len(spans) ? L : spans[k][0]]];
|
|
1218
1980
|
part(name, at = [p0[0], p0[1], 0], rotate = orient([cos(h0), sin(h0), 0], [-sin(h0), cos(h0), 0]), bend = [for (b = bends) [b[0], b[1], b[2]]]) {
|
|
1219
1981
|
rect([L, width]);
|
|
1220
|
-
for (b =
|
|
1982
|
+
for (b = spans) translate([b[0], 0])
|
|
1221
1983
|
if (narrow) narrow_hinge([b[1] - b[0], width], spacing, bridge);
|
|
1222
1984
|
else living_hinge([b[1] - b[0], width], spacing = spacing, bridge = bridge);
|
|
1223
1985
|
if (tabs)
|
|
@@ -1229,6 +1991,134 @@ module flex_strip(path, width, name = "strip", tabs = true, straight = 10, r = u
|
|
|
1229
1991
|
}
|
|
1230
1992
|
}
|
|
1231
1993
|
}
|
|
1994
|
+
|
|
1995
|
+
// The part of \`path\` from s0 to s1 along it, its ends where those fall
|
|
1996
|
+
function path_part(path, s0, s1) =
|
|
1997
|
+
let (at = concat([0], scan([for (i = [0:len(path) - 2]) norm(path[i + 1] - path[i])], 0, function(a, x) a + x)))
|
|
1998
|
+
concat([point_at(path, s0)], [for (i = [0:len(path) - 1]) if (at[i] > s0 + 1e-6 && at[i] < s1 - 1e-6) path[i]], [point_at(path, s1)]);
|
|
1999
|
+
|
|
2000
|
+
// A closed outline as a path round it that starts and ends at the point
|
|
2001
|
+
// of it nearest \`join\`, or with join undef the middle of its longest side
|
|
2002
|
+
function wall_path(outline, join = undef) =
|
|
2003
|
+
let (
|
|
2004
|
+
n = len(outline),
|
|
2005
|
+
pts = norm(outline[n - 1] - outline[0]) < 1e-9 ? slice(outline, 0, n - 1) : outline,
|
|
2006
|
+
m = len(pts),
|
|
2007
|
+
near = [for (i = [0:m - 1]) let (a = pts[i], b = pts[(i + 1) % m], d = b - a,
|
|
2008
|
+
u = is_undef(join) ? 0.5 : clamp(((join - a) * d) / max(d * d, 1e-12), 0, 1)) [a + u * d, is_undef(join) ? -norm(d) : norm(join - a - u * d)]],
|
|
2009
|
+
k = fold([for (i = [0:m - 1]) i], 0, function(b, i) near[i][1] < near[b][1] ? i : b),
|
|
2010
|
+
ring = concat([near[k][0]], [for (i = [1:m]) pts[(k + i) % m]], [near[k][0]])
|
|
2011
|
+
)
|
|
2012
|
+
[for (i = [0:len(ring) - 1]) if (i == 0 || norm(ring[i] - ring[i - 1]) > 1e-9) ring[i]];
|
|
2013
|
+
|
|
2014
|
+
// Where to split a strip L long into n pieces no longer than max_length:
|
|
2015
|
+
// near even spacing, at the middle of a straight run where one is near,
|
|
2016
|
+
// else at the middle of a segment of the path, where its bends end
|
|
2017
|
+
function wall_splits(L, n, max_length, mids, halves, k = 1, prev = 0, out = []) =
|
|
2018
|
+
k >= n ? out
|
|
2019
|
+
: let (t = k * L / n,
|
|
2020
|
+
// Where this cut may go: no piece longer than max_length, this one or
|
|
2021
|
+
// those still to come
|
|
2022
|
+
lo = max(prev + 1, L - (n - k) * max_length), hi = prev + max_length,
|
|
2023
|
+
fits = function(list) [for (c = list) if (c >= lo && c <= hi) c],
|
|
2024
|
+
nearest = function(list) fold(list, list[0], function(b, x) abs(x - t) < abs(b - t) ? x : b),
|
|
2025
|
+
ok = fits(mids), half = fits(halves),
|
|
2026
|
+
c = len(ok) ? nearest(ok) : len(half) ? nearest(half) : clamp(t, lo, hi))
|
|
2027
|
+
wall_splits(L, n, max_length, mids, halves, k + 1, c, concat(out, [c]));
|
|
2028
|
+
|
|
2029
|
+
// The names of the pieces of the strip wall() makes
|
|
2030
|
+
function wall_strip_names(name, pieces) = pieces == 1 ? [str(name, " strip")] : [for (k = [1:pieces]) str(name, " strip ", k)];
|
|
2031
|
+
|
|
2032
|
+
// How many pieces wall() cuts its strip into
|
|
2033
|
+
function wall_pieces(outline, max_length = 400, join = undef, straight = 10, r = undef) = max(1, ceil(path_length(wall_path(strip_loop(outline, straight, r), join)) / max_length));
|
|
2034
|
+
|
|
2035
|
+
// A wall round a closed outline: a front plate, a back plate \`depth\`
|
|
2036
|
+
// behind it and a strip between them that follows the outline, bent on
|
|
2037
|
+
// living hinges where it curves and tabbed into slots in both plates where
|
|
2038
|
+
// it runs straight. The strip's ends meet at the point of the outline
|
|
2039
|
+
// nearest \`join\`; a strip longer than \`max_length\` is cut into pieces no
|
|
2040
|
+
// longer, split where it runs straight when it can, so each fits the bed.
|
|
2041
|
+
//
|
|
2042
|
+
// The first child, when given, is the front plate, drawn as the outline
|
|
2043
|
+
// is; the second the back plate. Without them each plate is the outline
|
|
2044
|
+
// grown by \`rim\` (half a thickness and 3 mm). Where the strip's ends meet
|
|
2045
|
+
// they are \`seam\` apart, so pieces bent on their hinges don't press on
|
|
2046
|
+
// each other. The parts are
|
|
2047
|
+
// str(name, " front"), str(name, " back") and str(name, " strip"), or
|
|
2048
|
+
// " strip 1", " strip 2" and so on for a strip in pieces. It stands
|
|
2049
|
+
// upright as placed by \`at\` and \`rotate\`: the outline is seen from the
|
|
2050
|
+
// front, the back plate behind it.
|
|
2051
|
+
module wall(outline, depth, name = "wall", join = undef, max_length = 400, rim = undef, seam = 0.3, tabs = true, straight = 10, r = undef, spacing = 1.5, bridge = 3, narrow = false, at = [0, 0, 0], rotate = [90, 0, 0]) {
|
|
2052
|
+
t = $thickness;
|
|
2053
|
+
grow = is_undef(rim) ? t / 2 + 3 : rim;
|
|
2054
|
+
path = wall_path(strip_loop(outline, straight, r), join);
|
|
2055
|
+
L = path_length(path);
|
|
2056
|
+
n = max(1, ceil(L / max_length));
|
|
2057
|
+
spans = strip_merge(strip_bends(path, straight, r));
|
|
2058
|
+
runs = [for (k = [0:len(spans)]) [k == 0 ? 0 : spans[k - 1][1], k == len(spans) ? L : spans[k][0]]];
|
|
2059
|
+
mids = [for (run = runs) if (run[1] - run[0] >= 2 * straight) (run[0] + run[1]) / 2];
|
|
2060
|
+
at_ = concat([0], scan([for (i = [0:len(path) - 2]) norm(path[i + 1] - path[i])], 0, function(a, x) a + x));
|
|
2061
|
+
halves = [for (i = [0:len(path) - 2]) (at_[i] + at_[i + 1]) / 2];
|
|
2062
|
+
cuts = concat([0], wall_splits(L, n, max_length, mids, halves), [L]);
|
|
2063
|
+
names = wall_strip_names(name, n);
|
|
2064
|
+
pieces = [for (k = [0:n - 1]) path_part(path, cuts[k] + seam / 2, cuts[k + 1] - seam / 2)];
|
|
2065
|
+
// The pieces with tabs, as flex_strip() puts them on runs over 16 mm
|
|
2066
|
+
tabbed = !tabs ? [] : [for (k = [0:n - 1]) let (sp = strip_merge(strip_bends(pieces[k], straight, r)), l = path_length(pieces[k]),
|
|
2067
|
+
rs = [for (j = [0:len(sp)]) (j == len(sp) ? l : sp[j][0]) - (j == 0 ? 0 : sp[j - 1][1])]) if (max(rs) > 16) names[k]];
|
|
2068
|
+
place(at = at, rotate = rotate) {
|
|
2069
|
+
part(str(name, " front"), slots = tabbed) {
|
|
2070
|
+
if ($children > 0) children(0);
|
|
2071
|
+
else offset(delta = grow) polygon(outline);
|
|
2072
|
+
}
|
|
2073
|
+
part(str(name, " back"), at = [0, 0, -depth - t], slots = tabbed) {
|
|
2074
|
+
if ($children > 1) children(1);
|
|
2075
|
+
else offset(delta = grow) polygon(outline);
|
|
2076
|
+
}
|
|
2077
|
+
for (k = [0:n - 1])
|
|
2078
|
+
flex_strip(pieces[k], depth, name = names[k], tabs = tabs, straight = straight, r = r, spacing = spacing, bridge = bridge, narrow = narrow);
|
|
2079
|
+
}
|
|
2080
|
+
}
|
|
2081
|
+
`,"kerf/inlay":`// kerf/inlay: inlays of another wood, stock or colour: the shapes cut out
|
|
2082
|
+
// of one part (or engraved into it as pockets) and cut again as inserts
|
|
2083
|
+
// that press into them.
|
|
2084
|
+
// Copyright (c) 2026 MyLaserTools. AGPL-3.0-only or MyLaserTools commercial licence.
|
|
2085
|
+
//
|
|
2086
|
+
// KerfScript takes the kerf off every cut, so a hole and an insert of the
|
|
2087
|
+
// same shape come out the same size; each insert is \`press\` mm bigger all
|
|
2088
|
+
// round so it holds.
|
|
2089
|
+
|
|
2090
|
+
// A part with inlays. Its first child is the part's shape; each child
|
|
2091
|
+
// after it is an inlay's shape. The inlays are cut through the part, or
|
|
2092
|
+
// with \`depth\` engraved that deep on the layer "pocket" (set that layer's
|
|
2093
|
+
// power for the depth). Each inlay is an insert of its own, named "name
|
|
2094
|
+
// inlay 1" up, \`press\` mm bigger all round, of materials[i] (stock of its
|
|
2095
|
+
// own, on a sheet of its own) or painted paints[i]; a pocket's insert is
|
|
2096
|
+
// \`depth\` thick. In the assembled view a through insert sits in its hole
|
|
2097
|
+
// and a pocket's on the surface over it.
|
|
2098
|
+
module inlaid(name, depth, press = 0.05, materials, paints, at = [0, 0, 0], rotate = [0, 0, 0]) {
|
|
2099
|
+
n = $children;
|
|
2100
|
+
assert(n >= 2, "inlaid(): give the part's shape, then one shape for each inlay");
|
|
2101
|
+
part(name, at = at, rotate = rotate) {
|
|
2102
|
+
if (is_undef(depth))
|
|
2103
|
+
difference() {
|
|
2104
|
+
children(0);
|
|
2105
|
+
for (i = [1:n - 1]) children(i);
|
|
2106
|
+
}
|
|
2107
|
+
else {
|
|
2108
|
+
children(0);
|
|
2109
|
+
layer("pocket", mode = "fill", color = "#555555") for (i = [1:n - 1]) children(i);
|
|
2110
|
+
}
|
|
2111
|
+
}
|
|
2112
|
+
for (i = [1:n - 1])
|
|
2113
|
+
let (
|
|
2114
|
+
m = is_undef(materials) || i - 1 >= len(materials) ? undef : materials[i - 1],
|
|
2115
|
+
c = is_undef(paints) || i - 1 >= len(paints) ? undef : paints[i - 1],
|
|
2116
|
+
t = is_undef(depth) ? $thickness : depth
|
|
2117
|
+
)
|
|
2118
|
+
material(thickness = t, name = is_undef(m) ? $material : m)
|
|
2119
|
+
part(str(name, " inlay ", i), glue = name, at = [0, 0, is_undef(depth) ? -t : 0], paint = c, press_fit = is_undef(depth))
|
|
2120
|
+
offset(delta = press) children(i);
|
|
2121
|
+
}
|
|
1232
2122
|
`,"kerf/joints":`// kerf/joints: joints between parts.
|
|
1233
2123
|
// Copyright (c) 2026 MyLaserTools. AGPL-3.0-only or MyLaserTools commercial licence.
|
|
1234
2124
|
|
|
@@ -1323,6 +2213,59 @@ module halved_pair(name, at = [0, 0, 0], cap = undef, feet = [], side_feet = und
|
|
|
1323
2213
|
}
|
|
1324
2214
|
}
|
|
1325
2215
|
}
|
|
2216
|
+
`,"kerf/layered":`// kerf/layered: multilayer pieces from one drawing, as layered ornaments,
|
|
2217
|
+
// mandalas, wreaths and signs are made.
|
|
2218
|
+
// Copyright (c) 2026 MyLaserTools. AGPL-3.0-only or MyLaserTools commercial licence.
|
|
2219
|
+
//
|
|
2220
|
+
// The children are the art's layers, back to front. Each becomes a part of
|
|
2221
|
+
// its own, glued on the one behind it and painted its colour; each layer
|
|
2222
|
+
// is at least the outline of everything in front of it, \`border\` mm
|
|
2223
|
+
// wider, so every layer is held up and shows as a rim round the next.
|
|
2224
|
+
|
|
2225
|
+
// A layer's colour: the one given for it, else from a palette that goes
|
|
2226
|
+
// from dark at the back to light at the front
|
|
2227
|
+
function layered_color(colors, k, n) =
|
|
2228
|
+
!is_undef(colors) && k < len(colors) ? colors[k]
|
|
2229
|
+
: ["dark brown", "brown", "light brown", "tan", "beige", "cream", "white"][
|
|
2230
|
+
min(6, round(k * 6 / max(1, n - 1)))];
|
|
2231
|
+
|
|
2232
|
+
// Layered art from its children, the layers back to front: one part a
|
|
2233
|
+
// layer, named "name layer 1" up from the back, each glued on the one
|
|
2234
|
+
// behind it and painted colors[k]. Each layer is its own drawing joined
|
|
2235
|
+
// with everything in front of it grown by \`border\` mm. \`shadow\` adds a
|
|
2236
|
+
// layer at the back that much wider still, in \`shadow_color\`; \`hole\` =
|
|
2237
|
+
// [x, y, d] cuts a hole d across through every layer, to hang it by. The
|
|
2238
|
+
// back layer goes at \`at\`, turned by \`rotate\`.
|
|
2239
|
+
module layered(name = "layered", colors, border = 2, shadow = 0, shadow_color = "dark grey", hole, at = [0, 0, 0], rotate = [0, 0, 0]) {
|
|
2240
|
+
n = $children;
|
|
2241
|
+
assert(n >= 1, "layered(): give the layers as children, back to front");
|
|
2242
|
+
module through() if (!is_undef(hole)) translate([hole[0], hole[1]]) circle(d = hole[2]);
|
|
2243
|
+
first = shadow > 0 ? str(name, " shadow") : str(name, " layer 1");
|
|
2244
|
+
if (shadow > 0)
|
|
2245
|
+
part(first, at = at, rotate = rotate, paint = shadow_color)
|
|
2246
|
+
difference() {
|
|
2247
|
+
offset(r = shadow) union() {
|
|
2248
|
+
children(0);
|
|
2249
|
+
if (n > 1) offset(r = border) union() for (j = [1:n - 1]) children(j);
|
|
2250
|
+
}
|
|
2251
|
+
through();
|
|
2252
|
+
}
|
|
2253
|
+
// Layer k: its drawing, and everything in front of it grown by the border
|
|
2254
|
+
for (k = [0:n - 1])
|
|
2255
|
+
let (
|
|
2256
|
+
pname = str(name, " layer ", k + 1),
|
|
2257
|
+
host = k == 0 ? (shadow > 0 ? first : undef) : str(name, " layer ", k)
|
|
2258
|
+
)
|
|
2259
|
+
part(pname, at = is_undef(host) ? at : undef, rotate = is_undef(host) ? rotate : undef,
|
|
2260
|
+
glue = host, paint = layered_color(colors, k, n), pieces = "any")
|
|
2261
|
+
difference() {
|
|
2262
|
+
union() {
|
|
2263
|
+
children(k);
|
|
2264
|
+
if (k < n - 1) offset(r = border) union() for (j = [k + 1:n - 1]) children(j);
|
|
2265
|
+
}
|
|
2266
|
+
through();
|
|
2267
|
+
}
|
|
2268
|
+
}
|
|
1326
2269
|
`,"kerf/linkage":`// kerf/linkage: where the joints of a linkage are at a crank angle.
|
|
1327
2270
|
// Copyright (c) 2026 MyLaserTools. AGPL-3.0-only or MyLaserTools commercial licence.
|
|
1328
2271
|
//
|
|
@@ -1381,9 +2324,12 @@ function link_angle(a, b) = atan2(b[1] - a[1], b[0] - a[0]);
|
|
|
1381
2324
|
// Copyright (c) 2026 MyLaserTools. AGPL-3.0-only or MyLaserTools commercial licence.
|
|
1382
2325
|
//
|
|
1383
2326
|
// A flat key turns an eccentric cam, which slides a bolt: half a turn
|
|
1384
|
-
// throws its nose out past the lock's top edge, into a
|
|
1385
|
-
//
|
|
1386
|
-
//
|
|
2327
|
+
// throws its nose out past the lock's top edge, into a slot in whatever it
|
|
2328
|
+
// locks, and half a turn back pulls it in. A bolt only holds against a pull
|
|
2329
|
+
// across its travel: set the lock so the bolt moves across the way the
|
|
2330
|
+
// locked part opens (sideways for a lid that lifts), and give the slot
|
|
2331
|
+
// wood on the side the part pulls from (a pocket, not a notch open that
|
|
2332
|
+
// way), so pulling presses the bolt against it. The lock is three layers
|
|
1387
2333
|
// of the current material: a base with the cam's hub, a frame with the
|
|
1388
2334
|
// cam and the bolt, and a plate with the keyhole.
|
|
1389
2335
|
//
|
|
@@ -1396,7 +2342,7 @@ function link_angle(a, b) = atan2(b[1] - a[1], b[0] - a[0]);
|
|
|
1396
2342
|
function lock_bounds(throw = 7) = let (d = lock_dims(throw))
|
|
1397
2343
|
[-d[6] / 2, d[8], d[6] / 2, d[7]];
|
|
1398
2344
|
|
|
1399
|
-
// Where the bolt's nose is: [width, y of its tip when locked]. Cut a
|
|
2345
|
+
// Where the bolt's nose is: [width, y of its tip when locked]. Cut a pocket
|
|
1400
2346
|
// a little wider than this where it goes.
|
|
1401
2347
|
function lock_nose(throw = 7) = let (d = lock_dims(throw)) [d[4], d[7] + d[5]];
|
|
1402
2348
|
|
|
@@ -1542,6 +2488,167 @@ module ring_stack(diameters, hole, name = "ring", count = undef, feet = true, cl
|
|
|
1542
2488
|
translate([-(t + clearance) / 2, -t - 1]) rect([t + clearance, h / 2 + t + 1]);
|
|
1543
2489
|
}
|
|
1544
2490
|
}
|
|
2491
|
+
`,"kerf/scene":`// kerf/scene: scene boxes and dioramas: a floor with rails, standees with
|
|
2492
|
+
// feet that stand in any rail, layered figures standing in them, and
|
|
2493
|
+
// snow-drip and wave edges.
|
|
2494
|
+
// Copyright (c) 2026 MyLaserTools. AGPL-3.0-only or MyLaserTools commercial licence.
|
|
2495
|
+
//
|
|
2496
|
+
// A floor (or a shelf) has rails: slots running across it, front to back
|
|
2497
|
+
// in rows. Every standee has 8 mm feet that go into any rail, so a scene
|
|
2498
|
+
// is changed by taking the standees out and putting others in. Standees
|
|
2499
|
+
// are drawn standing on y = 0, centred on x = 0; their feet go below.
|
|
2500
|
+
|
|
2501
|
+
use <kerf/figures>
|
|
2502
|
+
|
|
2503
|
+
// Where a floor's rails run, front to back: \`rows\` of them across a floor
|
|
2504
|
+
// \`depth\` deep, the first 8 mm from the front and the last 7 mm from the
|
|
2505
|
+
// back
|
|
2506
|
+
function scene_rows(depth, rows = 6) =
|
|
2507
|
+
assert(is_num(depth) && depth > 15, "scene_rows(): depth must be more than 15")
|
|
2508
|
+
rows == 1 ? [depth / 2] : [for (i = [0:rows - 1]) 8 + i * (depth - 15) / (rows - 1)];
|
|
2509
|
+
|
|
2510
|
+
// The rails of a floor \`width\` wide and \`depth\` deep, as slots to cut from
|
|
2511
|
+
// it: each \`$thickness + clearance\` wide, running across the floor and
|
|
2512
|
+
// stopping \`margin\` short of each side
|
|
2513
|
+
module scene_rails(width, depth, rows = 6, clearance = 0.1, margin = 6) {
|
|
2514
|
+
w = $thickness + clearance;
|
|
2515
|
+
for (y = scene_rows(depth, rows)) translate([margin, y - w / 2]) rect([width - 2 * margin, w]);
|
|
2516
|
+
}
|
|
2517
|
+
|
|
2518
|
+
// A floor with its rails, \`width\` by \`depth\`, its front edge on y = 0
|
|
2519
|
+
module scene_floor(width, depth, rows = 6, clearance = 0.1, margin = 6, r = 0) {
|
|
2520
|
+
difference() {
|
|
2521
|
+
rect([width, depth], r = r);
|
|
2522
|
+
scene_rails(width, depth, rows, clearance, margin);
|
|
2523
|
+
}
|
|
2524
|
+
}
|
|
2525
|
+
|
|
2526
|
+
// Where a standee's feet go across it, from its middle: one for a standee
|
|
2527
|
+
// under 28 mm wide, two a quarter of the width either side otherwise, and
|
|
2528
|
+
// three for a full-width one, as a backdrop
|
|
2529
|
+
function standee_feet(width, full = false) =
|
|
2530
|
+
full ? [-width / 3, 0, width / 3] : width < 28 ? [0] : [-width / 4, width / 4];
|
|
2531
|
+
|
|
2532
|
+
// The mound a standee stands on: 4.5 mm under a standee under 28 mm wide,
|
|
2533
|
+
// so it stands clear of the floor's edge, else none
|
|
2534
|
+
function standee_mound(width) = width < 28 ? 4.5 : 0;
|
|
2535
|
+
|
|
2536
|
+
// A standee: its children, a drawing, stood on a mound \`mound\` mm high
|
|
2537
|
+
// (by default as standee_mound() says) with \`tab\` mm feet below y = 0 that
|
|
2538
|
+
// go \`floor\` mm (the floor's thickness, $thickness) into a rail, spread
|
|
2539
|
+
// over the width it stands on as standee_feet() says; without a mound, a
|
|
2540
|
+
// ground line 2 mm high joins what stands on the floor. With
|
|
2541
|
+
// \`clip\`, a polygon's points, the drawing and mound are clipped to it and
|
|
2542
|
+
// the feet left whole, as for a standee in a round case.
|
|
2543
|
+
module standee(mound, full = false, tab = 8, floor, clip) {
|
|
2544
|
+
t = is_undef(floor) ? $thickness : floor;
|
|
2545
|
+
measure() {
|
|
2546
|
+
children();
|
|
2547
|
+
let (
|
|
2548
|
+
b = $bounds,
|
|
2549
|
+
w = b[2] - b[0],
|
|
2550
|
+
cx = (b[0] + b[2]) / 2,
|
|
2551
|
+
m = is_undef(mound) ? standee_mound(w) : mound
|
|
2552
|
+
) {
|
|
2553
|
+
intersection() {
|
|
2554
|
+
union() {
|
|
2555
|
+
translate([0, m - b[1]]) children();
|
|
2556
|
+
if (m > 0) translate([b[0], 0]) rect([w, m + 0.5], r = min(m / 2, w / 4));
|
|
2557
|
+
}
|
|
2558
|
+
if (!is_undef(clip)) polygon(clip);
|
|
2559
|
+
}
|
|
2560
|
+
// The feet go where the drawing meets the floor: spread over the
|
|
2561
|
+
// width it stands on, each a whole tab inside it where it is wide
|
|
2562
|
+
// enough
|
|
2563
|
+
measure() {
|
|
2564
|
+
intersection() {
|
|
2565
|
+
union() {
|
|
2566
|
+
translate([0, m - b[1]]) children();
|
|
2567
|
+
if (m > 0) translate([b[0], 0]) rect([w, m + 0.5], r = min(m / 2, w / 4));
|
|
2568
|
+
}
|
|
2569
|
+
translate([b[0] - 1, -1]) rect([w + 2, 2]);
|
|
2570
|
+
}
|
|
2571
|
+
let (f = $bounds, fw = f[2] - f[0], fc = (f[0] + f[2]) / 2) {
|
|
2572
|
+
// A ground line 2 mm high joins legs and feet that meet the
|
|
2573
|
+
// floor apart
|
|
2574
|
+
if (m == 0) translate([f[0], 0]) rect([fw, 2]);
|
|
2575
|
+
for (x = standee_feet(fw, full))
|
|
2576
|
+
let (at = fw < tab ? fc : clamp(fc + x, f[0] + tab / 2, f[2] - tab / 2))
|
|
2577
|
+
translate([at - tab / 2, -t]) rect([tab, t + 0.5]);
|
|
2578
|
+
}
|
|
2579
|
+
}
|
|
2580
|
+
}
|
|
2581
|
+
}
|
|
2582
|
+
}
|
|
2583
|
+
|
|
2584
|
+
// A layered figure from kerf/figures standing in a rail: its backer a
|
|
2585
|
+
// standee with feet (and a mound when narrow), its other layers glued on
|
|
2586
|
+
// the front. \`at\` is where its feet go: [x, the rail's y, the floor's top
|
|
2587
|
+
// z]; \`turn\` turns it about its feet. Each colour is a painted part, named
|
|
2588
|
+
// after \`label\`.
|
|
2589
|
+
module scene_figure(name, height = 60, at = [0, 0, 0], turn = 0, label, mound, floor, border = 2, gap = 0.6) {
|
|
2590
|
+
base = is_undef(label) ? lower(name) : label;
|
|
2591
|
+
t = is_undef(floor) ? $thickness : floor;
|
|
2592
|
+
layers = figure_layers(name);
|
|
2593
|
+
middle = [for (l = layers) if (l[0] == "clothes" || l[0] == "face") l];
|
|
2594
|
+
measure() {
|
|
2595
|
+
figure_layer(name, "outline", height, border = border, gap = gap);
|
|
2596
|
+
let (b = $bounds, m = is_undef(mound) ? standee_mound(b[2] - b[0]) : mound) {
|
|
2597
|
+
// Its thickness stands in the rail, centred on it
|
|
2598
|
+
part(str(base, " outline"), at = [at[0] - $thickness / 2 * sin(turn), at[1] + $thickness / 2 * cos(turn), at[2]],
|
|
2599
|
+
rotate = [90, 0, turn], paint = layers[0][1])
|
|
2600
|
+
standee(m, floor = t) figure_layer(name, "outline", height, border = border, gap = gap);
|
|
2601
|
+
for (l = middle)
|
|
2602
|
+
measure() {
|
|
2603
|
+
figure_layer(name, l[0], height, l[1], border = border, gap = gap);
|
|
2604
|
+
if (!is_undef($bounds))
|
|
2605
|
+
part(str(base, " ", l[0], " ", l[1]), glue = str(base, " outline"), at = [0, m, 0], paint = l[1], pieces = "any")
|
|
2606
|
+
figure_layer(name, l[0], height, l[1], border = border, gap = gap);
|
|
2607
|
+
}
|
|
2608
|
+
figure_details(name, height, base, 1, border, gap);
|
|
2609
|
+
}
|
|
2610
|
+
}
|
|
2611
|
+
}
|
|
2612
|
+
|
|
2613
|
+
// A layered figure on a base of its own, to stand on a shelf: a base
|
|
2614
|
+
// plate \`base\` [w, d] mm with one rail, the figure's feet in it
|
|
2615
|
+
module figure_base(name, height = 80, base = [60, 20], at = [0, 0, 0], label, clearance = 0.1, r = 3) {
|
|
2616
|
+
label_ = is_undef(label) ? lower(name) : label;
|
|
2617
|
+
part(str(label_, " base"), at = [at[0] - base[0] / 2, at[1] - base[1] / 2, at[2]])
|
|
2618
|
+
difference() {
|
|
2619
|
+
rect(base, r = r);
|
|
2620
|
+
translate([6, base[1] / 2 - ($thickness + clearance) / 2]) rect([base[0] - 12, $thickness + clearance]);
|
|
2621
|
+
}
|
|
2622
|
+
scene_figure(name, height, at = [at[0], at[1], at[2] + $thickness], label = label_);
|
|
2623
|
+
}
|
|
2624
|
+
|
|
2625
|
+
// An edge that drips, as snow along a roof or icing on a cake: a strip
|
|
2626
|
+
// \`width\` wide and \`height\` tall above y = 0, with \`n\` round drips hanging
|
|
2627
|
+
// below it up to \`depth\` mm, their lengths and places varied by \`seed\`
|
|
2628
|
+
module drip_edge(width, height = 6, depth = 8, n, seed = 1) {
|
|
2629
|
+
k = is_undef(n) ? max(2, round(width / 12)) : n;
|
|
2630
|
+
len_ = rands(0.35, 1, k, seed);
|
|
2631
|
+
shift = rands(-0.25, 0.25, k, seed + 1);
|
|
2632
|
+
r = min(width / k / 4, depth / 3);
|
|
2633
|
+
rect([width, height]);
|
|
2634
|
+
for (i = [0:k - 1])
|
|
2635
|
+
let (x = width * (i + 0.5 + shift[i]) / k)
|
|
2636
|
+
hull() {
|
|
2637
|
+
translate([x, height / 2]) circle(r = r);
|
|
2638
|
+
translate([x, -depth * len_[i] + r]) circle(r = r);
|
|
2639
|
+
}
|
|
2640
|
+
}
|
|
2641
|
+
|
|
2642
|
+
// An edge of waves, as water or a frill: a strip \`width\` wide and \`height\`
|
|
2643
|
+
// tall above y = 0, its bottom edge \`n\` waves \`depth\` mm deep
|
|
2644
|
+
module wave_edge(width, height = 6, depth = 4, n) {
|
|
2645
|
+
k = is_undef(n) ? max(1, round(width / 20)) : n;
|
|
2646
|
+
steps = 24 * k;
|
|
2647
|
+
polygon(concat(
|
|
2648
|
+
[[0, height], [width, height]],
|
|
2649
|
+
[for (i = [0:steps]) let (x = width * (1 - i / steps)) [x, -depth / 2 + depth / 2 * cos(360 * k * x / width)]]
|
|
2650
|
+
));
|
|
2651
|
+
}
|
|
1545
2652
|
`,"kerf/shapes":`// kerf/shapes: basic shapes by name, sized to a box.
|
|
1546
2653
|
// Copyright (c) 2026 MyLaserTools. AGPL-3.0-only or MyLaserTools commercial licence.
|
|
1547
2654
|
//
|
|
@@ -1866,8 +2973,9 @@ module speech_bubble(size = [40, 30], r, tail) {
|
|
|
1866
2973
|
polygon([[-s[0] * 0.3, yb + min(bh / 2, rr + 1)], [-s[0] * 0.3 + s[0] / 5, yb + min(bh / 2, rr + 1)], [-s[0] * 0.38, -s[1] / 2]]);
|
|
1867
2974
|
}
|
|
1868
2975
|
}
|
|
1869
|
-
`,"kerf/sizes":`// kerf/sizes: paper, card and
|
|
1870
|
-
//
|
|
2976
|
+
`,"kerf/sizes":`// kerf/sizes: paper, card, photo and banknote sizes, and the sizes of
|
|
2977
|
+
// bought parts and everyday things, in millimetres, for holders, folders,
|
|
2978
|
+
// frames and boxes made to fit them.
|
|
1871
2979
|
// Copyright (c) 2026 MyLaserTools. AGPL-3.0-only or MyLaserTools commercial licence.
|
|
1872
2980
|
|
|
1873
2981
|
// Paper sizes as [width, height], portrait: "A0" to "A8", "B4" to "B6",
|
|
@@ -1880,7 +2988,8 @@ function paper_size(name) = let (s = lookup_size(name, PAPER_SIZES))
|
|
|
1880
2988
|
// Card sizes as [width, height], landscape: "business" (85 x 55, Europe),
|
|
1881
2989
|
// "us business" (88.9 x 50.8), "credit" (85.6 x 53.98, ID-1), "japan"
|
|
1882
2990
|
// (91 x 55), "playing" (63 x 88), "bridge" (56 x 87), "tarot" (70 x 120),
|
|
1883
|
-
// "postcard" (148 x 105), "us postcard" (152.4 x 101.6)
|
|
2991
|
+
// "postcard" (148 x 105), "us postcard" (152.4 x 101.6), "gift card"
|
|
2992
|
+
// (85.6 x 53.98, as a credit card).
|
|
1884
2993
|
function card_size(name) = let (s = lookup_size(name, CARD_SIZES))
|
|
1885
2994
|
is_undef(s) ? assert(false, str("Unknown card size \\"", name, "\\". Known: ", size_names(CARD_SIZES))) : s;
|
|
1886
2995
|
|
|
@@ -1890,15 +2999,39 @@ function card_size(name) = let (s = lookup_size(name, CARD_SIZES))
|
|
|
1890
2999
|
function photo_size(name) = let (s = lookup_size(lookup_alias(name, PHOTO_ALIASES), PHOTO_SIZES))
|
|
1891
3000
|
is_undef(s) ? assert(false, str("Unknown photo size \\"", name, "\\". Known: ", size_names(PHOTO_SIZES))) : s;
|
|
1892
3001
|
|
|
1893
|
-
//
|
|
1894
|
-
//
|
|
1895
|
-
//
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
3002
|
+
// Banknote sizes as [width, height], landscape: "usd" (every US note),
|
|
3003
|
+
// "cad" (every Canadian note), "eur 5" to "eur 200", "gbp 5" to "gbp 50",
|
|
3004
|
+
// "aud 5" to "aud 100".
|
|
3005
|
+
function note_size(name) = let (s = lookup_size(name, NOTE_SIZES))
|
|
3006
|
+
is_undef(s) ? assert(false, str("Unknown banknote \\"", name, "\\". Known: ", size_names(NOTE_SIZES))) : s;
|
|
3007
|
+
|
|
3008
|
+
// A bought part's or an everyday thing's sizes by name, as a record: \`body\`
|
|
3009
|
+
// [width, depth, height]; for a round one its \`diameter\` and \`height\` (an
|
|
3010
|
+
// egg's \`length\`); for parts with one, the \`shaft\` diameter, the
|
|
3011
|
+
// \`shaft_length\` it stands out of the body and the \`hole\` to cut for it.
|
|
3012
|
+
// Retail sizes vary: measure yours.
|
|
3013
|
+
// Movements: "music-18" (an 18-note wind-up music box movement, shaft the
|
|
3014
|
+
// winding key's), "quartz-clock" (a 56 mm quartz clock movement with the
|
|
3015
|
+
// 16.5 mm shaft for dials up to 8 mm thick).
|
|
3016
|
+
// Lights: "tealight", "maxi tealight", "led tealight", "led puck",
|
|
3017
|
+
// "fairy lights" (the battery box of a string of them, with its \`wire\`).
|
|
3018
|
+
// Eggs and bottles: "hen egg", "chocolate egg", "wine bottle" (with its
|
|
3019
|
+
// \`neck\`).
|
|
3020
|
+
// Small parts: "magnet 6x2", "magnet 10x3", "magnet 12x3" (discs),
|
|
3021
|
+
// "key ring 25", "battery box 2aa", "battery box 3aa", "coin cell holder",
|
|
3022
|
+
// "key fob", "marble-16", "marble-25".
|
|
3023
|
+
// Boxes: "tissue box", "tissue cube".
|
|
1899
3024
|
function part_size(name) = let (s = lookup_size(name, PART_SIZES))
|
|
1900
3025
|
is_undef(s) ? assert(false, str("Unknown part \\"", name, "\\". Known: ", size_names(PART_SIZES))) : s;
|
|
1901
3026
|
|
|
3027
|
+
// The names in one of the tables, as a list, for a customizer menu:
|
|
3028
|
+
// "paper", "card", "photo", "note" (banknotes) or "part"
|
|
3029
|
+
function size_list(kind) =
|
|
3030
|
+
let (t = kind == "paper" ? PAPER_SIZES : kind == "card" ? CARD_SIZES : kind == "photo" ? PHOTO_SIZES
|
|
3031
|
+
: kind == "note" ? NOTE_SIZES : kind == "part" ? PART_SIZES : undef)
|
|
3032
|
+
assert(!is_undef(t), str("size_list(): kind must be \\"paper\\", \\"card\\", \\"photo\\", \\"note\\" or \\"part\\", got ", kind))
|
|
3033
|
+
[for (e = t) e[0]];
|
|
3034
|
+
|
|
1902
3035
|
// A size turned to lie wider than tall
|
|
1903
3036
|
function landscape(size) = size[0] >= size[1] ? size : [size[1], size[0]];
|
|
1904
3037
|
// A size turned to stand taller than wide
|
|
@@ -1916,7 +3049,15 @@ PAPER_SIZES = [
|
|
|
1916
3049
|
CARD_SIZES = [
|
|
1917
3050
|
["business", [85, 55]], ["us business", [88.9, 50.8]], ["credit", [85.6, 53.98]],
|
|
1918
3051
|
["japan", [91, 55]], ["playing", [63, 88]], ["bridge", [56, 87]], ["tarot", [70, 120]],
|
|
1919
|
-
["postcard", [148, 105]], ["us postcard", [152.4, 101.6]]
|
|
3052
|
+
["postcard", [148, 105]], ["us postcard", [152.4, 101.6]], ["gift card", [85.6, 53.98]]
|
|
3053
|
+
];
|
|
3054
|
+
NOTE_SIZES = [
|
|
3055
|
+
["usd", [155.96, 66.29]], ["cad", [152.4, 69.85]],
|
|
3056
|
+
["eur 5", [120, 62]], ["eur 10", [127, 67]], ["eur 20", [133, 72]],
|
|
3057
|
+
["eur 50", [140, 77]], ["eur 100", [147, 77]], ["eur 200", [153, 77]],
|
|
3058
|
+
["gbp 5", [125, 65]], ["gbp 10", [132, 69]], ["gbp 20", [139, 73]], ["gbp 50", [146, 77]],
|
|
3059
|
+
["aud 5", [130, 65]], ["aud 10", [137, 65]], ["aud 20", [144, 65]],
|
|
3060
|
+
["aud 50", [151, 65]], ["aud 100", [158, 65]]
|
|
1920
3061
|
];
|
|
1921
3062
|
PHOTO_SIZES = [
|
|
1922
3063
|
["4x6", [152.4, 101.6]], ["5x7", [177.8, 127]], ["8x10", [254, 203.2]],
|
|
@@ -1932,7 +3073,25 @@ PART_SIZES = [
|
|
|
1932
3073
|
["music-18", {body = [50, 44, 20], shaft = 3.5, hole = 6}],
|
|
1933
3074
|
["quartz-clock", {body = [56, 56, 16], shaft = 7.6, shaft_length = 16.5, hole = 8, dial = 8}],
|
|
1934
3075
|
["marble-16", {body = [16, 16, 16]}],
|
|
1935
|
-
["marble-25", {body = [25, 25, 25]}]
|
|
3076
|
+
["marble-25", {body = [25, 25, 25]}],
|
|
3077
|
+
["tealight", {body = [39, 39, 16], diameter = 39, height = 16, hole = 40}],
|
|
3078
|
+
["maxi tealight", {body = [59, 59, 24], diameter = 59, height = 24, hole = 60}],
|
|
3079
|
+
["led tealight", {body = [38, 38, 36], diameter = 38, height = 36, hole = 40}],
|
|
3080
|
+
["led puck", {body = [70, 70, 25], diameter = 70, height = 25, hole = 72}],
|
|
3081
|
+
["fairy lights", {body = [62, 37, 22], wire = 2}],
|
|
3082
|
+
["hen egg", {body = [44, 44, 57], diameter = 44, length = 57}],
|
|
3083
|
+
["chocolate egg", {body = [40, 40, 60], diameter = 40, length = 60}],
|
|
3084
|
+
["wine bottle", {body = [76, 76, 300], diameter = 76, height = 300, neck = 30}],
|
|
3085
|
+
["magnet 6x2", {body = [6, 6, 2], diameter = 6, height = 2, hole = 6.2}],
|
|
3086
|
+
["magnet 10x3", {body = [10, 10, 3], diameter = 10, height = 3, hole = 10.2}],
|
|
3087
|
+
["magnet 12x3", {body = [12, 12, 3], diameter = 12, height = 3, hole = 12.2}],
|
|
3088
|
+
["key ring 25", {body = [25, 25, 2.5], diameter = 25, height = 2.5}],
|
|
3089
|
+
["battery box 2aa", {body = [68, 35, 18]}],
|
|
3090
|
+
["battery box 3aa", {body = [68, 48, 18]}],
|
|
3091
|
+
["coin cell holder", {body = [25, 21, 6]}],
|
|
3092
|
+
["key fob", {body = [60, 35, 15]}],
|
|
3093
|
+
["tissue box", {body = [240, 120, 90]}],
|
|
3094
|
+
["tissue cube", {body = [115, 115, 130]}]
|
|
1936
3095
|
];
|
|
1937
3096
|
|
|
1938
3097
|
// The size of that name in a table of [name, size], ignoring case
|
|
@@ -1944,6 +3103,65 @@ function lookup_alias(name, aliases) = let (k = lower(name), hit = [for (e = ali
|
|
|
1944
3103
|
len(hit) ? hit[0] : name;
|
|
1945
3104
|
// The names in a table, for messages
|
|
1946
3105
|
function size_names(table) = join([for (e = table) e[0]], ", ");
|
|
3106
|
+
`,"kerf/sphere":`// kerf/sphere: slot-together balls and domes, as 3D baubles, globes and
|
|
3107
|
+
// lantern domes.
|
|
3108
|
+
// Copyright (c) 2026 MyLaserTools. AGPL-3.0-only or MyLaserTools commercial licence.
|
|
3109
|
+
//
|
|
3110
|
+
// A ball is half-disc fins standing round an upright axis, like the
|
|
3111
|
+
// segments of an orange, held by flat rings slotted onto them with halving
|
|
3112
|
+
// joints. The fins stop short of the axis, so they never meet each other.
|
|
3113
|
+
|
|
3114
|
+
// The heights of a ball's rings above its centre: the equator alone, or
|
|
3115
|
+
// \`rings\` spread between 60 degrees south and north; for a dome, from 10
|
|
3116
|
+
// to 70 degrees north
|
|
3117
|
+
function ball_rings(d, rings = 1, dome = false) =
|
|
3118
|
+
let (R = d / 2)
|
|
3119
|
+
dome ? (rings <= 1 ? [R * sin(10)] : [for (i = [0:rings - 1]) R * sin(10 + 60 * i / (rings - 1))])
|
|
3120
|
+
: rings <= 1 ? [0] : [for (i = [0:rings - 1]) R * sin(-60 + 120 * i / (rings - 1))];
|
|
3121
|
+
|
|
3122
|
+
// A ball \`d\` across, its centre at \`at\`: \`fins\` half-disc fins round its
|
|
3123
|
+
// upright axis and \`rings\` flat rings \`width\` wide slotted onto them. A
|
|
3124
|
+
// dome is the top half, standing on its lowest ring. \`hollow\` cuts the
|
|
3125
|
+
// fins away within that radius of the centre, to make room for a scene
|
|
3126
|
+
// inside; \`floor\` makes the lowest ring a whole disc for it to stand on,
|
|
3127
|
+
// with a rail along x across the hollow for a standee's feet.
|
|
3128
|
+
// \`loop\` (a diameter) puts a hole near the top of each fin for a ribbon
|
|
3129
|
+
// to hang it by. Parts are named after \`label\`: "ball fin", "ball ring 1".
|
|
3130
|
+
module ball(d = 80, fins = 6, rings = 1, width = 8, hollow = 0, floor = false, dome = false, loop = 4, at = [0, 0, 0], label = "ball", clearance = 0.1) {
|
|
3131
|
+
R = d / 2;
|
|
3132
|
+
t = $thickness;
|
|
3133
|
+
core = 1.2 * t;
|
|
3134
|
+
assert(fins >= 3, "ball(): fins must be 3 or more");
|
|
3135
|
+
assert(width < R / 2, "ball(): the rings must be narrower than a quarter of the ball");
|
|
3136
|
+
heights = ball_rings(d, rings, dome);
|
|
3137
|
+
hx = core + loop / 2 + 2;
|
|
3138
|
+
part(str(label, " fin"), qty = fins,
|
|
3139
|
+
at = [for (k = [0:fins - 1]) let (a = 360 * k / fins) at + [-t / 2 * sin(a), t / 2 * cos(a), 0]],
|
|
3140
|
+
rotate = [for (k = [0:fins - 1]) [90, 0, 360 * k / fins]],
|
|
3141
|
+
halving = [str(label, " ring*")], clearance = clearance)
|
|
3142
|
+
difference() {
|
|
3143
|
+
intersection() {
|
|
3144
|
+
circle(r = R);
|
|
3145
|
+
translate([core, dome ? 0 : -R]) rect([R, dome ? R : 2 * R]);
|
|
3146
|
+
}
|
|
3147
|
+
if (hollow > 0) circle(r = hollow);
|
|
3148
|
+
if (loop > 0) translate([hx, sqrt(R * R - (hx + loop / 2) * (hx + loop / 2)) - loop / 2 - 2]) circle(d = loop);
|
|
3149
|
+
}
|
|
3150
|
+
for (i = [0:len(heights) - 1])
|
|
3151
|
+
let (h = heights[i], r = sqrt(R * R - h * h))
|
|
3152
|
+
part(str(label, " ring ", i + 1), at = at + [0, 0, h - t / 2])
|
|
3153
|
+
// As many corners as a multiple of the fins, so every fin crosses
|
|
3154
|
+
// a ring alike and takes the same slot
|
|
3155
|
+
difference() {
|
|
3156
|
+
circle(r = r, $fn = fins * ceil(120 / fins));
|
|
3157
|
+
if (!(floor && i == 0)) circle(r = r - width, $fn = fins * ceil(120 / fins));
|
|
3158
|
+
// A floor in a hollow ball has a rail across its middle, where no
|
|
3159
|
+
// fin reaches, for a standee from kerf/scene
|
|
3160
|
+
if (floor && i == 0 && hollow > 12)
|
|
3161
|
+
translate([-(hollow - 6), -(t + clearance) / 2]) rect([2 * (hollow - 6), t + clearance]);
|
|
3162
|
+
}
|
|
3163
|
+
if (loop > 0) hardware("ribbon", at + [0, 0, R - 6], at + [0, 0, R + 25], [6, 0.4], label = str(label, " ribbon"));
|
|
3164
|
+
}
|
|
1947
3165
|
`,"kerf/stand":`// kerf/stand: a sign, a photo or a calendar standing in a base.
|
|
1948
3166
|
// Copyright (c) 2026 MyLaserTools. AGPL-3.0-only or MyLaserTools commercial licence.
|
|
1949
3167
|
//
|
|
@@ -2015,15 +3233,26 @@ module stand_slots(width, count = undef, tab = undef, lean = 0, clearance = 0.1)
|
|
|
2015
3233
|
// closed and its holes filled, with the drawing's detail engraved on it:
|
|
2016
3234
|
// a pictogram drawn as separate strokes (a moon and stars, yarn) cut out
|
|
2017
3235
|
// in one piece. bridge = w also joins pieces too far apart to close, by
|
|
2018
|
-
// strips w wide.
|
|
2019
|
-
|
|
3236
|
+
// strips w wide. min_width = w grows every line narrower than w to w, so
|
|
3237
|
+
// a symbol drawn small can be cut.
|
|
3238
|
+
module symbol(name, size = 10, center = true, fill = "nonzero", box = "drawn", solid = false, close = undef, bridge = undef, min_width = undef) {
|
|
2020
3239
|
assert(box == "drawn" || box == "grid", "box is \\"drawn\\" or \\"grid\\"");
|
|
2021
3240
|
s = symbol_entry(name);
|
|
2022
3241
|
vb = box == "grid" ? s[5] : s[2];
|
|
2023
3242
|
k = size / max(vb[2], vb[3]);
|
|
2024
|
-
module
|
|
3243
|
+
module art() translate(center ? [0, 0] : [vb[2] * k / 2, vb[3] * k / 2])
|
|
2025
3244
|
scale([k, -k]) translate([-vb[0] - vb[2] / 2, -vb[1] - vb[3] / 2])
|
|
2026
3245
|
path(s[4], fill = fill, close = true);
|
|
3246
|
+
// With min_width, every line narrower than it grows to it: what an
|
|
3247
|
+
// opening by that width removes, grown by half of it either side
|
|
3248
|
+
module drawn() if (is_undef(min_width) || min_width <= 0) art();
|
|
3249
|
+
else union() {
|
|
3250
|
+
art();
|
|
3251
|
+
offset(r = min_width / 2) difference() {
|
|
3252
|
+
art();
|
|
3253
|
+
offset(r = min_width / 2) offset(r = -min_width / 2) art();
|
|
3254
|
+
}
|
|
3255
|
+
}
|
|
2027
3256
|
r = is_undef(close) ? size / 30 : close;
|
|
2028
3257
|
module silhouette() if (is_undef(bridge)) fill_holes() close(r) drawn();
|
|
2029
3258
|
else join_islands(bridge) fill_holes() close(r) drawn();
|
|
@@ -3014,10 +4243,10 @@ module tab_rect(size, edges = true, count = undef, width = undef) {
|
|
|
3014
4243
|
if (e[2]) translate([w, h]) rotate(180) tabs(w, count, width);
|
|
3015
4244
|
if (e[3]) translate([0, h]) rotate(270) tabs(h, count, width);
|
|
3016
4245
|
}
|
|
3017
|
-
`};var P="0.3";var
|
|
3018
|
-
`));c.update(`${
|
|
3019
|
-
`};async function
|
|
3020
|
-
`)&&
|
|
3021
|
-
`)&&(0,
|
|
3022
|
-
`);try{return await
|
|
3023
|
-
`));let
|
|
4246
|
+
`};var P="0.3";var M="kerf.json",C="kerf.lock",k="kerf_libraries",x=20<<20,I=2e3,N=/^[a-z0-9][a-z0-9_-]{0,63}$/,k1=/^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?$/,L1=/^(readme|licen[cs]e|copying|notice|changelog)(\.[a-z]+)?$/i,R=class extends Error{},U=l=>{try{return(0,u.statSync)(l).isFile()}catch{return!1}},V=l=>{try{return(0,u.statSync)(l).isDirectory()}catch{return!1}},S=(l,c)=>l&&Object.prototype.hasOwnProperty.call(l,c)?l[c]:void 0,v=l=>{throw new R(l)};function s1(l,c){return(typeof l!="string"||!N.test(l))&&v(`${c} "${l}" is not a library name: use lowercase letters, digits, - and _`),l==="kerf"&&v(`${c}: "kerf" is the standard library's name`),l}function Y(l,c){(!l||typeof l!="object"||Array.isArray(l))&&v(`${c} must hold a JSON object`);let a=l;for(let e of["name","version","description","license","language"])a[e]!==void 0&&typeof a[e]!="string"&&v(`${c}: "${e}" must be a string`);a.name!==void 0&&s1(a.name,`${c}: name`),a.version!==void 0&&!k1.test(a.version)&&v(`${c}: "version" must look like 1.2.0, not "${a.version}"`),a.language!==void 0&&!/^\d+\.\d+$/.test(a.language)&&v(`${c}: "language" must look like ${P}, not "${a.language}"`),a.sheet!==void 0&&!(Array.isArray(a.sheet)&&a.sheet.length===2&&a.sheet.every(e=>typeof e=="number"&&Number.isFinite(e)&&e>0))&&v(`${c}: "sheet" must be [width, height] in mm, like [600, 400]`);let n=a.libraries??{};(!n||typeof n!="object"||Array.isArray(n))&&v(`${c}: "libraries" must be an object of name: source`);for(let[e,t]of Object.entries(n))s1(e,`${c}: library`),typeof t!="string"&&v(`${c}: the source of ${e} must be a string`);return{...a,libraries:{...n}}}function Q(l,c){let a;try{a=(0,u.readFileSync)(l,"utf8")}catch{return v(`${c} was not found`)}try{return JSON.parse(a)}catch(n){return v(`${c} is not valid JSON: ${n.message}`)}}function H(l,c=M){return Y(Q((0,d.join)(l,M),c),c)}function J(l){if(!(0,u.existsSync)((0,d.join)(l,C)))return;let c=Q((0,d.join)(l,C),C);(c?.lockVersion!==1||!c.libraries||typeof c.libraries!="object")&&v(`${C} is not a kerf.lock this kerf can read. Delete it and run kerf install.`);for(let[a,n]of Object.entries(c.libraries))(!n||["source","resolved","integrity"].some(e=>typeof n[e]!="string"))&&v(`${C}: the entry for ${a} is damaged. Remove it and run kerf install.`);return c}function X(l){for(let c=(0,d.resolve)(l);;){if(U((0,d.join)(c,M)))return c;let a=(0,d.dirname)(c);if(a===c)return;c=a}}function c1(l){try{return H(l).name}catch{return}}function o1(l,c,a=U){let n=(s,i)=>[(0,d.join)(s,i),(0,d.join)(s,i+".kerf")].find(r=>a(r));if((0,d.isAbsolute)(c))return[c,c+".kerf"].find(s=>a(s));let e=c.indexOf("/"),t=e>0?X(l):void 0;if(t){let s=c.slice(0,e);if(s===c1(t))return n(t,c.slice(e+1));if(V((0,d.join)(t,k,s)))return n((0,d.join)(t,k),c)}return n(l,c)}function A1(l){let c=(0,d.dirname)((0,d.resolve)(l));return a=>{let n=o1(c,a);return n===void 0?void 0:(0,u.readFileSync)(n,"utf8")}}function C1(l,c=200){let a=X(l);if(!a)return[];let n=[],e=(i,r)=>{for(let o of[...m1(i,3)].sort()){if(n.length>=c)return;o.endsWith(".kerf")&&n.push(r+o.slice(0,-5))}},t=c1(a);t&&e(a,t+"/");let s=(0,d.join)(a,k);if(V(s))for(let i of(0,u.readdirSync)(s).sort())N.test(i)&&V((0,d.join)(s,i))&&e((0,d.join)(s,i),i+"/");return n}function m1(l,c=1/0){let a=[],n=(e,t,s)=>{let i;try{i=(0,u.readdirSync)(e,{withFileTypes:!0})}catch{return}for(let r of i){if(r.name.startsWith(".")||r.name==="node_modules"||r.name===k)continue;let o=t?`${t}/${r.name}`:r.name;r.isDirectory()?s<c&&n((0,d.join)(e,r.name),o,s+1):r.isFile()&&(a.push(o),a.length>I&&v(`${l} has more than ${I} files`))}};return n(l,"",0),a}function O(l,c=()=>!0){let a=new Map;for(let n of m1(l))c(n)&&a.set(n,(0,u.readFileSync)((0,d.join)(l,...n.split("/"))));return a}var a1=l=>l===M||l.endsWith(".kerf")||!l.includes("/")&&L1.test(l);function T(l){let c=(0,h1.createHash)("sha256");for(let a of[...l.keys()].sort()){let n=Buffer.from(l.get(a).toString("utf8").replace(/\r\n/g,`
|
|
4247
|
+
`));c.update(`${a}\0${n.length}\0`),c.update(n)}return"sha256-"+c.digest("base64")}function i1(l){return l.kind==="folder"?"folder:"+(process.platform==="win32"?l.path.toLowerCase():l.path):l.kind==="github"?`github:${l.owner}/${l.repo}`.toLowerCase()+`@${l.ref}`:l.url}function E(l,c){let a=/^github:([\w.-]+)\/([\w.-]+?)(?:\.git)?(?:@(\S+))?$/.exec(l);if(a)return{kind:"github",owner:a[1],repo:a[2],ref:a[3]??"HEAD"};if(/^https?:\/\//i.test(l)){let e;try{e=new URL(l)}catch{return v(`${l} is not a link`)}return e.protocol==="http:"&&!["localhost","127.0.0.1","[::1]"].includes(e.hostname)&&v(`Use https:// to download ${l}`),{kind:"url",url:l}}let n=l.startsWith("file:")?l.slice(5):l;return n.startsWith("./")||n.startsWith("../")||(0,d.isAbsolute)(n)?{kind:"folder",path:(0,d.resolve)(c,n)}:v(`"${l}" is not a library source. Use github:owner/repo@tag, an https:// link to a .tar.gz, or a folder like ./my-library`)}async function H1(l,c){let a;try{a=await c(l)}catch(i){let r=i;return v(`Could not download ${l}: ${r.cause?.message??r.message}`)}a.ok||v(`Could not download ${l}: HTTP ${a.status}`+(a.status===404?". Check the name and the tag, and that it is public.":""));let n=()=>v(`${l} is larger than ${x>>20} MB`);if(Number(a.headers?.get("content-length"))>x&&n(),!a.body){let i=Buffer.from(await a.arrayBuffer());return i.length>x?n():i}let e=a.body.getReader(),t=[],s=0;for(;;){let{done:i,value:r}=await e.read();if(i||!r)break;s+=r.length,s>x&&(await e.cancel().catch(()=>{}),n()),t.push(r)}return Buffer.concat(t)}function V1(l,c){let a;try{a=(0,Z.gunzipSync)(l,{maxOutputLength:5*x})}catch{return v(`${c} is not a .tar.gz file`)}let n=new Map,e,t={},s;for(let i=0;i+512<=a.length;){let r=a.subarray(i,i+512);if(r.every(b=>b===0))break;let o=(b,L)=>{let y=r.subarray(b,b+L),_=y.indexOf(0);return y.subarray(0,_<0?L:_).toString("utf8")},f=parseInt(o(124,12).trim()||"0",8);f>=0||v(`${c} is damaged`);let p=o(156,1)||"0",h=a.subarray(i+512,i+512+f);if(i+=512+Math.ceil(f/512)*512,p==="x"||p==="g"){let b=_1(h);p==="g"?e=b.comment??e:t=b;continue}if(p==="L"){s=h.toString("utf8").replace(/\0+$/,"");continue}let m=o(345,155),g=t.path??s??(m?m+"/":"")+o(0,100);t={},s=void 0,(p==="0"||p==="7")&&n.set(g,Buffer.from(h)),n.size>I&&v(`${c} has more than ${I} files`)}return{files:n,commit:e}}function _1(l){let c={};for(let a=0;a<l.length;){let n=l.indexOf(32,a),e=parseInt(l.subarray(a,n).toString(),10);if(!(e>0)||n<0)break;let t=l.subarray(n+1,a+e-1).toString("utf8"),s=t.indexOf("=");s>0&&(c[t.slice(0,s)]=t.slice(s+1)),a+=e}return c}function r1(l,c){let a=new Map;for(let[t,s]of l){let i=t.replace(/^\.\//,""),r=i.split("/");((0,d.isAbsolute)(i)||i.includes("\\")||i.includes(":")||r.some(o=>o===".."||o===""))&&v(`${c} holds a file outside its folder: ${t}`),a.set(i,s)}let n="";if(!a.has(M)){let t=new Set([...a.keys()].map(s=>s.split("/")[0]));t.size===1&&(n=[...t][0]+"/")}let e=new Map;for(let[t,s]of a){if(!t.startsWith(n))continue;let i=t.slice(n.length);i.split("/").some(r=>r.startsWith(".")||r===k||r==="node_modules")||a1(i)&&e.set(i,s)}return e.has(M)||v(`${c} has no kerf.json at its top. Is it a KerfScript library?`),e}var q1=(l,c)=>{let[a,n]=l.split(".").map(Number),[e,t]=c.split(".").map(Number);return a>e||a===e&&n>t};async function d1(l,c,a,n,e){let t=E(l,c),s,i;if(t.kind==="folder")U((0,d.join)(t.path,M))||v(`${l}: no kerf.json in ${t.path}. Is it a KerfScript library?`),s=r1(O(t.path,a1),l),i=(0,d.relative)(a,t.path).split(d.sep).join("/")||".",!i.startsWith(".")&&!(0,d.isAbsolute)(i)&&(i="./"+i);else{let o=t.kind==="github"?`https://github.com/${t.owner}/${t.repo}/archive/${t.ref}.tar.gz`:t.url,f=e.get(o)??await H1(o,n);e.set(o,f);let p=V1(f,l);s=r1(p.files,l),i=t.kind==="github"&&/^[0-9a-f]{40}$/.test(p.commit??"")?`https://github.com/${t.owner}/${t.repo}/archive/${p.commit}.tar.gz`:o}let r=Y(JSON.parse(s.get(M).toString("utf8")),`the kerf.json of ${l}`);return r.name||v(`${l}: its kerf.json has no "name", so it is not a library`),r.language&&q1(r.language,P)&&v(`${r.name} needs KerfScript language ${r.language} or later, and this kerf has ${P}. Update kerf.`),{manifest:r,files:s,resolved:i,integrity:T(s)}}function x1(l,c){(0,u.rmSync)(l,{recursive:!0,force:!0});for(let[a,n]of c){let e=(0,d.join)(l,...a.split("/"));(0,u.mkdirSync)((0,d.dirname)(e),{recursive:!0}),(0,u.writeFileSync)(e,n)}}var S1=l=>{let c=[...l].sort(([a],[n])=>a<n?-1:1);return JSON.stringify({lockVersion:1,libraries:Object.fromEntries(c)},null,2)+`
|
|
4248
|
+
`};async function f1(l,c={}){let a=c.fetch??globalThis.fetch,n=c.log??(()=>{}),e=c.cache??new Map,t=H(l),s=J(l),i=new Map,r=Object.entries(t.libraries).map(([h,m])=>({name:h,source:m,base:l,from:M})),o=(0,d.join)(l,k);for(;r.length;){let{name:h,source:m,base:g,from:b}=r.shift(),L=E(m,g),y=L.kind==="folder",_=y?`${m} (${L.path})`:m,j=i.get(h);if(j){j.at!==i1(L)&&!S(t.libraries,h)&&v(`${b} uses ${h} from ${_}, and ${j.from} uses it from ${j.shown}. Add ${h} to kerf.json with the source to use.`);continue}let G=S(s?.libraries,h),w=G?.source===m&&(!y||(0,d.resolve)(l,G.resolved)===L.path)?G:void 0;c.frozen&&!w&&v(`kerf.lock does not pin ${h} from ${m}. Run kerf install without --frozen.`);let $=(0,d.join)(o,h),q;if(w&&!y&&V($)&&T(O($))===w.integrity)q=w;else{let z=await d1(w&&!y?w.resolved:m,y?g:l,l,a,e);z.manifest.name!==h&&v(`${m} is the library "${z.manifest.name}", so ${b} must call it ${z.manifest.name}, not ${h}`),w&&z.integrity!==w.integrity&&(!y||c.frozen)&&v(y?`${h} in ${m} changed since kerf.lock pinned it. Run kerf install without --frozen.`:`${h} from ${w.resolved} no longer matches kerf.lock. If you trust the change, remove ${h} from kerf.lock and run kerf install again.`),x1($,z.files),q={source:m,...z.manifest.version?{version:z.manifest.version}:{},resolved:z.resolved,integrity:z.integrity},(!w||w.integrity!==z.integrity||!y)&&n(`${w?"Restored":"Installed"} ${h}${q.version?" "+q.version:""} from ${m}`)}i.set(h,{entry:q,at:i1(L),shown:_,from:b});let l1=L.kind==="folder"?L.path:void 0;for(let[z,F]of Object.entries(H($,`${k}/${h}/${M}`).libraries))E(F,l).kind==="folder"&&!l1&&v(`${h} uses ${z} from the folder ${F}: a published library needs github: or https: sources`),r.push({name:z,source:F,base:l1??l,from:h})}let f=S1(new Map([...i].map(([h,m])=>[h,m.entry]))),p=(0,u.existsSync)((0,d.join)(l,C))?(0,u.readFileSync)((0,d.join)(l,C),"utf8"):"";if(c.frozen&&f!==p.replace(/\r\n/g,`
|
|
4249
|
+
`)&&v("kerf.lock is out of date. Run kerf install without --frozen."),V(o))for(let h of(0,u.readdirSync)(o,{withFileTypes:!0}))h.isDirectory()&&N.test(h.name)&&!i.has(h.name)&&((0,u.rmSync)((0,d.join)(o,h.name),{recursive:!0,force:!0}),n(`Removed ${h.name}`));return f!==p.replace(/\r\n/g,`
|
|
4250
|
+
`)&&(0,u.writeFileSync)((0,d.join)(l,C),f),JSON.parse(f)}function T1(l){let c=H(l),a=J(l),n=Object.keys(c.libraries);if(!a)return n.length?["kerf.lock is missing. Run kerf install."]:[];let e=[],t=new Set,s=[...n];for(;s.length;){let i=s.shift();if(t.has(i))continue;t.add(i);let r=S(a.libraries,i);if(!r){e.push(`${i} is not in kerf.lock. Run kerf install.`);continue}n.includes(i)&&r.source!==c.libraries[i]&&e.push(`kerf.json takes ${i} from ${c.libraries[i]}, and kerf.lock from ${r.source}. Run kerf install.`);let o=(0,d.join)(l,k,i);if(!V(o)){e.push(`${i} is not in ${k}. Run kerf install.`);continue}T(O(o))!==r.integrity&&e.push(`The files in ${k}/${i} differ from kerf.lock. Run kerf install.`);try{s.push(...Object.keys(H(o).libraries))}catch(f){e.push(f.message)}}for(let i of Object.keys(a.libraries))t.has(i)||e.push(`kerf.lock pins ${i}, which nothing uses any more.`);return e}function j1(l,c){let a=(0,d.join)(l,M),n=(0,u.existsSync)(a)?Q(a,M):{};Y(n,M);let e={...n.libraries??{}};return c(e),n.libraries=e,{file:a,before:(0,u.existsSync)(a)?(0,u.readFileSync)(a,"utf8"):void 0,raw:n}}async function v1(l,c,a){let{file:n,before:e,raw:t}=j1(l,c);(0,u.writeFileSync)(n,JSON.stringify(t,null,2)+`
|
|
4251
|
+
`);try{return await f1(l,a)}catch(s){throw e===void 0?(0,u.rmSync)(n,{force:!0}):(0,u.writeFileSync)(n,e),s}}async function $1(l,c,a={}){let n=new Map,t=(await d1(c,l,l,a.fetch??globalThis.fetch,n)).manifest.name;t===c1(l)&&v(`This project is the library ${t}; it cannot use itself`);let s=await v1(l,i=>void(i[t]=c),{...a,cache:n});return{name:t,lock:s}}async function P1(l,c,a={}){return v1(l,n=>{S(n,c)===void 0&&v(`kerf.json has no library named ${c}`),delete n[c]},a)}function W(l,c=[]){if(Array.isArray(l))for(let a of l)W(a,c);else if(l&&typeof l=="object"){let a=l;if(a.kind==="use"&&typeof a.path=="string")c.push({path:a.path,line:a.pos.line});else for(let n of Object.values(a))W(n,c)}return c}function I1(l){let c=[];for(let[a,n]of l){let e=Buffer.alloc(512),t=a,s="";if(Buffer.byteLength(t)>100){let r=a.lastIndexOf("/",155);(r<0||Buffer.byteLength(a.slice(r+1))>100)&&v(`${a}: the path is too long to pack`),s=a.slice(0,r),t=a.slice(r+1)}e.write(t,0,100),e.write("0000644\0",100),e.write("0000000\0",108),e.write("0000000\0",116),e.write(n.length.toString(8).padStart(11,"0")+"\0",124),e.write("00000000000\0",136),e.fill(32,148,156),e.write("0",156),e.write("ustar\0",257),e.write("00",263),e.write(s,345,155);let i=0;for(let r of e)i+=r;e.write(i.toString(8).padStart(6,"0")+"\0 ",148),c.push(e,n,Buffer.alloc((512-n.length%512)%512))}return c.push(Buffer.alloc(1024)),(0,Z.gzipSync)(Buffer.concat(c),{level:9})}function R1(l,c){let a=H(l),n=a.name??v('kerf.json needs a "name" to pack a library'),e=a.version??v('kerf.json needs a "version", like 1.0.0'),t=O(l,a1),s=[];for(let[f,p]of Object.entries(a.libraries))E(p,l).kind==="folder"&&s.push(`kerf.json: ${f} comes from a folder; a published library needs github: or https: sources`);let i=f=>t.has(f)||t.has(f+".kerf");for(let[f,p]of t){if(!f.endsWith(".kerf"))continue;let h;try{h=n1(p.toString("utf8"),`${n}/${f}`).program}catch(m){s.push(`${f}: ${m.message}`);continue}for(let m of W(h)){let g=m.path.split("/")[0];Object.prototype.hasOwnProperty.call(t1,m.path)||g===n&&i(m.path.slice(n.length+1))||m.path.includes("/")&&S(a.libraries,g)!==void 0||s.push(`${f}, line ${m.line}: <${m.path}> will not be found once the library is installed`+(i(m.path)?`. Write <${n}/${m.path}> for the library's own file.`:"."))}}[...t.keys()].some(f=>f.endsWith(".kerf"))||s.push("There are no .kerf files to pack"),s.length&&v(s.join(`
|
|
4252
|
+
`));let r=[...t.keys()].sort().map(f=>[`${n}/${f}`,t.get(f)]),o=c??(0,d.join)(l,`${n}-${e}.tar.gz`);return(0,u.writeFileSync)(o,I1(r)),{file:o,name:n,version:e,files:t.size,integrity:T(t)}}0&&(module.exports={FOLDER,LOCK,LibraryError,MANIFEST,add,check,findProject,install,installedPaths,integrity,libraryFile,pack,readLock,readManifest,remove,resolver});
|