@mylasertools/kerfscript 0.4.0 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +125 -1
- package/LANGUAGE.md +26 -11
- package/README.md +79 -5
- package/dist/ast.d.cts +13 -1
- package/dist/ast.d.ts +13 -1
- package/dist/cli.js +7509 -1629
- package/dist/diagnostics.d.cts +6 -0
- package/dist/diagnostics.d.ts +6 -0
- package/dist/evaluator.d.cts +12 -0
- package/dist/evaluator.d.ts +12 -0
- package/dist/format.d.cts +4 -0
- package/dist/format.d.ts +4 -0
- package/dist/highlight.cjs +151 -0
- package/dist/highlight.d.cts +13 -0
- package/dist/highlight.d.ts +13 -0
- package/dist/highlight.js +131 -0
- package/dist/import/dbg.d.cts +1 -0
- package/dist/import/dbg.d.ts +1 -0
- package/dist/import/index.d.cts +16 -0
- package/dist/import/index.d.ts +16 -0
- package/dist/import/shapes.d.cts +76 -0
- package/dist/import/shapes.d.ts +76 -0
- package/dist/import/svg.d.cts +48 -0
- package/dist/import/svg.d.ts +48 -0
- package/dist/import/xml.d.cts +12 -0
- package/dist/import/xml.d.ts +12 -0
- package/dist/index.cjs +391 -13
- package/dist/index.d.cts +7 -3
- package/dist/index.d.ts +7 -3
- package/dist/index.js +391 -13
- package/dist/language.cjs +417 -0
- package/dist/language.d.cts +143 -0
- package/dist/language.d.ts +143 -0
- package/dist/language.js +417 -0
- package/dist/lexer.d.cts +17 -0
- package/dist/lexer.d.ts +17 -0
- package/dist/libraries.cjs +380 -0
- package/dist/libraries.d.cts +112 -0
- package/dist/libraries.d.ts +112 -0
- package/dist/libraries.js +380 -0
- package/dist/lsp.d.cts +12 -0
- package/dist/lsp.d.ts +12 -0
- package/dist/paths.d.cts +1 -1
- package/dist/paths.d.ts +1 -1
- package/dist/signatures.cjs +675 -0
- package/dist/signatures.d.cts +20 -0
- package/dist/signatures.d.ts +20 -0
- package/dist/signatures.js +655 -0
- package/docs/cli.md +54 -2
- package/docs/desktop.md +5 -0
- package/docs/editors.md +121 -0
- package/docs/import.md +149 -0
- package/docs/javascript.md +177 -10
- package/docs/kerf.md +10 -0
- package/docs/library/box.svg +11 -0
- package/docs/library/calibration.svg +11 -0
- package/docs/library/dividers.svg +11 -0
- package/docs/library/enclosure.svg +11 -0
- package/docs/library/hanging.svg +11 -0
- package/docs/library/hinge.svg +11 -0
- package/docs/library/tabs.svg +11 -0
- package/docs/library.md +339 -0
- package/docs/mcp.md +88 -0
- package/docs/openscad.md +1 -1
- package/docs/shared-libraries.md +229 -0
- package/docs/specification.md +529 -0
- package/docs/versions.md +2 -2
- package/package.json +52 -6
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export interface ParamInfo {
|
|
2
|
+
name: string;
|
|
3
|
+
default?: string;
|
|
4
|
+
named?: boolean;
|
|
5
|
+
doc?: string;
|
|
6
|
+
}
|
|
7
|
+
export interface Signature {
|
|
8
|
+
name: string;
|
|
9
|
+
kind: 'module' | 'function' | 'both';
|
|
10
|
+
params: ParamInfo[];
|
|
11
|
+
rest?: boolean;
|
|
12
|
+
anyNamed?: boolean;
|
|
13
|
+
children?: boolean;
|
|
14
|
+
forms?: string[];
|
|
15
|
+
section: string;
|
|
16
|
+
doc: string;
|
|
17
|
+
}
|
|
18
|
+
export declare const SIGNATURES: Signature[];
|
|
19
|
+
export declare const signature: (name: string) => Signature | undefined;
|
|
20
|
+
export declare function formatSignature(s: Signature): string;
|
|
@@ -0,0 +1,655 @@
|
|
|
1
|
+
/*! @mylasertools/kerfscript/signatures | (c) MyLaserTools | AGPL-3.0-only or commercial licence */
|
|
2
|
+
|
|
3
|
+
// src/signatures.ts
|
|
4
|
+
var p = (name, doc, def) => ({
|
|
5
|
+
name,
|
|
6
|
+
...def !== void 0 && { default: def },
|
|
7
|
+
...doc && { doc }
|
|
8
|
+
});
|
|
9
|
+
var named = (name, doc, def) => ({
|
|
10
|
+
...p(name, doc, def),
|
|
11
|
+
named: true
|
|
12
|
+
});
|
|
13
|
+
var FINGER = "max(3 * $thickness, 6)";
|
|
14
|
+
var value = [p("value")];
|
|
15
|
+
var x = [p("x")];
|
|
16
|
+
var math = (name, doc) => ({
|
|
17
|
+
name,
|
|
18
|
+
kind: "function",
|
|
19
|
+
params: x,
|
|
20
|
+
section: "Numbers and vectors",
|
|
21
|
+
doc
|
|
22
|
+
});
|
|
23
|
+
var is = (name, type) => ({
|
|
24
|
+
name,
|
|
25
|
+
kind: "function",
|
|
26
|
+
params: value,
|
|
27
|
+
section: "Types",
|
|
28
|
+
doc: `Whether the value is ${type}`
|
|
29
|
+
});
|
|
30
|
+
var text = (name, doc) => ({
|
|
31
|
+
name,
|
|
32
|
+
kind: "function",
|
|
33
|
+
params: [
|
|
34
|
+
p("text", "The text to measure", '""'),
|
|
35
|
+
p("size", "Font size in millimetres", "10"),
|
|
36
|
+
p("font", "Font name", "$font"),
|
|
37
|
+
named("halign", "left, center or right", '"left"'),
|
|
38
|
+
named("valign", "baseline, top, center or bottom", '"baseline"'),
|
|
39
|
+
named("spacing", "Letter spacing factor", "1")
|
|
40
|
+
],
|
|
41
|
+
section: "Text measurements",
|
|
42
|
+
doc
|
|
43
|
+
});
|
|
44
|
+
var SIGNATURES = [
|
|
45
|
+
// Shapes
|
|
46
|
+
{
|
|
47
|
+
name: "rect",
|
|
48
|
+
kind: "module",
|
|
49
|
+
params: [
|
|
50
|
+
p("size", "A number, or [width, height]", "1"),
|
|
51
|
+
p("center", "Centre the rectangle on the origin instead of its corner", "false"),
|
|
52
|
+
named("r", "Corner radius", "0")
|
|
53
|
+
],
|
|
54
|
+
section: "Shapes",
|
|
55
|
+
doc: "A rectangle with its corner at the origin"
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
name: "square",
|
|
59
|
+
kind: "module",
|
|
60
|
+
params: [
|
|
61
|
+
p("size", "A number, or [width, height]", "1"),
|
|
62
|
+
p("center", "Centre the square on the origin instead of its corner", "false"),
|
|
63
|
+
named("r", "Corner radius", "0")
|
|
64
|
+
],
|
|
65
|
+
section: "Shapes",
|
|
66
|
+
doc: "Another name for rect()"
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
name: "circle",
|
|
70
|
+
kind: "module",
|
|
71
|
+
params: [p("r", "Radius", "1"), named("d", "Diameter, instead of r")],
|
|
72
|
+
section: "Shapes",
|
|
73
|
+
doc: "A circle centred on the origin"
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
name: "ellipse",
|
|
77
|
+
kind: "module",
|
|
78
|
+
params: [p("r", "[rx, ry], or one radius for both", "1")],
|
|
79
|
+
section: "Shapes",
|
|
80
|
+
doc: "An ellipse centred on the origin"
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
name: "regular_polygon",
|
|
84
|
+
kind: "module",
|
|
85
|
+
params: [p("n", "Number of corners", "6"), p("r", "Distance to the corners", "10")],
|
|
86
|
+
section: "Shapes",
|
|
87
|
+
doc: "A regular polygon centred on the origin"
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
name: "star",
|
|
91
|
+
kind: "module",
|
|
92
|
+
params: [
|
|
93
|
+
p("n", "Number of points", "5"),
|
|
94
|
+
p("r", "Radius of the points", "10"),
|
|
95
|
+
p("inner", "Radius between the points", "r * 0.45")
|
|
96
|
+
],
|
|
97
|
+
section: "Shapes",
|
|
98
|
+
doc: "A star centred on the origin"
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
name: "polygon",
|
|
102
|
+
kind: "module",
|
|
103
|
+
params: [
|
|
104
|
+
p("points", "A list of [x, y] points"),
|
|
105
|
+
p("paths", "Lists of point indexes, one per outline; holes come from even-odd fill")
|
|
106
|
+
],
|
|
107
|
+
section: "Shapes",
|
|
108
|
+
doc: "A shape from a list of points"
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
name: "path",
|
|
112
|
+
kind: "module",
|
|
113
|
+
params: [
|
|
114
|
+
p("d", 'SVG path data, as "M0 0 L10 0 L5 8 Z"'),
|
|
115
|
+
named("fill", '"evenodd" or "nonzero"', '"evenodd"')
|
|
116
|
+
],
|
|
117
|
+
section: "Shapes",
|
|
118
|
+
doc: "Shapes from SVG path data: closed subpaths become areas, open ones lines"
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
name: "text",
|
|
122
|
+
kind: "module",
|
|
123
|
+
params: [
|
|
124
|
+
p("text", "The text", '""'),
|
|
125
|
+
p("size", "Font size in millimetres", "10"),
|
|
126
|
+
p("font", "Font name", "$font"),
|
|
127
|
+
named("halign", "left, center or right", '"left"'),
|
|
128
|
+
named("valign", "baseline, top, center or bottom", '"baseline"'),
|
|
129
|
+
named("spacing", "Letter spacing factor", "1")
|
|
130
|
+
],
|
|
131
|
+
section: "Shapes",
|
|
132
|
+
doc: "Text as shapes; the font must be available to the renderer"
|
|
133
|
+
},
|
|
134
|
+
{
|
|
135
|
+
name: "line",
|
|
136
|
+
kind: "module",
|
|
137
|
+
params: [p("from", "Start point", "[0, 0]"), p("to", "End point", "[10, 0]")],
|
|
138
|
+
section: "Shapes",
|
|
139
|
+
doc: "A straight line, not an area"
|
|
140
|
+
},
|
|
141
|
+
{
|
|
142
|
+
name: "polyline",
|
|
143
|
+
kind: "module",
|
|
144
|
+
params: [
|
|
145
|
+
p("points", "A list of [x, y] points"),
|
|
146
|
+
p("closed", "Join the last point to the first", "false")
|
|
147
|
+
],
|
|
148
|
+
section: "Shapes",
|
|
149
|
+
doc: "Lines through a list of points"
|
|
150
|
+
},
|
|
151
|
+
{
|
|
152
|
+
name: "arc",
|
|
153
|
+
kind: "module",
|
|
154
|
+
params: [
|
|
155
|
+
p("r", "Radius", "10"),
|
|
156
|
+
p("start", "Start angle in degrees", "0"),
|
|
157
|
+
p("end", "End angle in degrees", "90")
|
|
158
|
+
],
|
|
159
|
+
section: "Shapes",
|
|
160
|
+
doc: "An arc line around the origin"
|
|
161
|
+
},
|
|
162
|
+
// Transforms
|
|
163
|
+
{
|
|
164
|
+
name: "translate",
|
|
165
|
+
kind: "module",
|
|
166
|
+
params: [p("v", "[x, y]", "[0, 0]")],
|
|
167
|
+
children: true,
|
|
168
|
+
section: "Transforms",
|
|
169
|
+
doc: "Move the children by x and y"
|
|
170
|
+
},
|
|
171
|
+
{
|
|
172
|
+
name: "rotate",
|
|
173
|
+
kind: "module",
|
|
174
|
+
params: [
|
|
175
|
+
p("a", "Angle in degrees, anticlockwise", "0"),
|
|
176
|
+
named("center", "The point to turn around, [x, y]")
|
|
177
|
+
],
|
|
178
|
+
children: true,
|
|
179
|
+
section: "Transforms",
|
|
180
|
+
doc: "Rotate the children around the origin or a point"
|
|
181
|
+
},
|
|
182
|
+
{
|
|
183
|
+
name: "scale",
|
|
184
|
+
kind: "module",
|
|
185
|
+
params: [p("v", "One factor, or [sx, sy]", "1")],
|
|
186
|
+
children: true,
|
|
187
|
+
section: "Transforms",
|
|
188
|
+
doc: "Scale the children"
|
|
189
|
+
},
|
|
190
|
+
{
|
|
191
|
+
name: "mirror",
|
|
192
|
+
kind: "module",
|
|
193
|
+
params: [p("v", "[nx, ny], perpendicular to the mirror line", "[1, 0]")],
|
|
194
|
+
children: true,
|
|
195
|
+
section: "Transforms",
|
|
196
|
+
doc: "Reflect the children across a line through the origin"
|
|
197
|
+
},
|
|
198
|
+
{
|
|
199
|
+
name: "multmatrix",
|
|
200
|
+
kind: "module",
|
|
201
|
+
params: [p("m", "A 2 \xD7 3 or 3 \xD7 3 matrix")],
|
|
202
|
+
children: true,
|
|
203
|
+
section: "Transforms",
|
|
204
|
+
doc: "Apply a transformation matrix to the children"
|
|
205
|
+
},
|
|
206
|
+
// Combining
|
|
207
|
+
{
|
|
208
|
+
name: "union",
|
|
209
|
+
kind: "module",
|
|
210
|
+
params: [],
|
|
211
|
+
children: true,
|
|
212
|
+
section: "Combining",
|
|
213
|
+
doc: "Join the children"
|
|
214
|
+
},
|
|
215
|
+
{
|
|
216
|
+
name: "group",
|
|
217
|
+
kind: "module",
|
|
218
|
+
params: [],
|
|
219
|
+
children: true,
|
|
220
|
+
section: "Combining",
|
|
221
|
+
doc: "Another name for union()"
|
|
222
|
+
},
|
|
223
|
+
{
|
|
224
|
+
name: "difference",
|
|
225
|
+
kind: "module",
|
|
226
|
+
params: [],
|
|
227
|
+
children: true,
|
|
228
|
+
section: "Combining",
|
|
229
|
+
doc: "Remove every later child's area from every layer of the first child"
|
|
230
|
+
},
|
|
231
|
+
{
|
|
232
|
+
name: "intersection",
|
|
233
|
+
kind: "module",
|
|
234
|
+
params: [],
|
|
235
|
+
children: true,
|
|
236
|
+
section: "Combining",
|
|
237
|
+
doc: "Keep only the area common to all children"
|
|
238
|
+
},
|
|
239
|
+
{
|
|
240
|
+
name: "hull",
|
|
241
|
+
kind: "module",
|
|
242
|
+
params: [],
|
|
243
|
+
children: true,
|
|
244
|
+
section: "Combining",
|
|
245
|
+
doc: "The convex hull of the children; each part inside gets its own"
|
|
246
|
+
},
|
|
247
|
+
{
|
|
248
|
+
name: "offset",
|
|
249
|
+
kind: "module",
|
|
250
|
+
params: [
|
|
251
|
+
p("r", "Grow (positive) or shrink areas with rounded corners"),
|
|
252
|
+
named("delta", "Grow or shrink areas with sharp corners", "0"),
|
|
253
|
+
named("chamfer", "Cut the corners off when growing by delta", "false")
|
|
254
|
+
],
|
|
255
|
+
children: true,
|
|
256
|
+
section: "Combining",
|
|
257
|
+
doc: "Grow or shrink the areas of the children"
|
|
258
|
+
},
|
|
259
|
+
{
|
|
260
|
+
name: "stroke",
|
|
261
|
+
kind: "module",
|
|
262
|
+
params: [p("width", "Width of the area around each line", "1")],
|
|
263
|
+
children: true,
|
|
264
|
+
section: "Combining",
|
|
265
|
+
doc: "Turn lines into areas, for cutting single-line art"
|
|
266
|
+
},
|
|
267
|
+
{
|
|
268
|
+
name: "outline",
|
|
269
|
+
kind: "module",
|
|
270
|
+
params: [],
|
|
271
|
+
children: true,
|
|
272
|
+
section: "Combining",
|
|
273
|
+
doc: "Turn areas into their outline lines"
|
|
274
|
+
},
|
|
275
|
+
// Layers and parts
|
|
276
|
+
{
|
|
277
|
+
name: "cut",
|
|
278
|
+
kind: "module",
|
|
279
|
+
params: [],
|
|
280
|
+
children: true,
|
|
281
|
+
section: "Layers",
|
|
282
|
+
doc: "Put the children on the cut layer"
|
|
283
|
+
},
|
|
284
|
+
{
|
|
285
|
+
name: "score",
|
|
286
|
+
kind: "module",
|
|
287
|
+
params: [],
|
|
288
|
+
children: true,
|
|
289
|
+
section: "Layers",
|
|
290
|
+
doc: "Put the children on the score layer: lines marked without cutting through"
|
|
291
|
+
},
|
|
292
|
+
{
|
|
293
|
+
name: "engrave",
|
|
294
|
+
kind: "module",
|
|
295
|
+
params: [],
|
|
296
|
+
children: true,
|
|
297
|
+
section: "Layers",
|
|
298
|
+
doc: "Put the children on the engrave layer: areas filled in"
|
|
299
|
+
},
|
|
300
|
+
{
|
|
301
|
+
name: "guide",
|
|
302
|
+
kind: "module",
|
|
303
|
+
params: [],
|
|
304
|
+
children: true,
|
|
305
|
+
section: "Layers",
|
|
306
|
+
doc: "Put the children on the guide layer, which is not cut"
|
|
307
|
+
},
|
|
308
|
+
{
|
|
309
|
+
name: "layer",
|
|
310
|
+
kind: "module",
|
|
311
|
+
params: [
|
|
312
|
+
p("name", "Layer name"),
|
|
313
|
+
p("mode", '"cut", "line", "fill" or "guide"'),
|
|
314
|
+
p("color", 'Colour in the output, as "#00aa00"')
|
|
315
|
+
],
|
|
316
|
+
children: true,
|
|
317
|
+
section: "Layers",
|
|
318
|
+
doc: "Put the children on a layer, defining it on first use"
|
|
319
|
+
},
|
|
320
|
+
{
|
|
321
|
+
name: "part",
|
|
322
|
+
kind: "module",
|
|
323
|
+
params: [
|
|
324
|
+
p("name", "Part name", '"part"'),
|
|
325
|
+
p("qty", "Number of copies to cut", "1"),
|
|
326
|
+
named("at", "Where the part goes in the assembled view, [x, y, z]"),
|
|
327
|
+
named("rotate", "How the part is turned in the assembled view, [x, y, z] in degrees")
|
|
328
|
+
],
|
|
329
|
+
children: true,
|
|
330
|
+
section: "Parts and sheets",
|
|
331
|
+
doc: "A named part, with its thickness, kerf and material"
|
|
332
|
+
},
|
|
333
|
+
{
|
|
334
|
+
name: "material",
|
|
335
|
+
kind: "module",
|
|
336
|
+
params: [
|
|
337
|
+
p("thickness", "Sets $thickness"),
|
|
338
|
+
p("kerf", "Sets $kerf"),
|
|
339
|
+
p("name", "Sets $material")
|
|
340
|
+
],
|
|
341
|
+
children: true,
|
|
342
|
+
section: "Parts and sheets",
|
|
343
|
+
doc: "Set the thickness, kerf and material name for the children"
|
|
344
|
+
},
|
|
345
|
+
// Joinery
|
|
346
|
+
{
|
|
347
|
+
name: "finger_rect",
|
|
348
|
+
kind: "module",
|
|
349
|
+
params: [
|
|
350
|
+
p("size", "[width, height]"),
|
|
351
|
+
p("edges", '"out", "in" or "flat", or [bottom, right, top, left]', '"out"'),
|
|
352
|
+
p("finger", "Finger width", FINGER)
|
|
353
|
+
],
|
|
354
|
+
section: "Joinery",
|
|
355
|
+
doc: "A rectangle with finger joints, notched $thickness deep"
|
|
356
|
+
},
|
|
357
|
+
{
|
|
358
|
+
name: "finger_holes",
|
|
359
|
+
kind: "module",
|
|
360
|
+
params: [
|
|
361
|
+
p("length", "Length of the edge that plugs in"),
|
|
362
|
+
p("edge", '"out" or "in", the kind of edge that plugs in', '"out"'),
|
|
363
|
+
p("finger", "Finger width", FINGER)
|
|
364
|
+
],
|
|
365
|
+
section: "Joinery",
|
|
366
|
+
doc: "A row of slots along x for a finger edge to plug into"
|
|
367
|
+
},
|
|
368
|
+
{
|
|
369
|
+
name: "tslot",
|
|
370
|
+
kind: "module",
|
|
371
|
+
params: [
|
|
372
|
+
p("d", "Screw diameter", "3"),
|
|
373
|
+
p("length", "Screw length into the panel", "12"),
|
|
374
|
+
p("nut", "Nut size, [width, height]", "[d * 1.85, d * 0.8]"),
|
|
375
|
+
p("nut_at", "Distance of the nut from the edge", "length / 2")
|
|
376
|
+
],
|
|
377
|
+
section: "Joinery",
|
|
378
|
+
doc: "A T-slot for a screw and nut, opening at y = 0; subtract it from a panel edge"
|
|
379
|
+
},
|
|
380
|
+
{
|
|
381
|
+
name: "living_hinge",
|
|
382
|
+
kind: "module",
|
|
383
|
+
params: [
|
|
384
|
+
p("size", "[width, height]"),
|
|
385
|
+
p("spacing", "Distance between the rows of cuts", "1.5"),
|
|
386
|
+
p("bridge", "Uncut length between cuts", "3"),
|
|
387
|
+
p("cut", "Length of each cut", "max(bridge * 2, (height - 3 * bridge) / 2)")
|
|
388
|
+
],
|
|
389
|
+
section: "Joinery",
|
|
390
|
+
doc: "A straight-line flex pattern of cut lines filling [width, height]"
|
|
391
|
+
},
|
|
392
|
+
// Other
|
|
393
|
+
{
|
|
394
|
+
name: "children",
|
|
395
|
+
kind: "module",
|
|
396
|
+
params: [p("index", "Which child, from 0, or a list of them")],
|
|
397
|
+
section: "Other",
|
|
398
|
+
doc: "Run the child statements passed to the current module"
|
|
399
|
+
},
|
|
400
|
+
{
|
|
401
|
+
name: "echo",
|
|
402
|
+
kind: "both",
|
|
403
|
+
params: [],
|
|
404
|
+
rest: true,
|
|
405
|
+
anyNamed: true,
|
|
406
|
+
section: "Other",
|
|
407
|
+
doc: "Write values to the output without making shapes"
|
|
408
|
+
},
|
|
409
|
+
{
|
|
410
|
+
name: "assert",
|
|
411
|
+
kind: "both",
|
|
412
|
+
params: [p("condition", "Stops the program when false"), p("message", "Says why")],
|
|
413
|
+
section: "Other",
|
|
414
|
+
doc: "Stop with an error when the condition is false"
|
|
415
|
+
},
|
|
416
|
+
// Numbers and vectors
|
|
417
|
+
math("abs", "Absolute value"),
|
|
418
|
+
math("sign", "Sign as -1, 0 or 1"),
|
|
419
|
+
math("floor", "Round down"),
|
|
420
|
+
math("ceil", "Round up"),
|
|
421
|
+
math("round", "Round to the nearest integer, halves away from zero"),
|
|
422
|
+
math("sqrt", "Square root"),
|
|
423
|
+
math("exp", "e raised to x"),
|
|
424
|
+
math("ln", "Natural logarithm"),
|
|
425
|
+
{
|
|
426
|
+
name: "log",
|
|
427
|
+
kind: "function",
|
|
428
|
+
params: [p("x"), p("base", void 0, "10")],
|
|
429
|
+
forms: ["log(x)", "log(base, x)"],
|
|
430
|
+
section: "Numbers and vectors",
|
|
431
|
+
doc: "Logarithm, base 10 or a chosen base; with two values the base comes first"
|
|
432
|
+
},
|
|
433
|
+
math("sin", "Sine of an angle in degrees"),
|
|
434
|
+
math("cos", "Cosine of an angle in degrees"),
|
|
435
|
+
math("tan", "Tangent of an angle in degrees"),
|
|
436
|
+
math("asin", "Inverse sine, in degrees"),
|
|
437
|
+
math("acos", "Inverse cosine, in degrees"),
|
|
438
|
+
math("atan", "Inverse tangent, in degrees"),
|
|
439
|
+
{
|
|
440
|
+
name: "atan2",
|
|
441
|
+
kind: "function",
|
|
442
|
+
params: [p("y"), p("x")],
|
|
443
|
+
section: "Numbers and vectors",
|
|
444
|
+
doc: "The angle of the point [x, y] from the x axis, in degrees"
|
|
445
|
+
},
|
|
446
|
+
{
|
|
447
|
+
name: "pow",
|
|
448
|
+
kind: "function",
|
|
449
|
+
params: [p("x"), p("y")],
|
|
450
|
+
section: "Numbers and vectors",
|
|
451
|
+
doc: "x raised to y"
|
|
452
|
+
},
|
|
453
|
+
{
|
|
454
|
+
name: "min",
|
|
455
|
+
kind: "function",
|
|
456
|
+
params: [p("values", "A list, or the first of several values")],
|
|
457
|
+
rest: true,
|
|
458
|
+
section: "Numbers and vectors",
|
|
459
|
+
doc: "The smallest of a list, or of several values"
|
|
460
|
+
},
|
|
461
|
+
{
|
|
462
|
+
name: "max",
|
|
463
|
+
kind: "function",
|
|
464
|
+
params: [p("values", "A list, or the first of several values")],
|
|
465
|
+
rest: true,
|
|
466
|
+
section: "Numbers and vectors",
|
|
467
|
+
doc: "The largest of a list, or of several values"
|
|
468
|
+
},
|
|
469
|
+
{
|
|
470
|
+
name: "clamp",
|
|
471
|
+
kind: "function",
|
|
472
|
+
params: [p("x"), p("low"), p("high")],
|
|
473
|
+
section: "Numbers and vectors",
|
|
474
|
+
doc: "x limited to the interval from low to high"
|
|
475
|
+
},
|
|
476
|
+
{
|
|
477
|
+
name: "lerp",
|
|
478
|
+
kind: "function",
|
|
479
|
+
params: [p("a"), p("b"), p("t", "0 gives a, 1 gives b")],
|
|
480
|
+
section: "Numbers and vectors",
|
|
481
|
+
doc: "Interpolate between numbers or vectors"
|
|
482
|
+
},
|
|
483
|
+
{
|
|
484
|
+
name: "norm",
|
|
485
|
+
kind: "function",
|
|
486
|
+
params: [p("v")],
|
|
487
|
+
section: "Numbers and vectors",
|
|
488
|
+
doc: "The length of a vector"
|
|
489
|
+
},
|
|
490
|
+
{
|
|
491
|
+
name: "cross",
|
|
492
|
+
kind: "function",
|
|
493
|
+
params: [p("a"), p("b")],
|
|
494
|
+
section: "Numbers and vectors",
|
|
495
|
+
doc: "Cross product: a number for 2D vectors, a vector for 3D ones"
|
|
496
|
+
},
|
|
497
|
+
// Lists and strings
|
|
498
|
+
{
|
|
499
|
+
name: "len",
|
|
500
|
+
kind: "function",
|
|
501
|
+
params: value,
|
|
502
|
+
section: "Lists and strings",
|
|
503
|
+
doc: "Number of items in a list or characters in a string"
|
|
504
|
+
},
|
|
505
|
+
{
|
|
506
|
+
name: "concat",
|
|
507
|
+
kind: "function",
|
|
508
|
+
params: [],
|
|
509
|
+
rest: true,
|
|
510
|
+
section: "Lists and strings",
|
|
511
|
+
doc: "Join lists and single values into one list"
|
|
512
|
+
},
|
|
513
|
+
{
|
|
514
|
+
name: "reverse",
|
|
515
|
+
kind: "function",
|
|
516
|
+
params: value,
|
|
517
|
+
section: "Lists and strings",
|
|
518
|
+
doc: "A list or string in reverse order"
|
|
519
|
+
},
|
|
520
|
+
{
|
|
521
|
+
name: "sum",
|
|
522
|
+
kind: "function",
|
|
523
|
+
params: [p("values", "A list of numbers")],
|
|
524
|
+
section: "Lists and strings",
|
|
525
|
+
doc: "The sum of a list of numbers"
|
|
526
|
+
},
|
|
527
|
+
{
|
|
528
|
+
name: "slice",
|
|
529
|
+
kind: "function",
|
|
530
|
+
params: [
|
|
531
|
+
p("value", "A list or string"),
|
|
532
|
+
p("start", "First index", "0"),
|
|
533
|
+
p("end", "Index after the last; the length when left out")
|
|
534
|
+
],
|
|
535
|
+
section: "Lists and strings",
|
|
536
|
+
doc: "Part of a list or string"
|
|
537
|
+
},
|
|
538
|
+
{
|
|
539
|
+
name: "str",
|
|
540
|
+
kind: "function",
|
|
541
|
+
params: [],
|
|
542
|
+
rest: true,
|
|
543
|
+
section: "Lists and strings",
|
|
544
|
+
doc: "Values as text, joined"
|
|
545
|
+
},
|
|
546
|
+
{
|
|
547
|
+
name: "chr",
|
|
548
|
+
kind: "function",
|
|
549
|
+
params: [],
|
|
550
|
+
rest: true,
|
|
551
|
+
section: "Lists and strings",
|
|
552
|
+
doc: "Text from Unicode code points"
|
|
553
|
+
},
|
|
554
|
+
{
|
|
555
|
+
name: "ord",
|
|
556
|
+
kind: "function",
|
|
557
|
+
params: [p("text")],
|
|
558
|
+
section: "Lists and strings",
|
|
559
|
+
doc: "The first character's Unicode code point"
|
|
560
|
+
},
|
|
561
|
+
{
|
|
562
|
+
name: "upper",
|
|
563
|
+
kind: "function",
|
|
564
|
+
params: [p("text")],
|
|
565
|
+
section: "Lists and strings",
|
|
566
|
+
doc: "Text in capitals"
|
|
567
|
+
},
|
|
568
|
+
{
|
|
569
|
+
name: "lower",
|
|
570
|
+
kind: "function",
|
|
571
|
+
params: [p("text")],
|
|
572
|
+
section: "Lists and strings",
|
|
573
|
+
doc: "Text in small letters"
|
|
574
|
+
},
|
|
575
|
+
{
|
|
576
|
+
name: "split",
|
|
577
|
+
kind: "function",
|
|
578
|
+
params: [p("text"), p("separator", void 0, '" "')],
|
|
579
|
+
section: "Lists and strings",
|
|
580
|
+
doc: "Text split into a list of strings"
|
|
581
|
+
},
|
|
582
|
+
{
|
|
583
|
+
name: "join",
|
|
584
|
+
kind: "function",
|
|
585
|
+
params: [p("values"), p("separator", void 0, '""')],
|
|
586
|
+
section: "Lists and strings",
|
|
587
|
+
doc: "Values joined into one string"
|
|
588
|
+
},
|
|
589
|
+
{
|
|
590
|
+
name: "search",
|
|
591
|
+
kind: "function",
|
|
592
|
+
params: [p("value"), p("list", "A list or string")],
|
|
593
|
+
section: "Lists and strings",
|
|
594
|
+
doc: "Index of the first equal item, or undef"
|
|
595
|
+
},
|
|
596
|
+
{
|
|
597
|
+
name: "contains",
|
|
598
|
+
kind: "function",
|
|
599
|
+
params: [p("value", "A list or string"), p("item")],
|
|
600
|
+
section: "Lists and strings",
|
|
601
|
+
doc: "Whether a list contains an item or a string contains a substring"
|
|
602
|
+
},
|
|
603
|
+
{
|
|
604
|
+
name: "lookup",
|
|
605
|
+
kind: "function",
|
|
606
|
+
params: [p("x"), p("table", "A list of [x, y] pairs")],
|
|
607
|
+
section: "Lists and strings",
|
|
608
|
+
doc: "Interpolate in a table; outside it, the nearest end"
|
|
609
|
+
},
|
|
610
|
+
// Types and random values
|
|
611
|
+
is("is_num", "a number other than NaN"),
|
|
612
|
+
is("is_string", "a string"),
|
|
613
|
+
is("is_bool", "true or false"),
|
|
614
|
+
is("is_list", "a list"),
|
|
615
|
+
is("is_undef", "undef"),
|
|
616
|
+
is("is_function", "a function"),
|
|
617
|
+
{
|
|
618
|
+
name: "type_of",
|
|
619
|
+
kind: "function",
|
|
620
|
+
params: value,
|
|
621
|
+
section: "Types",
|
|
622
|
+
doc: "The type name: number, string, boolean, undef, list, range or function"
|
|
623
|
+
},
|
|
624
|
+
{
|
|
625
|
+
name: "rands",
|
|
626
|
+
kind: "function",
|
|
627
|
+
params: [p("min"), p("max"), p("count"), p("seed", "The same seed gives the same list", "1")],
|
|
628
|
+
section: "Random values",
|
|
629
|
+
doc: "A list of count numbers between min and max"
|
|
630
|
+
},
|
|
631
|
+
// Text and joints
|
|
632
|
+
text("text_width", "The advance width of the text, including spacing"),
|
|
633
|
+
text("text_metrics", "The text as [advance, [[x0, y0], [x1, y1]], ascent, descent]"),
|
|
634
|
+
{
|
|
635
|
+
name: "finger_count",
|
|
636
|
+
kind: "function",
|
|
637
|
+
params: [p("length", "Edge length"), p("finger", "Finger width", FINGER)],
|
|
638
|
+
section: "Joint dimensions",
|
|
639
|
+
doc: "The odd number of fingers finger_rect() puts on an edge of that length"
|
|
640
|
+
}
|
|
641
|
+
];
|
|
642
|
+
var BY_NAME = new Map(SIGNATURES.map((s) => [s.name, s]));
|
|
643
|
+
var signature = (name) => BY_NAME.get(name);
|
|
644
|
+
function formatSignature(s) {
|
|
645
|
+
const params = s.params.map(
|
|
646
|
+
(x2) => x2.default === void 0 ? x2.name : `${x2.name} = ${x2.default}`
|
|
647
|
+
);
|
|
648
|
+
if (s.rest) params.push("...");
|
|
649
|
+
return `${s.name}(${params.join(", ")})`;
|
|
650
|
+
}
|
|
651
|
+
export {
|
|
652
|
+
SIGNATURES,
|
|
653
|
+
formatSignature,
|
|
654
|
+
signature
|
|
655
|
+
};
|