@thi.ng/axidraw 0.2.0 → 0.2.2

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  # Change Log
2
2
 
3
- - **Last updated**: 2022-12-10T14:04:38Z
3
+ - **Last updated**: 2022-12-16T12:52:25Z
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.
package/README.md CHANGED
@@ -1,10 +1,10 @@
1
1
  <!-- This file is generated - DO NOT EDIT! -->
2
2
 
3
- # ![axidraw](https://media.thi.ng/umbrella/banners-20220914/thing-axidraw.svg?25c834ce)
3
+ # ![@thi.ng/axidraw](https://media.thi.ng/umbrella/banners-20220914/thing-axidraw.svg?25c834ce)
4
4
 
5
5
  [![npm version](https://img.shields.io/npm/v/@thi.ng/axidraw.svg)](https://www.npmjs.com/package/@thi.ng/axidraw)
6
6
  ![npm downloads](https://img.shields.io/npm/dm/@thi.ng/axidraw.svg)
7
- [![Twitter Follow](https://img.shields.io/twitter/follow/thing_umbrella.svg?style=flat-square&label=twitter)](https://twitter.com/thing_umbrella)
7
+ [![Mastodon Follow](https://img.shields.io/mastodon/follow/109331703950160316?domain=https%3A%2F%2Fmastodon.thi.ng&style=social)](https://mastodon.thi.ng/@toxi)
8
8
 
9
9
  This project is part of the
10
10
  [@thi.ng/umbrella](https://github.com/thi-ng/umbrella/) monorepo.
@@ -16,6 +16,7 @@ This project is part of the
16
16
  - [thi.ng/geom support](#thinggeom-support)
17
17
  - [SVG support](#svg-support)
18
18
  - [Serial port support](#serial-port-support)
19
+ - [Draw control](#draw-control)
19
20
  - [Status](#status)
20
21
  - [Installation](#installation)
21
22
  - [Dependencies](#dependencies)
@@ -28,7 +29,7 @@ This project is part of the
28
29
 
29
30
  ## About
30
31
 
31
- Minimal AxiDraw plotter/drawing machine controller for Node.js.
32
+ Minimal AxiDraw plotter/drawing machine controller for Node.js
32
33
 
33
34
  This package provides a super-lightweight alternative to control an [AxiDraw
34
35
  plotter](https://axidraw.com/) directly from Node.js, using a small custom set
@@ -112,6 +113,22 @@ At some point it would also be worth looking into
112
113
  support to enable plotting directly from the browser. Right now this package is
113
114
  only aimed at Node.js though...
114
115
 
116
+ ### Draw control
117
+
118
+ The main draw function provided by this package is async and can supports custom
119
+ implementations to pause, resume or cancel the processing of further drawing
120
+ commands. By the default
121
+ [`AxiDrawControl`](https://docs.thi.ng/umbrella/axidraw/classes/AxiDrawControl.html)
122
+ is used as default implementation.
123
+
124
+ If a control is provided, it will be checked prior to processing each individual
125
+ command. Drawing will be paused if the control state is in paused state and the
126
+ control will be rechecked every N milliseconds for updates (configurable). In
127
+ paused state, the pen will be automatically lifted (if it wasn't already) and
128
+ when resuming it will be sent down again (if it was originally down). Draw
129
+ commands are only sent to the machine if no control is provided at all or if the
130
+ control is in the "continue" state.
131
+
115
132
  ## Status
116
133
 
117
134
  **ALPHA** - bleeding edge / work-in-progress
@@ -134,11 +151,8 @@ ES module import:
134
151
 
135
152
  For Node.js REPL:
136
153
 
137
- ```text
138
- # with flag only for < v16
139
- node --experimental-repl-await
140
-
141
- > const axidraw = await import("@thi.ng/axidraw");
154
+ ```js
155
+ const axidraw = await import("@thi.ng/axidraw");
142
156
  ```
143
157
 
144
158
  Package sizes (brotli'd, pre-treeshake): ESM: 1.67 KB
@@ -208,26 +222,26 @@ import { asAxiDraw } from "@thi.ng/geom-axidraw";
208
222
  import { map, range } from "@thi.ng/transducers";
209
223
 
210
224
  (async () => {
211
- // create group of bezier-interpolated star polygons,
212
- // with each path using a slightly different configuration
213
- const geo = group({ translate: [100, 100] }, [
214
- ...map(
215
- (t) =>
216
- pathFromCubics(
217
- asCubic(star(90, 6, [t, 1]), {
218
- breakPoints: true,
219
- scale: 0.66,
220
- })
221
- ),
222
- range(0.3, 1.01, 0.05)
223
- ),
224
- ]);
225
-
226
- // connect to plotter
227
- const axi = new AxiDraw();
228
- await axi.connect();
229
- // convert geometry to drawing commands & send to plotter
230
- await axi.draw(asAxiDraw(geo, { samples: 40 }));
225
+ // create group of bezier-interpolated star polygons,
226
+ // with each path using a slightly different configuration
227
+ const geo = group({ translate: [100, 100] }, [
228
+ ...map(
229
+ (t) =>
230
+ pathFromCubics(
231
+ asCubic(star(90, 6, [t, 1]), {
232
+ breakPoints: true,
233
+ scale: 0.66,
234
+ })
235
+ ),
236
+ range(0.3, 1.01, 0.05)
237
+ ),
238
+ ]);
239
+
240
+ // connect to plotter
241
+ const axi = new AxiDraw();
242
+ await axi.connect();
243
+ // convert geometry to drawing commands & send to plotter
244
+ await axi.draw(asAxiDraw(geo, { samples: 40 }));
231
245
  })();
232
246
  ```
233
247
 
@@ -239,7 +253,7 @@ Other selected toots/tweets:
239
253
 
240
254
  ## Authors
241
255
 
242
- Karsten Schmidt
256
+ - [Karsten Schmidt](https://thi.ng)
243
257
 
244
258
  If this project contributes to an academic publication, please cite it as:
245
259
 
@@ -254,4 +268,4 @@ If this project contributes to an academic publication, please cite it as:
254
268
 
255
269
  ## License
256
270
 
257
- &copy; 2022 Karsten Schmidt // Apache Software License 2.0
271
+ &copy; 2022 Karsten Schmidt // Apache License 2.0
package/api.d.ts CHANGED
@@ -2,31 +2,31 @@ import type { IDeref } from "@thi.ng/api";
2
2
  import type { ILogger } from "@thi.ng/logger";
3
3
  import type { ReadonlyVec } from "@thi.ng/vectors";
4
4
  /** Start command sequence (configurable via {@link AxiDrawOpts}) */
5
- export declare type StartCommand = ["start"];
5
+ export type StartCommand = ["start"];
6
6
  /** Stop command sequence (configurable via {@link AxiDrawOpts}) */
7
- export declare type StopCommand = ["stop"];
7
+ export type StopCommand = ["stop"];
8
8
  /** Return plotter to initial XY position */
9
- export declare type HomeCommand = ["home"];
9
+ export type HomeCommand = ["home"];
10
10
  /** Reset curr position as home (0,0) */
11
- export declare type ResetCommand = ["reset"];
11
+ export type ResetCommand = ["reset"];
12
12
  /** Turn XY motors on/off */
13
- export declare type MotorCommand = ["on" | "off"];
13
+ export type MotorCommand = ["on" | "off"];
14
14
  /** Pen config, min/down position, max/up position (in %) */
15
- export declare type PenConfigCommand = ["pen", number?, number?];
15
+ export type PenConfigCommand = ["pen", number?, number?];
16
16
  /**
17
17
  * Pen up/down, optional delay (in ms), optional custom level/position. If
18
18
  * omitted, default values used from {@link AxiDrawOpts}. Using -1 as delay also
19
19
  * uses default.
20
20
  */
21
- export declare type PenUpDownCommand = ["u" | "d", number?, number?];
21
+ export type PenUpDownCommand = ["u" | "d", number?, number?];
22
22
  /**
23
23
  * Move to abs pos (in worldspace coords, default mm), optional speed factor
24
24
  * (default: 1)
25
25
  */
26
- export declare type MoveXYCommand = ["m", ReadonlyVec, number?];
26
+ export type MoveXYCommand = ["m", ReadonlyVec, number?];
27
27
  /** Explicit delay (in ms) */
28
- export declare type WaitCommand = ["w", number];
29
- export declare type DrawCommand = StartCommand | StopCommand | HomeCommand | ResetCommand | MotorCommand | PenConfigCommand | PenUpDownCommand | MoveXYCommand | WaitCommand;
28
+ export type WaitCommand = ["w", number];
29
+ export type DrawCommand = StartCommand | StopCommand | HomeCommand | ResetCommand | MotorCommand | PenConfigCommand | PenUpDownCommand | MoveXYCommand | WaitCommand;
30
30
  /**
31
31
  * Global plotter drawing configuration. Also see {@link DEFAULT_OPTS}.
32
32
  */
package/control.d.ts CHANGED
@@ -1,5 +1,12 @@
1
1
  import type { IDeref, IReset } from "@thi.ng/api";
2
2
  import { AxiDrawState } from "./api.js";
3
+ /**
4
+ * Default implementation with easy-to-use API to control the processing of draw
5
+ * commands via {@link AxiDraw.draw}.
6
+ *
7
+ * @remarks
8
+ * See {@link AxiDrawOpts.control} for further details.
9
+ */
3
10
  export declare class AxiDrawControl implements IDeref<AxiDrawState>, IReset {
4
11
  interval: number;
5
12
  state: AxiDrawState;
package/control.js CHANGED
@@ -1,4 +1,11 @@
1
1
  import { AxiDrawState } from "./api.js";
2
+ /**
3
+ * Default implementation with easy-to-use API to control the processing of draw
4
+ * commands via {@link AxiDraw.draw}.
5
+ *
6
+ * @remarks
7
+ * See {@link AxiDrawOpts.control} for further details.
8
+ */
2
9
  export class AxiDrawControl {
3
10
  constructor(interval = 1000) {
4
11
  this.interval = interval;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thi.ng/axidraw",
3
- "version": "0.2.0",
3
+ "version": "0.2.2",
4
4
  "description": "Minimal AxiDraw plotter/drawing machine controller for Node.js",
5
5
  "type": "module",
6
6
  "module": "./index.js",
@@ -10,7 +10,7 @@
10
10
  "type": "git",
11
11
  "url": "https://github.com/thi-ng/umbrella.git"
12
12
  },
13
- "homepage": "https://github.com/thi-ng/umbrella/tree/master/packages/axidraw#readme",
13
+ "homepage": "https://github.com/thi-ng/umbrella/tree/develop/packages/axidraw#readme",
14
14
  "funding": [
15
15
  {
16
16
  "type": "github",
@@ -21,7 +21,7 @@
21
21
  "url": "https://patreon.com/thing_umbrella"
22
22
  }
23
23
  ],
24
- "author": "Karsten Schmidt <k+npm@thi.ng>",
24
+ "author": "Karsten Schmidt (https://thi.ng)",
25
25
  "license": "Apache-2.0",
26
26
  "scripts": {
27
27
  "build": "yarn clean && tsc --declaration",
@@ -34,20 +34,20 @@
34
34
  "test": "testament test"
35
35
  },
36
36
  "dependencies": {
37
- "@thi.ng/api": "^8.5.1",
38
- "@thi.ng/compose": "^2.1.20",
39
- "@thi.ng/errors": "^2.2.5",
40
- "@thi.ng/logger": "^1.4.4",
41
- "@thi.ng/vectors": "^7.5.26",
37
+ "@thi.ng/api": "^8.6.1",
38
+ "@thi.ng/compose": "^2.1.22",
39
+ "@thi.ng/errors": "^2.2.6",
40
+ "@thi.ng/logger": "^1.4.5",
41
+ "@thi.ng/vectors": "^7.5.28",
42
42
  "serialport": "^10.5.0"
43
43
  },
44
44
  "devDependencies": {
45
- "@microsoft/api-extractor": "^7.33.5",
46
- "@thi.ng/testament": "^0.3.6",
45
+ "@microsoft/api-extractor": "^7.33.7",
46
+ "@thi.ng/testament": "^0.3.7",
47
47
  "rimraf": "^3.0.2",
48
48
  "tools": "^0.0.1",
49
- "typedoc": "^0.23.20",
50
- "typescript": "^4.8.4"
49
+ "typedoc": "^0.23.22",
50
+ "typescript": "^4.9.4"
51
51
  },
52
52
  "keywords": [
53
53
  "2d",
@@ -94,5 +94,5 @@
94
94
  "status": "alpha",
95
95
  "year": 2022
96
96
  },
97
- "gitHead": "5178ea1d7f4b2de86cf5101bdd73f6567518c0bd\n"
97
+ "gitHead": "7b2af448da8a63fb21704a79cc4cdf1f3d7d7a64\n"
98
98
  }