kei-lisp-plugin-graphics 3.0.0 → 4.0.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/README.md CHANGED
@@ -21,8 +21,11 @@ interpreter. Register it on a `LispInterpreter` and call drawing primitives
21
21
 
22
22
  ![Shapes and text drawn from Lisp source with kei-lisp-plugin-graphics](./docs/assets/basic-drawing.png)
23
23
 
24
- _The canvas above is painted entirely from Lisp source try it in the
25
- [**live demo**](https://ike-keichan.github.io/kei-lisp-plugin-graphics/)._
24
+ _The canvas above is painted entirely from Lisp source. You can see this
25
+ program rendered in the
26
+ [**example page**](https://ike-keichan.github.io/kei-lisp-plugin-graphics/).
27
+ To write and run kei-lisp yourself, use
28
+ [**kei-lisp-web**](https://ike-keichan.github.io/kei-lisp-web/)._
26
29
 
27
30
  ## Features
28
31
 
@@ -34,11 +37,18 @@ _The canvas above is painted entirely from Lisp source — try it in the
34
37
  ## Installation
35
38
 
36
39
  ```sh
40
+ # npm
41
+ npm install kei-lisp-plugin-graphics kei-lisp
42
+
43
+ # yarn
44
+ yarn add kei-lisp-plugin-graphics kei-lisp
45
+
46
+ # pnpm
37
47
  pnpm add kei-lisp-plugin-graphics kei-lisp
38
- # or: npm install kei-lisp-plugin-graphics kei-lisp
39
48
  ```
40
49
 
41
50
  `kei-lisp` is a **peer dependency**; install both into your project. Requires
51
+ **kei-lisp >= 3.0.1** (for kei-lisp 2.x use kei-lisp-plugin-graphics 3.x) and
42
52
  **Node.js >= 24** for the build toolchain (the plugin itself targets any
43
53
  environment that exposes a `CanvasRenderingContext2D`).
44
54
 
@@ -60,7 +70,7 @@ interpreter.evalString(`
60
70
  (gstroke-color "black")
61
71
  (gline-width 2)
62
72
  (gstroke-rect 10 10 120 80)
63
- (gclose)
73
+ (gclose) ; note: gclose clears the canvas — omit it to keep the drawing visible
64
74
  `);
65
75
  ```
66
76
 
@@ -69,11 +79,9 @@ interpreter.evalString(`
69
79
  ## API
70
80
 
71
81
  ```ts
72
- import type { KeiLispPlugin } from 'kei-lisp';
73
-
74
82
  export function createGraphicsPlugin(options: {
75
83
  canvas: HTMLCanvasElement | OffscreenCanvas;
76
- }): KeiLispPlugin;
84
+ }): GraphicsPlugin;
77
85
  ```
78
86
 
79
87
  The returned plugin implements the [`KeiLispPlugin`](https://github.com/ike-keichan/kei-lisp/blob/main/docs/plugins.md)
@@ -94,25 +102,47 @@ canvas's 2D rendering context.
94
102
  | State | `gsave`, `grestore` |
95
103
  | Image / export | `gimage`, `gsave-png`, `gsave-jpeg`, `gclear-rect`, `gpixel`, `gset-pixel` |
96
104
 
97
- Each function returns `t` on success. See [`docs/graphics.md`](./docs/graphics.md)
98
- for argument signatures and side effects.
105
+ Each function returns `t` on success; failures signal an evaluation error
106
+ that Lisp code can intercept with `(handler-case … (eval-error (e) …))`.
107
+ See [`docs/graphics.md`](./docs/graphics.md) for argument signatures and
108
+ side effects.
109
+
110
+ ## Bundled Lisp patterns
111
+
112
+ The package ships loadable `.lisp` pattern files under `lisp/` — a grid
113
+ helper (`ggrid`), color-palette helpers (`gpalette` / `gpalette-color`),
114
+ and a frame-loop helper (`ganimate`):
115
+
116
+ ```lisp
117
+ (load "node_modules/kei-lisp-plugin-graphics/lisp/grid.lisp")
118
+ (gopen)
119
+ (ggrid 40)
120
+ ```
121
+
122
+ `load` reads from the filesystem (Node.js); browser hosts can fetch the
123
+ file's text and evaluate it instead. See
124
+ [`docs/patterns.md`](./docs/patterns.md) for the full list.
99
125
 
100
126
  ## Environment support
101
127
 
102
- | Capability | Browser (`HTMLCanvasElement`) | `OffscreenCanvas` (worker) | Node.js (e.g. `@napi-rs/canvas`) |
103
- | ------------------------------------- | -------------------------------------------------------- | -------------------------- | -------------------------------- |
104
- | Drawing primitives (`g…`) | ✅ | ✅ | ✅ |
105
- | `gimage` / `gpattern` (image loading) | ✅ | ⚠️ needs a global `Image` | ❌ returns `nil` |
106
- | `gsave-png` / `gsave-jpeg` (download) | ✅ | ❌ returns `nil` | ❌ returns `nil` |
107
- | `gsave-png` / `gsave-jpeg` (`path`) | ❌ returns `nil` | ⚠️ async `convertToBlob` | ✅ |
108
- | Diagnostics | `console.error` (or host-provided `process.stderr` shim) | same | `process.stderr` |
128
+ | Capability | Browser (`HTMLCanvasElement`) | `OffscreenCanvas` (worker) | Node.js (e.g. `@napi-rs/canvas`) |
129
+ | ------------------------------------- | -------------------------------------------------------- | ------------------------------------------------- | -------------------------------- |
130
+ | Drawing primitives (`g…`) | ✅ | ✅ | ✅ |
131
+ | `gimage` / `gpattern` (image loading) | ✅ | ⚠️ needs a global `Image` | ❌ signals an error |
132
+ | `gsave-png` / `gsave-jpeg` (download) | ✅ | ❌ signals an error | ❌ signals an error |
133
+ | `gsave-png` / `gsave-jpeg` (`path`) | ❌ signals an error | ⚠️ needs Node's `process` (async `convertToBlob`) | ✅ |
134
+ | Diagnostics | `console.error` (or host-provided `process.stderr` shim) | same | `process.stderr` |
109
135
 
110
136
  ## Reference
111
137
 
112
- - [Live demo](https://ike-keichan.github.io/kei-lisp-plugin-graphics/) the examples, served from GitHub Pages
138
+ In-depth documentation of each area:
139
+
140
+ - [Example page](https://ike-keichan.github.io/kei-lisp-plugin-graphics/) — the examples rendered on GitHub Pages
141
+ - [kei-lisp-web](https://ike-keichan.github.io/kei-lisp-web/) — interactive kei-lisp playground
113
142
  - [API docs (TypeDoc)](https://ike-keichan.github.io/kei-lisp-plugin-graphics/api/) — generated API documentation
114
143
  - [API Reference](./docs/api.md) — TypeScript / JavaScript API
115
144
  - [Graphics Reference](./docs/graphics.md) — every `g…` Lisp function
145
+ - [Bundled Lisp Patterns](./docs/patterns.md) — the loadable `.lisp` helpers shipped under `lisp/`
116
146
  - [Non-goals](./docs/non-goals.md) — what this project deliberately does not do
117
147
  - [kei-lisp Plugin Guide](https://github.com/ike-keichan/kei-lisp/blob/main/docs/plugins.md) — how plugins integrate with the interpreter
118
148
 
@@ -127,13 +157,16 @@ pnpm install
127
157
  Requires [pnpm](https://pnpm.io/) and Node.js 24+
128
158
  (see [`.node-version`](./.node-version) for the exact version).
129
159
 
130
- | Command | Description |
131
- | ----------------- | ------------------------------------------ |
132
- | `pnpm build` | Build for distribution (CJS + ESM + types) |
133
- | `pnpm test` | Run tests |
134
- | `pnpm test:watch` | Run tests in watch mode |
135
- | `pnpm check` | Run all checks (format, lint, spell, ...) |
136
- | `pnpm fix` | Auto-fix format and lint issues |
160
+ | Command | Description |
161
+ | -------------------- | ----------------------------------------- |
162
+ | `pnpm build` | Build for distribution |
163
+ | `pnpm test` | Run tests |
164
+ | `pnpm test:coverage` | Run tests with coverage thresholds |
165
+ | `pnpm test:watch` | Run tests in watch mode |
166
+ | `pnpm e2e` | Browser E2E (Playwright + Chromium) |
167
+ | `pnpm screenshot` | Regenerate the README screenshot |
168
+ | `pnpm check` | Run all checks (format, lint, spell, ...) |
169
+ | `pnpm fix` | Auto-fix format and lint issues |
137
170
 
138
171
  See [CONTRIBUTING.md](./CONTRIBUTING.md) for the branch policy and PR flow.
139
172