@thi.ng/axidraw 1.1.78 → 1.1.80
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 +1 -1
- package/axidraw.js +5 -10
- package/package.json +16 -16
- package/polyline.js +5 -10
package/CHANGELOG.md
CHANGED
package/axidraw.js
CHANGED
|
@@ -164,8 +164,7 @@ class AxiDraw {
|
|
|
164
164
|
let drawDist = 0;
|
|
165
165
|
const $recordDist = (dist) => {
|
|
166
166
|
totalDist += dist;
|
|
167
|
-
if (this.isPenDown)
|
|
168
|
-
drawDist += dist;
|
|
167
|
+
if (this.isPenDown) drawDist += dist;
|
|
169
168
|
};
|
|
170
169
|
const { control, logger, preDelay, refresh } = this.opts;
|
|
171
170
|
for (let $cmd of wrap ? complete(commands) : commands) {
|
|
@@ -174,8 +173,7 @@ class AxiDraw {
|
|
|
174
173
|
let state = control.deref();
|
|
175
174
|
if (state === AxiDrawState.PAUSE) {
|
|
176
175
|
const penDown = this.isPenDown;
|
|
177
|
-
if (penDown)
|
|
178
|
-
this.penUp();
|
|
176
|
+
if (penDown) this.penUp();
|
|
179
177
|
do {
|
|
180
178
|
await delayed(0, refresh);
|
|
181
179
|
} while ((state = control.deref()) === AxiDrawState.PAUSE);
|
|
@@ -318,16 +316,14 @@ class AxiDraw {
|
|
|
318
316
|
this.send(`SC,10,65535\r`);
|
|
319
317
|
}
|
|
320
318
|
penUp(delay, level) {
|
|
321
|
-
if (level !== void 0)
|
|
322
|
-
this.sendPenConfig(4, level);
|
|
319
|
+
if (level !== void 0) this.sendPenConfig(4, level);
|
|
323
320
|
delay = delay !== void 0 && delay >= 0 ? delay : this.opts.delayUp;
|
|
324
321
|
this.send(`SP,1,${delay}\r`);
|
|
325
322
|
this.isPenDown = false;
|
|
326
323
|
return delay;
|
|
327
324
|
}
|
|
328
325
|
penDown(delay, level) {
|
|
329
|
-
if (level !== void 0)
|
|
330
|
-
this.sendPenConfig(5, level);
|
|
326
|
+
if (level !== void 0) this.sendPenConfig(5, level);
|
|
331
327
|
delay = delay !== void 0 && delay >= 0 ? delay : this.opts.delayDown;
|
|
332
328
|
this.send(`SP,0,${delay}\r`);
|
|
333
329
|
this.isPenDown = true;
|
|
@@ -385,8 +381,7 @@ class AxiDraw {
|
|
|
385
381
|
}
|
|
386
382
|
sendMove(tempo = 1) {
|
|
387
383
|
const { bounds, pos, scale, targetPos, opts, isPenDown } = this;
|
|
388
|
-
if (bounds)
|
|
389
|
-
clamp2(null, targetPos, ...bounds);
|
|
384
|
+
if (bounds) clamp2(null, targetPos, ...bounds);
|
|
390
385
|
const delta = sub2([], targetPos, pos);
|
|
391
386
|
set2(pos, targetPos);
|
|
392
387
|
const maxAxis = Math.max(...abs2([], delta));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thi.ng/axidraw",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.80",
|
|
4
4
|
"description": "Minimal AxiDraw plotter/drawing machine controller for Node.js",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "./index.js",
|
|
@@ -36,23 +36,23 @@
|
|
|
36
36
|
"tool:tangle": "../../node_modules/.bin/tangle src/**/*.ts"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@thi.ng/api": "^8.11.
|
|
40
|
-
"@thi.ng/checks": "^3.6.
|
|
41
|
-
"@thi.ng/compose": "^3.0.
|
|
42
|
-
"@thi.ng/date": "^2.7.
|
|
43
|
-
"@thi.ng/errors": "^2.5.
|
|
44
|
-
"@thi.ng/logger": "^3.0.
|
|
45
|
-
"@thi.ng/math": "^5.10.
|
|
46
|
-
"@thi.ng/transducers": "^9.0.
|
|
47
|
-
"@thi.ng/units": "^0.4.
|
|
48
|
-
"@thi.ng/vectors": "^7.10.
|
|
39
|
+
"@thi.ng/api": "^8.11.2",
|
|
40
|
+
"@thi.ng/checks": "^3.6.4",
|
|
41
|
+
"@thi.ng/compose": "^3.0.4",
|
|
42
|
+
"@thi.ng/date": "^2.7.18",
|
|
43
|
+
"@thi.ng/errors": "^2.5.7",
|
|
44
|
+
"@thi.ng/logger": "^3.0.12",
|
|
45
|
+
"@thi.ng/math": "^5.10.13",
|
|
46
|
+
"@thi.ng/transducers": "^9.0.5",
|
|
47
|
+
"@thi.ng/units": "^0.4.46",
|
|
48
|
+
"@thi.ng/vectors": "^7.10.31",
|
|
49
49
|
"serialport": "^12.0.0"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
|
-
"@microsoft/api-extractor": "^7.43.
|
|
53
|
-
"esbuild": "^0.
|
|
54
|
-
"typedoc": "^0.25.
|
|
55
|
-
"typescript": "^5.4.
|
|
52
|
+
"@microsoft/api-extractor": "^7.43.2",
|
|
53
|
+
"esbuild": "^0.21.1",
|
|
54
|
+
"typedoc": "^0.25.13",
|
|
55
|
+
"typescript": "^5.4.5"
|
|
56
56
|
},
|
|
57
57
|
"keywords": [
|
|
58
58
|
"2d",
|
|
@@ -115,5 +115,5 @@
|
|
|
115
115
|
"status": "alpha",
|
|
116
116
|
"year": 2022
|
|
117
117
|
},
|
|
118
|
-
"gitHead": "
|
|
118
|
+
"gitHead": "df34b4a9e650cc7323575356de207d78933bdcf3\n"
|
|
119
119
|
}
|
package/polyline.js
CHANGED
|
@@ -1,22 +1,17 @@
|
|
|
1
1
|
import { DOWN, MOVE, PEN, UP } from "./commands.js";
|
|
2
2
|
function* polyline(pts, opts = {}) {
|
|
3
|
-
if (!pts.length)
|
|
4
|
-
return;
|
|
3
|
+
if (!pts.length) return;
|
|
5
4
|
const { speed = 1, onlyGeo = false, delayDown, delayUp, down } = opts;
|
|
6
5
|
if (onlyGeo) {
|
|
7
|
-
for (let p of pts)
|
|
8
|
-
yield MOVE(p, speed);
|
|
6
|
+
for (let p of pts) yield MOVE(p, speed);
|
|
9
7
|
return;
|
|
10
8
|
}
|
|
11
9
|
yield MOVE(pts[0]);
|
|
12
|
-
if (down !== void 0)
|
|
13
|
-
yield PEN(down);
|
|
10
|
+
if (down !== void 0) yield PEN(down);
|
|
14
11
|
yield DOWN(delayDown);
|
|
15
|
-
for (let i = 1, n = pts.length; i < n; i++)
|
|
16
|
-
yield MOVE(pts[i], speed);
|
|
12
|
+
for (let i = 1, n = pts.length; i < n; i++) yield MOVE(pts[i], speed);
|
|
17
13
|
yield UP(delayUp);
|
|
18
|
-
if (down !== void 0)
|
|
19
|
-
yield PEN();
|
|
14
|
+
if (down !== void 0) yield PEN();
|
|
20
15
|
}
|
|
21
16
|
export {
|
|
22
17
|
polyline
|