gpucanvas 0.3.0 → 0.3.1

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.
Files changed (2) hide show
  1. package/README.md +34 -5
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,14 +1,32 @@
1
1
  # gpucanvas
2
2
 
3
- Put thousands of live DOM nodes on an infinite canvas and let the GPU pan and zoom them.
3
+ Put thousands of live DOM nodes on an infinite canvas: the GPU draws them, an editor selects,
4
+ moves and resizes them, and shaders run on them.
4
5
 
5
6
  ![The same 5,000 live React screens as plain DOM (left) and in gpucanvas (right), with each side's frame rate measured live](docs/benchmark.gif)
6
7
 
7
8
  The same session on both sides: 5,000 live React screens, the same camera path, a message typed and sent. Left, every screen is plain DOM under a CSS transform. Right, gpucanvas. Recorded in Chrome on a MacBook Pro; the frame rates are measured live in each run. Run it yourself in the [live demo](https://berkantay.github.io/gpucanvas/).
8
9
 
10
+ - **[Canvas](#how-it-works).** Live React or plain DOM nodes, drawn by WebGPU in one instanced
11
+ pass. Pan and zoom never touch the DOM, and clicks, typing and state still reach the real
12
+ elements.
13
+ - **[Editor](#editing).** Click to select, double-click to go a layer deeper, down to any element
14
+ or React component. Move and resize with snapping guides.
15
+ - **[Shader effects](#shader-effects).** Run WGSL on live components: a glass lens, frost,
16
+ shockwaves, glitch, VHS, or your own.
17
+
9
18
  ## Try it
10
19
 
11
- Open **[berkantay.github.io/gpucanvas](https://berkantay.github.io/gpucanvas/)** in Chrome 157 or later. Thirty agent cursors build the first view, then the camera pulls out to all 5,000 screens. Press `b` to run the benchmark tour.
20
+ Open **[berkantay.github.io/gpucanvas](https://berkantay.github.io/gpucanvas/)** in Chrome 157 or
21
+ later. Thirty agent cursors build the first view, then the camera pulls out to all 5,000 screens.
22
+
23
+ - Click a screen to select it, double-click to go deeper, drag to move it.
24
+ - Pick a shader effect in the toolbar, or open one directly:
25
+ [glass](https://berkantay.github.io/gpucanvas/?effect=glass),
26
+ [shockwave](https://berkantay.github.io/gpucanvas/?effect=shockwave) (click anywhere),
27
+ [frost](https://berkantay.github.io/gpucanvas/?effect=frost),
28
+ [glitch](https://berkantay.github.io/gpucanvas/?effect=glitch).
29
+ - Press `b` to run the benchmark tour.
12
30
 
13
31
  The GPU path needs HTML-in-Canvas, which is behind a flag:
14
32
 
@@ -158,8 +176,10 @@ const scanlines = defineEffect({
158
176
  `EffectInput` has `uv` (0 to 1 across the node), `size` in CSS pixels, `time` in seconds,
159
177
  `zoom`, the four `params`, the `pointer` and the last `press` in the node's uv, and
160
178
  `sincePress` in seconds. `source(uv)` reads the node's pixels, premultiplied, and is
161
- transparent outside it; `hash` and `noise` give random values. An effect that draws past its node, like a glow, declares how far with
162
- `pad`. Effects read the node's whole snapshot, so very close in they are softer than plain nodes.
179
+ transparent outside it; `hash` and `noise` give random values. An effect that draws past its
180
+ node, like a glow, declares how far with `pad`. Effects read the node's whole snapshot, so very
181
+ close in they are softer than plain nodes. In React, `<CanvasNode effect={effects.glass}>` does
182
+ the same.
163
183
 
164
184
  The DOM backend shows effects that have a `css` look as a CSS `filter` (animated ones as filter
165
185
  animations) and the rest as plain nodes. The demo's toolbar puts one effect on every component.
@@ -171,6 +191,12 @@ bun install
171
191
  bun run dev # http://localhost:5199/?mode=gpu&n=10000 (mode: auto | gpu | dom)
172
192
  ```
173
193
 
194
+ ## Releases
195
+
196
+ Publishing a GitHub release for a `vX.Y.Z` tag that matches `package.json` publishes the package
197
+ to npm from GitHub Actions, with provenance, through npm trusted publishing. See
198
+ [release.yml](.github/workflows/release.yml).
199
+
174
200
  ## How it works
175
201
 
176
202
  1. **Pages.** Nodes are live DOM inside `<canvas content="drawable">`, packed side by side into
@@ -186,7 +212,8 @@ bun run dev # http://localhost:5199/?mode=gpu&n=10000 (mode: auto | gpu
186
212
  4. **Tiles up close.** Past 100% zoom on a 2x display, only the visible part of a node is
187
213
  rasterized, as sharp tiles, center first. While its content animates, one half-resolution preview stands in.
188
214
  5. **One draw call.** Each frame culls nodes against the view and draws every visible one with
189
- one instanced quad draw. Panning and zooming never touch the DOM. Raster work has a
215
+ one instanced quad draw, or one per run of nodes sharing a shader effect. Panning and zooming
216
+ never touch the DOM. Raster work has a
190
217
  per-frame budget, so the camera stays smooth while pixels fill in.
191
218
  6. **Live updates.** A MutationObserver marks a node dirty when its content changes, and
192
219
  loading images, web fonts and CSS transitions trigger a redraw. Animated content on nodes
@@ -235,6 +262,8 @@ DOM is the same screens in one CSS-transformed container, which is also the fall
235
262
 
236
263
  ## Next
237
264
 
265
+ - **Snapshots as data.** Every node is already a texture: export it as an image without a
266
+ headless browser, diff two versions of a screen on the GPU, keep a filmstrip of its history.
238
267
  - **Keyboard and accessibility.** Parked pages use `content-visibility: hidden`, so Tab skips
239
268
  their nodes. A focused node already stays live; moving focus across pages needs a focus model.
240
269
  - **Workers.** Composite in a worker with `captureElementImage`, and drive culling from the GPU.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gpucanvas",
3
- "version": "0.3.0",
3
+ "version": "0.3.1",
4
4
  "description": "Put thousands of live DOM nodes on an infinite canvas: the GPU draws them, an editor selects, moves and resizes them, and shaders run on them.",
5
5
  "keywords": [
6
6
  "canvas",