@thi.ng/geom-axidraw 0.4.0 → 0.5.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 +8 -1
- package/README.md +2 -2
- package/as-axidraw.js +2 -2
- package/as-geometry.js +17 -11
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
-
- **Last updated**: 2023-03-
|
|
3
|
+
- **Last updated**: 2023-03-22T22:24:21Z
|
|
4
4
|
- **Generator**: [thi.ng/monopub](https://thi.ng/monopub)
|
|
5
5
|
|
|
6
6
|
All notable changes to this project will be documented in this file.
|
|
@@ -9,6 +9,13 @@ See [Conventional Commits](https://conventionalcommits.org/) for commit guidelin
|
|
|
9
9
|
**Note:** Unlisted _patch_ versions only involve non-code or otherwise excluded changes
|
|
10
10
|
and/or version bumps of transitive dependencies.
|
|
11
11
|
|
|
12
|
+
## [0.5.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/geom-axidraw@0.5.0) (2023-03-22)
|
|
13
|
+
|
|
14
|
+
#### 🚀 Features
|
|
15
|
+
|
|
16
|
+
- add support for new draw commands ([e5e994c](https://github.com/thi-ng/umbrella/commit/e5e994c))
|
|
17
|
+
- update asGeometry() to handle new move commands
|
|
18
|
+
|
|
12
19
|
## [0.4.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/geom-axidraw@0.4.0) (2023-03-19)
|
|
13
20
|
|
|
14
21
|
#### 🚀 Features
|
package/README.md
CHANGED
|
@@ -259,7 +259,7 @@ import { asAxiDraw } from "@thi.ng/geom-axidraw";
|
|
|
259
259
|
MOVE([10,50]),
|
|
260
260
|
// dip the brush 3x times down & up (each time wait 200ms whilst down)
|
|
261
261
|
// (dip() creates a cmd sequence, so need to use the spread operator `...` here)
|
|
262
|
-
...dip(3, {
|
|
262
|
+
...dip(3, { downDelay: 200 }),
|
|
263
263
|
// (...and then drawing continues w/ next 5 points)
|
|
264
264
|
]
|
|
265
265
|
}
|
|
@@ -303,7 +303,7 @@ For Node.js REPL:
|
|
|
303
303
|
const geomAxidraw = await import("@thi.ng/geom-axidraw");
|
|
304
304
|
```
|
|
305
305
|
|
|
306
|
-
Package sizes (brotli'd, pre-treeshake): ESM: 1.
|
|
306
|
+
Package sizes (brotli'd, pre-treeshake): ESM: 1.50 KB
|
|
307
307
|
|
|
308
308
|
## Dependencies
|
|
309
309
|
|
package/as-axidraw.js
CHANGED
|
@@ -69,8 +69,8 @@ export const asAxiDraw = defmulti(__dispatch, {
|
|
|
69
69
|
group: ($, opts) => __group($, opts),
|
|
70
70
|
});
|
|
71
71
|
function* __group($, opts) {
|
|
72
|
+
const $sampleOpts = __sampleAttribs(opts?.samples, $.attribs);
|
|
72
73
|
const { skip, sort, interleave } = __axiAttribs($.attribs);
|
|
73
|
-
const sopts = __sampleAttribs(opts?.samples, $.attribs);
|
|
74
74
|
const children = skip ? [...takeNth(skip + 1, $.children)] : $.children;
|
|
75
75
|
function* emitChunk(chunk) {
|
|
76
76
|
const iter = sort ? sort(chunk) : chunk;
|
|
@@ -79,7 +79,7 @@ function* __group($, opts) {
|
|
|
79
79
|
shape.attribs = {
|
|
80
80
|
...$.attribs,
|
|
81
81
|
...shape.attribs,
|
|
82
|
-
__samples: __sampleAttribs(
|
|
82
|
+
__samples: __sampleAttribs($sampleOpts, shape.attribs),
|
|
83
83
|
};
|
|
84
84
|
yield* asAxiDraw(shape, opts);
|
|
85
85
|
}
|
package/as-geometry.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { group } from "@thi.ng/geom/group";
|
|
2
2
|
import { points } from "@thi.ng/geom/points";
|
|
3
3
|
import { polyline } from "@thi.ng/geom/polyline";
|
|
4
|
-
import {
|
|
4
|
+
import { add2 } from "@thi.ng/vectors/add";
|
|
5
|
+
import { copy } from "@thi.ng/vectors/copy";
|
|
5
6
|
const DEFAULT_ATTRIBS = {
|
|
6
7
|
paths: { stroke: "#000" },
|
|
7
8
|
rapids: { stroke: "#0ff" },
|
|
@@ -40,19 +41,24 @@ export const asGeometry = (src, opts = {}) => {
|
|
|
40
41
|
let penDown = false;
|
|
41
42
|
let pts = null;
|
|
42
43
|
let currPos = [0, 0];
|
|
44
|
+
const $move = (newPos) => {
|
|
45
|
+
if (penDown || opts.rapids) {
|
|
46
|
+
if (!pts)
|
|
47
|
+
pts = [copy(currPos), newPos];
|
|
48
|
+
else
|
|
49
|
+
pts.push(newPos);
|
|
50
|
+
}
|
|
51
|
+
currPos = newPos;
|
|
52
|
+
};
|
|
43
53
|
for (let cmd of src) {
|
|
44
54
|
switch (cmd[0]) {
|
|
55
|
+
// absolute
|
|
56
|
+
case "M":
|
|
57
|
+
$move(copy(cmd[1]));
|
|
58
|
+
break;
|
|
59
|
+
// relative
|
|
45
60
|
case "m":
|
|
46
|
-
|
|
47
|
-
const newPos = copy(cmd[1]);
|
|
48
|
-
if (penDown || opts.rapids) {
|
|
49
|
-
if (!pts)
|
|
50
|
-
pts = [copy(currPos), newPos];
|
|
51
|
-
else
|
|
52
|
-
pts.push(newPos);
|
|
53
|
-
}
|
|
54
|
-
currPos = newPos;
|
|
55
|
-
}
|
|
61
|
+
$move(add2([], currPos, cmd[1]));
|
|
56
62
|
break;
|
|
57
63
|
case "u":
|
|
58
64
|
if (pts) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thi.ng/geom-axidraw",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "Conversion and preparation of thi.ng/geom shapes & shape groups to/from AxiDraw pen plotter draw commands",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "./index.js",
|
|
@@ -36,10 +36,10 @@
|
|
|
36
36
|
"dependencies": {
|
|
37
37
|
"@thi.ng/api": "^8.7.4",
|
|
38
38
|
"@thi.ng/arrays": "^2.5.8",
|
|
39
|
-
"@thi.ng/axidraw": "^1.
|
|
39
|
+
"@thi.ng/axidraw": "^1.1.0",
|
|
40
40
|
"@thi.ng/compare": "^2.1.27",
|
|
41
41
|
"@thi.ng/defmulti": "^2.1.33",
|
|
42
|
-
"@thi.ng/geom": "^4.
|
|
42
|
+
"@thi.ng/geom": "^4.3.0",
|
|
43
43
|
"@thi.ng/geom-accel": "^3.3.9",
|
|
44
44
|
"@thi.ng/geom-api": "^3.4.10",
|
|
45
45
|
"@thi.ng/geom-clip-line": "^2.3.10",
|
|
@@ -121,5 +121,5 @@
|
|
|
121
121
|
"status": "alpha",
|
|
122
122
|
"year": 2022
|
|
123
123
|
},
|
|
124
|
-
"gitHead": "
|
|
124
|
+
"gitHead": "5b3d731c0e192c53f65efb4baed97be0e4029a33\n"
|
|
125
125
|
}
|