Skip to content

Unlock custom brushes, natural fill effects and intuitive hatching in p5.js

chore: reorganise test folders, update docs with standalone build

acamposuribe83ac7df4bd9f
diff --git a/.gitignore b/.gitignore
index 36934dc..a6bd32e 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,10 @@
node_modules/
.claude/
-workspace/
\ No newline at end of file
+workspace/
+
+# autoresearch
+autoresearch.jsonl
+autoresearch.md
+autoresearch.ideas.md
+autoresearch.sh
+autoresearch.sh
\ No newline at end of file
diff --git a/README.md b/README.md
index e2103a8..ca08dff 100644
--- a/README.md
+++ b/README.md
@@ -15,6 +15,25 @@ p5.brush.js adds natural drawing tools to p5.js — pencils, charcoal, markers,
> ▶️ **[Check the teaser live →](https://editor.p5js.org/acamposuribe/sketches/bkb_CyJyi)**
> Live on the p5.js Web Editor, where you can read and edit code.
+## Two builds
+
+p5.brush ships in two flavors:
+
+| | p5 build | Standalone build |
+|---|---|---|
+| **File** | `dist/p5.brush.js` | `dist/brush.js` |
+| **Requires** | p5.js 2.x + WEBGL canvas | Nothing — WebGL2 browser only |
+| **Canvas setup** | `createCanvas(w, h, WEBGL)` | `brush.createCanvas(w, h)` |
+| **Transforms** | p5's `push/pop`, `translate`, `rotate`, `scale` | `brush.push/pop`, `brush.translate`, etc. |
+| **Angle mode** | Follows p5's `angleMode()` | `brush.angleMode(brush.DEGREES \| brush.RADIANS)` |
+| **Seeding** | `randomSeed()` / `noiseSeed()` | `brush.seed()` / `brush.noiseSeed()` |
+| **Frame flush** | Automatic | `brush.render()` at end of each frame |
+| **Clear** | p5's `background()` | `brush.clear(color?)` |
+
+This README covers the **p5 build**. For the standalone build see **[docs/standalone.md](docs/standalone.md)**.
+
+---
+
## Table of Contents
- [Installation](#installation)
- [Features](#features)
diff --git a/docs/standalone.md b/docs/standalone.md
new file mode 100644
index 0000000..abf41c5
--- /dev/null
+++ b/docs/standalone.md
@@ -0,0 +1,337 @@
+# p5.brush — Standalone Build
+
+The standalone build (`dist/brush.js` / `dist/brush.esm.js`) runs without p5.js. It needs nothing beyond a WebGL2-capable browser.
+
+For the p5 build see the main [README](../README.md).
+
+---
+
+## Table of Contents
+- [Installation](#installation)
+- [Setup](#setup)
+- [Frame lifecycle](#frame-lifecycle)
+- [Transforms](#transforms)
+- [Angle mode](#angle-mode)
+- [Seeding](#seeding)
+- [API reference](#api-reference)
+- [Differences from the p5 build](#differences-from-the-p5-build)
+
+---
+
+## Installation
+
+### Script tag (UMD)
+
+Download `dist/brush.js` from this repository and include it in your HTML. It exposes a global `brush` object.
+
+```html
+<script src="path_to/brush.js"></script>
+```
+
+### ESM module
+
+```js
+import * as brush from './dist/brush.esm.js';
+```
+
+---
+
+## Setup
+
+### Using `brush.createCanvas()`
+
+The simplest path. Creates a `<canvas>` element, attaches it to the DOM, and automatically loads it as the draw target — no separate `brush.load()` call needed.
+
+```js
+brush.createCanvas(width, height, options?)
+```
+
+**Options:**
+
+| Property | Description |
+|---|---|
+| `pixelDensity` | Backing resolution multiplier. Defaults to `1`. Pass `window.devicePixelRatio` for sharp output on HiDPI screens. |
+| `parent` | CSS selector string or DOM element to append the canvas to. |
+| `id` | `id` attribute for the created `<canvas>`. |
+
+```js
+import * as brush from './dist/brush.esm.js';
+
+brush.createCanvas(800, 600, {
+ parent: '#sketch-container',
+ pixelDensity: window.devicePixelRatio,
+});
+
+brush.scaleBrushes(4);
+brush.angleMode(brush.DEGREES);
+```
+
+### Bringing your own canvas
+
+If you create the canvas element yourself (or use an `OffscreenCanvas`), call `brush.load(canvas)` once to register it as the draw target.
+
+```js
+const canvas = document.createElement('canvas');
+canvas.width = 800;
+canvas.height = 600;
+document.body.appendChild(canvas);
+
+brush.load(canvas);
+```
+
+`brush.load()` also lets you **switch between multiple canvases** at runtime — call it again with a different canvas whenever you want to redirect drawing.
+
+> **WebGL2 required.** Both `brush.createCanvas()` and `brush.load()` require the canvas to support a WebGL2 context. Make sure the browser supports it before calling either.
+
+---
+
+## Frame lifecycle
+
+Unlike the p5 build (where p5 handles compositing automatically), the standalone build requires you to explicitly flush and clear each frame.
+
+### `brush.render()`
+
+Flushes any pending stroke and fill compositing into the active canvas. Call this **at the end of each drawing pass** — once per frame if you are animating, or once after a static draw.
+
+```js
+brush.clear('#f5f0e0');
+brush.push();
+brush.translate(-W / 2, -H / 2);
+
+brush.set('HB', '#333', 1);
+brush.line(100, 100, 700, 500);
+
+brush.pop();
+brush.render(); // ← flush to canvas
+```
+
+### `brush.clear(color?)`
+
+Clears the active canvas. Without arguments, clears to transparent. With a color argument, clears to that color at full opacity.
+
+```js
+brush.clear(); // transparent
+brush.clear('#f5f0e0'); // off-white background
+brush.clear(240, 235, 220); // RGB
+```
+
+---
+
+## Transforms
+
+The standalone build manages its own transform stack, independent of any external library.
+
+```js
+brush.push() // save current transform + brush state
+brush.pop() // restore
+brush.translate(x, y)
+brush.rotate(angle) // angle follows current angleMode
+brush.scale(x, y?) // omit y to scale uniformly
+```
+
+These work exactly like p5's equivalents. `push()` and `pop()` save and restore both the transform matrix and brush state (stroke, fill, hatch settings).
+
+### Origin
+
+The WebGL canvas origin is at the **center** of the canvas. To work in top-left coordinates, shift the origin at the start of each frame:
+
+```js
+brush.push();
+brush.translate(-W / 2, -H / 2);
+
+// draw everything here...
+
+brush.pop();
+brush.render();
+```
+
+---
+
+## Angle mode
+
+```js
+brush.angleMode(brush.DEGREES); // all angle inputs in degrees
+brush.angleMode(brush.RADIANS); // all angle inputs in radians (default)
+```
+
+The exported constants are `brush.DEGREES` and `brush.RADIANS`. The mode affects every API that accepts an angle: `brush.rotate()`, `brush.hatch()`, `brush.flowLine()`, `brush.arc()`, `brush.move()`, `brush.addField()`, and `brush.Position.moveTo()`.
+
+```js
+brush.angleMode(brush.DEGREES);
+brush.hatch(8, 45); // 45°
+brush.flowLine(x, y, 100, 90); // pointing down
+```
+
+For custom vector fields, pass `{ angleMode: 'radians' }` if your generator writes radians:
+
+```js
+brush.addField('myField', (t, field) => {
+ for (let c = 0; c < field.length; c++)
+ for (let r = 0; r < field[0].length; r++)
+ field[c][r] = Math.sin(c * 0.3 + t) * Math.PI;
+ return field;
+}, { angleMode: 'radians' });
+```
+
+---
+
+## Seeding
+
+```js
+brush.seed(n) // seed the internal RNG
+brush.noiseSeed(n) // seed the internal noise generator
+```
+
+Call before drawing to get reproducible results. Both accept any number.
+
+```js
+brush.seed(42);
+brush.noiseSeed(42);
+```
+
+---
+
+## API reference
+
+All stroke, fill, hatch, primitive, field, and class APIs are **identical** to the p5 build. See the [p5 API reference in README.md](../README.md#reference) for the full documentation of every function.
+
+The sections below list only what is **different or exclusive** to the standalone build.
+
+---
+
+### Configuration
+
+#### `brush.createCanvas(width, height, options?)`
+
+Creates a `<canvas>` element and loads it as the draw target. Returns the canvas element.
+
+See [Setup](#setup) above for the full option list and examples.
+
+---
+
+#### `brush.load(canvas)`
+
+Loads an existing `HTMLCanvasElement` or `OffscreenCanvas` as the draw target. Only needed when you create the canvas yourself or want to switch targets.
+
+```js
+// External canvas
+const canvas = document.createElement('canvas');
+canvas.width = 800; canvas.height = 600;
+brush.load(canvas);
+
+// OffscreenCanvas (e.g. in a Web Worker)
+const offscreen = new OffscreenCanvas(800, 600);
+brush.load(offscreen);
+```
+
+---
+
+#### `brush.render()`
+
+Flushes compositing. Must be called at the end of every drawing pass. See [Frame lifecycle](#frame-lifecycle).
+
+---
+
+#### `brush.clear(color?)`
+
+Clears the canvas to transparent (no args) or to a solid color. See [Frame lifecycle](#frame-lifecycle).
+
+---
+
+### Transforms
+
+#### `brush.push()` / `brush.pop()`
+
+Save and restore the current transform matrix and all brush state (stroke, fill, hatch).
+
+#### `brush.translate(x, y)`
+
+#### `brush.rotate(angle)`
+
+Angle follows the current `brush.angleMode()`.
+
+#### `brush.scale(x, y?)`
+
+Omit `y` to scale uniformly.
+
+---
+
+### Angle mode
+
+#### `brush.angleMode(mode)`
+
+Set to `brush.DEGREES` or `brush.RADIANS`. Default is `brush.RADIANS`.
+
+#### `brush.DEGREES` / `brush.RADIANS`
+
+Exported string constants used with `brush.angleMode()`.
+
+---
+
+### Seeding
+
+#### `brush.seed(n)`
+
+Seed the internal RNG.
+
+#### `brush.noiseSeed(n)`
+
+Seed the internal noise generator.
+
+---
+
+## Differences from the p5 build
+
+| | p5 build | Standalone build |
+|---|---|---|
+| Canvas creation | `createCanvas(w, h, WEBGL)` | `brush.createCanvas(w, h)` |
+| Loading an existing canvas | `brush.load(p5Graphics\|framebuffer)` for offscreen targets | `brush.load(htmlCanvas\|offscreenCanvas)` for external canvases |
+| Compositing flush | Automatic | `brush.render()` required each frame |
+| Clearing | `background()` | `brush.clear(color?)` |
+| Transforms | p5's `push/pop`, `translate`, `rotate`, `scale` | `brush.push/pop`, `brush.translate`, `brush.rotate`, `brush.scale` |
+| Angle mode | p5's `angleMode()` | `brush.angleMode(brush.DEGREES \| brush.RADIANS)` |
+| Seeding | `randomSeed()` / `noiseSeed()` seed the library too | `brush.seed()` / `brush.noiseSeed()` |
+| Instance mode | `brush.instance(p)` | Not applicable (`brush.instance()` is a no-op) |
+| Framebuffer targets | Supported via `brush.load(framebuffer)` | Not supported |
+
+---
+
+## Full example
+
+```js
+import * as brush from './dist/brush.esm.js';
+
+const W = 800, H = 600;
+
+// Create and load the canvas in one call
+brush.createCanvas(W, H, {
+ parent: document.body,
+ pixelDensity: window.devicePixelRatio,
+});
+
+brush.scaleBrushes(4);
+brush.angleMode(brush.DEGREES);
+brush.seed(42);
+
+// Draw
+brush.clear('#f5f0e0');
+brush.push();
+brush.translate(-W / 2, -H / 2);
+
+brush.set('HB', '#1a2a3a', 1);
+brush.line(80, 80, 720, 520);
+
+brush.fill('#003c32', 110);
+brush.fillBleed(0.2);
+brush.noStroke();
+brush.circle(W / 2, H / 2, 120);
+
+brush.hatchStyle('HB', '#1a2a3a', 0.8);
+brush.hatch(6, 45, { rand: 0.05 });
+brush.noFill();
+brush.rect(100, 100, 200, 160, 'corner');
+brush.noHatch();
+
+brush.pop();
+brush.render(); // flush to canvas
+```
diff --git a/llms.txt b/llms.txt
index 2f7b9ef..400def8 100644
--- a/llms.txt
+++ b/llms.txt
@@ -57,7 +57,6 @@ Exception: `brush.addField(name, fn, { angleMode })` lets custom field generator
- `brush.load(buffer?)` — Use this when targeting a **secondary** canvas. Pass a `p5.Graphics` buffer or an active `p5.Framebuffer` to redirect brush drawing there. Call `brush.load()` with no args to return to the main canvas. For `p5.Graphics`, create the buffer in `WEBGL`, call `brush.load(pg)`, draw, then call `brush.load()` again before presenting it with `image(pg, ...)`. For framebuffers, call `brush.load(framebuffer)` only while that framebuffer is active inside `begin()` / `end()` or `draw()`, then call `brush.load()` again after leaving that scope. `brush.load(...)` only changes p5.brush's target; native p5 drawing calls still need to be directed at the same target explicitly. Framebuffers created from `p5.Graphics` are not supported.
- `brush.scaleBrushes(scale)` — Scale all currently registered brushes by `scale`. In practice this is usually necessary to adapt brushes to the canvas size, not just optional polish. For a `600x600` canvas, `brush.scaleBrushes(3)` is a good starting point, but it should still be confirmed visually. Call once in setup; if you only want the built-ins scaled, call it before adding custom brushes.
- `brush.instance(p)` — Use when p5 is in instance mode. Call before setup/draw.
-- `brush.preload()` — Compatibility helper for preloading image tips. Usually unnecessary in v2 if you `await brush.add(...)` for image brushes.
---
diff --git a/test/index.html b/test/index.html
index bdbdcee..e80fa9d 100644
--- a/test/index.html
+++ b/test/index.html
@@ -181,88 +181,88 @@
<p>Use these pages to visually inspect the p5 build directly in the browser.</p>
</div>
<div class="grid">
- <a class="card" href="./visual_suite.html">
+ <a class="card" href="./p5/visual_suite.html">
<h3>Visual API Suite</h3>
<p>Wide coverage page that exercises most public APIs and logs error-message checks to the console.</p>
<span class="meta">Coverage</span>
- <span class="path">test/visual_suite.html</span>
+ <span class="path">test/p5/visual_suite.html</span>
</a>
- <a class="card" href="./fill_circle_explorer.html">
+ <a class="card" href="./p5/fill_circle_explorer.html">
<h3>Fill Circle Explorer</h3>
<p>Seeded single-shape page for inspecting watercolor fill bleed, opacity, texture, border, and palette color on a centered circle.</p>
<span class="meta">Explorer</span>
- <span class="path">test/fill_circle_explorer.html</span>
+ <span class="path">test/p5/fill_circle_explorer.html</span>
</a>
- <a class="card" href="./wash_test.html">
+ <a class="card" href="./p5/wash_test.html">
<h3>Wash Test</h3>
<p>Direct WEBGL wash page that draws five random rect and circle polygons with palette colors at full opacity.</p>
<span class="meta">Coverage</span>
- <span class="path">test/wash_test.html</span>
+ <span class="path">test/p5/wash_test.html</span>
</a>
- <a class="card" href="./pastel_hatching_test.html">
+ <a class="card" href="./p5/pastel_hatching_test.html">
<h3>Pastel Hatching Test</h3>
<p>Minimal global-mode sketch with a custom crayon brush and a single centered rectangle for pastel hatching experiments.</p>
<span class="meta">Experiment</span>
- <span class="path">test/pastel_hatching_test.html</span>
+ <span class="path">test/p5/pastel_hatching_test.html</span>
</a>
- <a class="card" href="./angle_mode_test.html">
+ <a class="card" href="./p5/angle_mode_test.html">
<h3>Angle Mode Test</h3>
<p>Compares degrees, radians, mixed mode changes, stored hatch angles, low-level Position movement, and custom fields.</p>
<span class="meta">Behavior</span>
- <span class="path">test/angle_mode_test.html</span>
+ <span class="path">test/p5/angle_mode_test.html</span>
</a>
- <a class="card" href="./transform_test.html">
+ <a class="card" href="./p5/transform_test.html">
<h3>Transform Alignment</h3>
<p>Checks that brush strokes and fills align with native p5 reference geometry under translate, rotate, and scale.</p>
<span class="meta">Geometry</span>
- <span class="path">test/transform_test.html</span>
+ <span class="path">test/p5/transform_test.html</span>
</a>
- <a class="card" href="./pushpop_test.html">
+ <a class="card" href="./p5/pushpop_test.html">
<h3>Push / Pop State</h3>
<p>Verifies that p5 push/pop restores stroke, brush, fill, and hatch state correctly.</p>
<span class="meta">State</span>
- <span class="path">test/pushpop_test.html</span>
+ <span class="path">test/p5/pushpop_test.html</span>
</a>
- <a class="card" href="./hatch_test.html">
+ <a class="card" href="./p5/hatch_test.html">
<h3>Hatch Test</h3>
<p>Exercises hatch angles, spacing, rand/continuous/gradient options, cross-hatching, brush types, shapes, and multi-polygon arrays.</p>
<span class="meta">Coverage</span>
- <span class="path">test/hatch_test.html</span>
+ <span class="path">test/p5/hatch_test.html</span>
</a>
- <a class="card" href="./field_explorer.html">
+ <a class="card" href="./p5/field_explorer.html">
<h3>Flow Field Explorer</h3>
<p>Interactive field inspector for comparing built-in fields with adjustable density and line length.</p>
<span class="meta">Explorer</span>
- <span class="path">test/field_explorer.html</span>
+ <span class="path">test/p5/field_explorer.html</span>
</a>
- <a class="card" href="./p5_specific/offscreen_target_test.html">
+ <a class="card" href="./p5/offscreen_target_test.html">
<h3>Offscreen Targets</h3>
<p>Checks brush.load() on p5.Graphics and custom-sized main framebuffers, with pixel-count diagnostics.</p>
<span class="meta">Targets</span>
- <span class="path">test/p5_specific/offscreen_target_test.html</span>
+ <span class="path">test/p5/offscreen_target_test.html</span>
</a>
- <a class="card" href="./p5_specific/instance_mode_test.html">
+ <a class="card" href="./p5/instance_mode_test.html">
<h3>Instance Mode</h3>
<p>Checks brush.instance(p) on the instance canvas, an instance p5.Graphics target, and an instance-owned main framebuffer.</p>
<span class="meta">Instances</span>
- <span class="path">test/p5_specific/instance_mode_test.html</span>
+ <span class="path">test/p5/instance_mode_test.html</span>
</a>
- <a class="card" href="./p5_specific/multi_instance_async_test.html">
+ <a class="card" href="./p5/multi_instance_async_test.html">
<h3>Async Multi-Instance</h3>
<p>Stress-tests the old multi-instance startup race with many instance-mode sketches and repeated canvas ownership checks.</p>
<span class="meta">Regression</span>
- <span class="path">test/p5_specific/multi_instance_async_test.html</span>
+ <span class="path">test/p5/multi_instance_async_test.html</span>
</a>
</div>
</section>
@@ -287,53 +287,53 @@
<span class="path">test/standalone/fill_circle_explorer.html</span>
</a>
- <a class="card" href="./standalone/hatch_test.html">
- <h3>Standalone Hatch Test</h3>
- <p>Exercises hatch angles, spacing, rand/continuous/gradient options, cross-hatching, shape variety, and combined hatch settings.</p>
+ <a class="card" href="./standalone/wash_test.html">
+ <h3>Standalone Wash Test</h3>
+ <p>Draws random rect and circle polygons with palette colors at full opacity in the standalone build.</p>
<span class="meta">Coverage</span>
- <span class="path">test/standalone/hatch_test.html</span>
+ <span class="path">test/standalone/wash_test.html</span>
</a>
- <a class="card" href="./standalone/field_explorer.html">
- <h3>Standalone Flow Field Explorer</h3>
- <p>Interactive field inspector for comparing built-in fields with adjustable density and line length in the standalone build.</p>
- <span class="meta">Explorer</span>
- <span class="path">test/standalone/field_explorer.html</span>
+ <a class="card" href="./standalone/pastel_hatching_test.html">
+ <h3>Standalone Pastel Hatching</h3>
+ <p>Custom crayon brush and centered rectangle for pastel hatching experiments in the standalone build.</p>
+ <span class="meta">Experiment</span>
+ <span class="path">test/standalone/pastel_hatching_test.html</span>
+ </a>
+
+ <a class="card" href="./standalone/angle_mode_test.html">
+ <h3>Standalone Angle Mode</h3>
+ <p>Compares degrees, radians, mixed mode changes, stored hatch angles, and custom fields in the standalone build.</p>
+ <span class="meta">Behavior</span>
+ <span class="path">test/standalone/angle_mode_test.html</span>
</a>
<a class="card" href="./standalone/transform_test.html">
<h3>Standalone Transform Alignment</h3>
<p>Native 2D references are overlaid on standalone brush marks to verify translate, rotate, scale, stroke, and fill alignment.</p>
- <span class="meta">Standalone</span>
+ <span class="meta">Geometry</span>
<span class="path">test/standalone/transform_test.html</span>
</a>
<a class="card" href="./standalone/pushpop_test.html">
<h3>Standalone Push / Pop</h3>
<p>Checks that standalone push/pop restores stroke color, weight, brush type, and fill state.</p>
- <span class="meta">Standalone</span>
+ <span class="meta">State</span>
<span class="path">test/standalone/pushpop_test.html</span>
</a>
- <a class="card" href="./standalone/wash_test.html">
- <h3>Standalone Wash Test</h3>
- <p>Draws random rect and circle polygons with palette colors at full opacity in the standalone build.</p>
+ <a class="card" href="./standalone/hatch_test.html">
+ <h3>Standalone Hatch Test</h3>
+ <p>Exercises hatch angles, spacing, rand/continuous/gradient options, cross-hatching, shape variety, and combined hatch settings.</p>
<span class="meta">Coverage</span>
- <span class="path">test/standalone/wash_test.html</span>
- </a>
-
- <a class="card" href="./standalone/pastel_hatching_test.html">
- <h3>Standalone Pastel Hatching</h3>
- <p>Custom crayon brush and centered rectangle for pastel hatching experiments in the standalone build.</p>
- <span class="meta">Experiment</span>
- <span class="path">test/standalone/pastel_hatching_test.html</span>
+ <span class="path">test/standalone/hatch_test.html</span>
</a>
- <a class="card" href="./standalone/angle_mode_test.html">
- <h3>Standalone Angle Mode</h3>
- <p>Compares degrees, radians, mixed mode changes, stored hatch angles, and custom fields in the standalone build.</p>
- <span class="meta">Behavior</span>
- <span class="path">test/standalone/angle_mode_test.html</span>
+ <a class="card" href="./standalone/field_explorer.html">
+ <h3>Standalone Flow Field Explorer</h3>
+ <p>Interactive field inspector for comparing built-in fields with adjustable density and line length in the standalone build.</p>
+ <span class="meta">Explorer</span>
+ <span class="path">test/standalone/field_explorer.html</span>
</a>
</div>
</section>
diff --git a/test/angle_mode_test.html b/test/p5/angle_mode_test.html
similarity index 92%
rename from test/angle_mode_test.html
rename to test/p5/angle_mode_test.html
index 0a64be1..8c243b1 100644
--- a/test/angle_mode_test.html
+++ b/test/p5/angle_mode_test.html
@@ -5,7 +5,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>p5.brush - Angle Mode Test</title>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/lib/p5.min.js"></script>
- <script src="../dist/p5.brush.js"></script>
+ <script src="../../dist/p5.brush.js"></script>
<script src="./p5_first_frame_profiler.js"></script>
<style>
* {
@@ -91,9 +91,9 @@
<body>
<main>
<div class="nav">
- <a href="./index.html">All tests</a>
+ <a href="../index.html">All tests</a>
<span class="sep">·</span>
- <a href="./standalone/angle_mode_test.html">Standalone →</a>
+ <a href="../standalone/angle_mode_test.html">Standalone →</a>
</div>
<h1>Angle Mode Test</h1>
<p>
@@ -106,6 +106,6 @@
<div id="canvas-host"></div>
<script src="./angle_mode_test.js"></script>
</main>
- <script src="./test-nav.js"></script>
+ <script src="../test-nav.js"></script>
</body>
</html>
diff --git a/test/angle_mode_test.js b/test/p5/angle_mode_test.js
similarity index 100%
rename from test/angle_mode_test.js
rename to test/p5/angle_mode_test.js
diff --git a/test/field_explorer.html b/test/p5/field_explorer.html
similarity index 97%
rename from test/field_explorer.html
rename to test/p5/field_explorer.html
index 7b0492c..dc1bd9a 100644
--- a/test/field_explorer.html
+++ b/test/p5/field_explorer.html
@@ -5,7 +5,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Flow Field Explorer</title>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/lib/p5.min.js"></script>
- <script src="../dist/p5.brush.js"></script>
+ <script src="../../dist/p5.brush.js"></script>
<script src="./p5_first_frame_profiler.js"></script>
<style>
:root {
@@ -126,9 +126,9 @@
<body>
<main>
<div class="nav">
- <a href="./index.html">All tests</a>
+ <a href="../index.html">All tests</a>
<span class="sep">·</span>
- <a href="./standalone/field_explorer.html">Standalone →</a>
+ <a href="../standalone/field_explorer.html">Standalone →</a>
</div>
<h1>Flow Field Explorer</h1>
<p>
@@ -291,6 +291,6 @@
}
</script>
</main>
- <script src="./test-nav.js"></script>
+ <script src="../test-nav.js"></script>
</body>
</html>
diff --git a/test/fill_circle_explorer.html b/test/p5/fill_circle_explorer.html
similarity index 97%
rename from test/fill_circle_explorer.html
rename to test/p5/fill_circle_explorer.html
index 5696f72..f6f8e07 100644
--- a/test/fill_circle_explorer.html
+++ b/test/p5/fill_circle_explorer.html
@@ -5,7 +5,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Fill Circle Explorer</title>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/lib/p5.min.js"></script>
- <script src="../dist/p5.brush.js"></script>
+ <script src="../../dist/p5.brush.js"></script>
<script src="./p5_first_frame_profiler.js"></script>
<style>
:root {
@@ -208,9 +208,9 @@
<body>
<main>
<div class="nav">
- <a href="./index.html">All tests</a>
+ <a href="../index.html">All tests</a>
<span class="sep">·</span>
- <a href="./standalone/fill_circle_explorer.html">Standalone →</a>
+ <a href="../standalone/fill_circle_explorer.html">Standalone →</a>
</div>
<h1>Fill Circle Explorer</h1>
<p>
@@ -285,6 +285,6 @@
<script src="./fill_circle_explorer.js"></script>
</main>
- <script src="./test-nav.js"></script>
+ <script src="../test-nav.js"></script>
</body>
</html>
diff --git a/test/fill_circle_explorer.js b/test/p5/fill_circle_explorer.js
similarity index 100%
rename from test/fill_circle_explorer.js
rename to test/p5/fill_circle_explorer.js
diff --git a/test/hatch_test.html b/test/p5/hatch_test.html
similarity index 91%
rename from test/hatch_test.html
rename to test/p5/hatch_test.html
index 5f40950..6e12518 100644
--- a/test/hatch_test.html
+++ b/test/p5/hatch_test.html
@@ -5,7 +5,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>p5.brush Hatch Test</title>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/lib/p5.min.js"></script>
- <script src="../dist/p5.brush.js"></script>
+ <script src="../../dist/p5.brush.js"></script>
<script src="./p5_first_frame_profiler.js"></script>
<style>
* { box-sizing: border-box; }
@@ -72,9 +72,9 @@
<body>
<main>
<div class="nav">
- <a href="./index.html">All tests</a>
+ <a href="../index.html">All tests</a>
<span class="sep">·</span>
- <a href="./standalone/hatch_test.html">Standalone →</a>
+ <a href="../standalone/hatch_test.html">Standalone →</a>
</div>
<h1>Hatch Test</h1>
<p>
@@ -86,6 +86,6 @@
<div id="canvas-host"></div>
<script src="./hatch_test.js"></script>
</main>
- <script src="./test-nav.js"></script>
+ <script src="../test-nav.js"></script>
</body>
</html>
diff --git a/test/hatch_test.js b/test/p5/hatch_test.js
similarity index 100%
rename from test/hatch_test.js
rename to test/p5/hatch_test.js
diff --git a/test/p5_specific/instance_mode_test.html b/test/p5/instance_mode_test.html
similarity index 97%
rename from test/p5_specific/instance_mode_test.html
rename to test/p5/instance_mode_test.html
index 67cdf5a..4d3ee5c 100644
--- a/test/p5_specific/instance_mode_test.html
+++ b/test/p5/instance_mode_test.html
@@ -6,7 +6,7 @@
<title>p5.brush - Instance Mode Test</title>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/lib/p5.min.js"></script>
<script src="../../dist/p5.brush.js"></script>
- <script src="../p5_first_frame_profiler.js"></script>
+ <script src="./p5_first_frame_profiler.js"></script>
<style>
* {
box-sizing: border-box;
diff --git a/test/p5_specific/instance_mode_test.js b/test/p5/instance_mode_test.js
similarity index 100%
rename from test/p5_specific/instance_mode_test.js
rename to test/p5/instance_mode_test.js
diff --git a/test/p5_specific/multi_instance_async_test.html b/test/p5/multi_instance_async_test.html
similarity index 99%
rename from test/p5_specific/multi_instance_async_test.html
rename to test/p5/multi_instance_async_test.html
index 84383e6..09c161b 100644
--- a/test/p5_specific/multi_instance_async_test.html
+++ b/test/p5/multi_instance_async_test.html
@@ -6,7 +6,7 @@
<title>p5.brush - Async Multi-Instance Test</title>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/lib/p5.min.js"></script>
<script src="../../dist/p5.brush.js"></script>
- <script src="../p5_first_frame_profiler.js"></script>
+ <script src="./p5_first_frame_profiler.js"></script>
<style>
:root {
--bg: #f4efe6;
diff --git a/test/p5_specific/multi_instance_async_test.js b/test/p5/multi_instance_async_test.js
similarity index 100%
rename from test/p5_specific/multi_instance_async_test.js
rename to test/p5/multi_instance_async_test.js
diff --git a/test/p5_specific/offscreen_target_test.html b/test/p5/offscreen_target_test.html
similarity index 98%
rename from test/p5_specific/offscreen_target_test.html
rename to test/p5/offscreen_target_test.html
index 7c64b1c..d0072f4 100644
--- a/test/p5_specific/offscreen_target_test.html
+++ b/test/p5/offscreen_target_test.html
@@ -6,7 +6,7 @@
<title>p5.brush - Offscreen Target Test</title>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/lib/p5.min.js"></script>
<script src="../../dist/p5.brush.js"></script>
- <script src="../p5_first_frame_profiler.js"></script>
+ <script src="./p5_first_frame_profiler.js"></script>
<style>
* {
box-sizing: border-box;
diff --git a/test/p5_specific/offscreen_target_test.js b/test/p5/offscreen_target_test.js
similarity index 100%
rename from test/p5_specific/offscreen_target_test.js
rename to test/p5/offscreen_target_test.js
diff --git a/test/p5_first_frame_profiler.js b/test/p5/p5_first_frame_profiler.js
similarity index 100%
rename from test/p5_first_frame_profiler.js
rename to test/p5/p5_first_frame_profiler.js
diff --git a/test/pastel_hatching_test.html b/test/p5/pastel_hatching_test.html
similarity index 96%
rename from test/pastel_hatching_test.html
rename to test/p5/pastel_hatching_test.html
index 8052680..35f3e02 100644
--- a/test/pastel_hatching_test.html
+++ b/test/p5/pastel_hatching_test.html
@@ -5,7 +5,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Pastel Hatching Test</title>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/lib/p5.min.js"></script>
- <script src="../dist/p5.brush.js"></script>
+ <script src="../../dist/p5.brush.js"></script>
<script src="./p5_first_frame_profiler.js"></script>
<style>
:root {
@@ -193,9 +193,9 @@
<body>
<main>
<div class="nav">
- <a href="./index.html">All tests</a>
+ <a href="../index.html">All tests</a>
<span class="sep">·</span>
- <a href="./standalone/pastel_hatching_test.html">Standalone →</a>
+ <a href="../standalone/pastel_hatching_test.html">Standalone →</a>
</div>
<h1>Pastel Hatching Test</h1>
<p>
@@ -257,6 +257,6 @@
</div>
</main>
<script src="./pastel_hatching_test.js"></script>
- <script src="./test-nav.js"></script>
+ <script src="../test-nav.js"></script>
</body>
</html>
diff --git a/test/pastel_hatching_test.js b/test/p5/pastel_hatching_test.js
similarity index 100%
rename from test/pastel_hatching_test.js
rename to test/p5/pastel_hatching_test.js
diff --git a/test/pushpop_test.html b/test/p5/pushpop_test.html
similarity index 96%
rename from test/pushpop_test.html
rename to test/p5/pushpop_test.html
index 4e6ea18..7ece7cf 100644
--- a/test/pushpop_test.html
+++ b/test/p5/pushpop_test.html
@@ -5,7 +5,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>p5.brush - Push/Pop Test</title>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/lib/p5.min.js"></script>
- <script src="../dist/p5.brush.js"></script>
+ <script src="../../dist/p5.brush.js"></script>
<script src="./p5_first_frame_profiler.js"></script>
<style>
* { box-sizing: border-box; }
@@ -72,9 +72,9 @@
<body>
<main>
<div class="nav">
- <a href="./index.html">All tests</a>
+ <a href="../index.html">All tests</a>
<span class="sep">·</span>
- <a href="./standalone/pushpop_test.html">Standalone →</a>
+ <a href="../standalone/pushpop_test.html">Standalone →</a>
</div>
<h1>Push / Pop State Test</h1>
<p>
@@ -214,6 +214,6 @@
}
</script>
</main>
- <script src="./test-nav.js"></script>
+ <script src="../test-nav.js"></script>
</body>
</html>
diff --git a/test/transform_test.html b/test/p5/transform_test.html
similarity index 97%
rename from test/transform_test.html
rename to test/p5/transform_test.html
index fb0fd4c..b0f0eee 100644
--- a/test/transform_test.html
+++ b/test/p5/transform_test.html
@@ -5,7 +5,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>p5.brush - Transform Test</title>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/lib/p5.min.js"></script>
- <script src="../dist/p5.brush.js"></script>
+ <script src="../../dist/p5.brush.js"></script>
<script src="./p5_first_frame_profiler.js"></script>
<style>
* { box-sizing: border-box; }
@@ -72,9 +72,9 @@
<body>
<main>
<div class="nav">
- <a href="./index.html">All tests</a>
+ <a href="../index.html">All tests</a>
<span class="sep">·</span>
- <a href="./standalone/transform_test.html">Standalone →</a>
+ <a href="../standalone/transform_test.html">Standalone →</a>
</div>
<h1>Transform Alignment Test</h1>
<p>
@@ -268,6 +268,6 @@
}
</script>
</main>
- <script src="./test-nav.js"></script>
+ <script src="../test-nav.js"></script>
</body>
</html>
diff --git a/test/visual_suite.html b/test/p5/visual_suite.html
similarity index 90%
rename from test/visual_suite.html
rename to test/p5/visual_suite.html
index a4d5fc4..f9aa7b1 100644
--- a/test/visual_suite.html
+++ b/test/p5/visual_suite.html
@@ -5,7 +5,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>p5.brush Visual Suite</title>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/lib/p5.min.js"></script>
- <script src="../dist/p5.brush.js"></script>
+ <script src="../../dist/p5.brush.js"></script>
<script src="./p5_first_frame_profiler.js"></script>
<style>
* { box-sizing: border-box; }
@@ -79,9 +79,9 @@
<body>
<main>
<div class="nav">
- <a href="./index.html">All tests</a>
+ <a href="../index.html">All tests</a>
<span class="sep">·</span>
- <a href="./standalone/visual_suite.html">Standalone →</a>
+ <a href="../standalone/visual_suite.html">Standalone →</a>
</div>
<h1>Visual API Suite</h1>
<p>
@@ -91,8 +91,8 @@
The browser console still receives the error-message checks, but the canvas itself is the main verification surface.
</p>
<div id="canvas-host"></div>
- <script src="./sketch.js"></script>
+ <script src="./visual_suite.js"></script>
</main>
- <script src="./test-nav.js"></script>
+ <script src="../test-nav.js"></script>
</body>
</html>
diff --git a/test/sketch.js b/test/p5/visual_suite.js
similarity index 99%
rename from test/sketch.js
rename to test/p5/visual_suite.js
index 3df6e68..a514a9e 100644
--- a/test/sketch.js
+++ b/test/p5/visual_suite.js
@@ -193,7 +193,7 @@ async function setup() {
spacing: 1.5,
pressure: [0.8, 1.2],
rotate: "random",
- image: { src: "../example/brush_tips/brush.jpg" },
+ image: { src: "../../example/brush_tips/brush.jpg" },
});
// ---- Add custom tip brush ----
diff --git a/test/wash_test.html b/test/p5/wash_test.html
similarity index 94%
rename from test/wash_test.html
rename to test/p5/wash_test.html
index 60d6103..67a573e 100644
--- a/test/wash_test.html
+++ b/test/p5/wash_test.html
@@ -5,7 +5,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Wash Test</title>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/lib/p5.min.js"></script>
- <script src="../dist/p5.brush.js"></script>
+ <script src="../../dist/p5.brush.js"></script>
<script src="./p5_first_frame_profiler.js"></script>
<style>
:root {
@@ -128,9 +128,9 @@
<body>
<main>
<div class="nav">
- <a href="./index.html">All tests</a>
+ <a href="../index.html">All tests</a>
<span class="sep">·</span>
- <a href="./standalone/wash_test.html">Standalone →</a>
+ <a href="../standalone/wash_test.html">Standalone →</a>
</div>
<h1>Wash Test</h1>
<p>
@@ -151,6 +151,6 @@
<div id="canvas-host" class="panel"></div>
</main>
<script src="./wash_test.js"></script>
- <script src="./test-nav.js"></script>
+ <script src="../test-nav.js"></script>
</body>
</html>
diff --git a/test/wash_test.js b/test/p5/wash_test.js
similarity index 100%
rename from test/wash_test.js
rename to test/p5/wash_test.js
diff --git a/test/standalone/angle_mode_test.html b/test/standalone/angle_mode_test.html
index bebafb2..d3a65d0 100644
--- a/test/standalone/angle_mode_test.html
+++ b/test/standalone/angle_mode_test.html
@@ -72,9 +72,9 @@
<body>
<main>
<div class="nav">
- <a href="../index.html">All tests</a>
+ <a href="../p5/index.html">All tests</a>
<span class="sep">·</span>
- <a href="../angle_mode_test.html">← p5 version</a>
+ <a href="../p5/angle_mode_test.html">← p5 version</a>
</div>
<h1>Angle Mode Test <small style="font-size:0.55em;color:#8a9aa8;">standalone</small></h1>
<p>
diff --git a/test/standalone/field_explorer.html b/test/standalone/field_explorer.html
index 02cedf4..faef5f0 100644
--- a/test/standalone/field_explorer.html
+++ b/test/standalone/field_explorer.html
@@ -115,9 +115,9 @@
<body>
<main>
<div class="nav">
- <a href="../index.html">All tests</a>
+ <a href="../p5/index.html">All tests</a>
<span class="sep">·</span>
- <a href="../field_explorer.html">← p5 version</a>
+ <a href="../p5/field_explorer.html">← p5 version</a>
</div>
<h1>Flow Field Explorer <small style="font-size:0.55em;color:#8a9aa8;">standalone</small></h1>
<p>
diff --git a/test/standalone/fill_circle_explorer.html b/test/standalone/fill_circle_explorer.html
index 07f283d..9d2e33a 100644
--- a/test/standalone/fill_circle_explorer.html
+++ b/test/standalone/fill_circle_explorer.html
@@ -176,9 +176,9 @@
<body>
<main>
<div class="nav">
- <a href="../index.html">All tests</a>
+ <a href="../p5/index.html">All tests</a>
<span class="sep">·</span>
- <a href="../fill_circle_explorer.html">← p5 version</a>
+ <a href="../p5/fill_circle_explorer.html">← p5 version</a>
</div>
<h1>Fill Circle Explorer <small style="font-size:0.55em;color:#8a9aa8;">standalone</small></h1>
<p>
diff --git a/test/standalone/hatch_test.html b/test/standalone/hatch_test.html
index c821922..9fae9fa 100644
--- a/test/standalone/hatch_test.html
+++ b/test/standalone/hatch_test.html
@@ -72,9 +72,9 @@
<body>
<main>
<div class="nav">
- <a href="../index.html">All tests</a>
+ <a href="../p5/index.html">All tests</a>
<span class="sep">·</span>
- <a href="../hatch_test.html">← p5 version</a>
+ <a href="../p5/hatch_test.html">← p5 version</a>
</div>
<h1>Hatch Test <small style="font-size:0.55em;color:#8a9aa8;">standalone</small></h1>
<p>
diff --git a/test/standalone/pastel_hatching_test.html b/test/standalone/pastel_hatching_test.html
index 779ccf1..068d839 100644
--- a/test/standalone/pastel_hatching_test.html
+++ b/test/standalone/pastel_hatching_test.html
@@ -127,9 +127,9 @@
<body>
<main>
<div class="nav">
- <a href="../index.html">All tests</a>
+ <a href="../p5/index.html">All tests</a>
<span class="sep">·</span>
- <a href="../pastel_hatching_test.html">← p5 version</a>
+ <a href="../p5/pastel_hatching_test.html">← p5 version</a>
</div>
<h1>Pastel Hatching <small style="font-size:0.55em;color:#8a9aa8;">standalone</small></h1>
<p>
diff --git a/test/standalone/pushpop_test.html b/test/standalone/pushpop_test.html
index ee1d773..79c83e0 100644
--- a/test/standalone/pushpop_test.html
+++ b/test/standalone/pushpop_test.html
@@ -72,9 +72,9 @@
<body>
<main>
<div class="nav">
- <a href="../index.html">All tests</a>
+ <a href="../p5/index.html">All tests</a>
<span class="sep">·</span>
- <a href="../pushpop_test.html">← p5 version</a>
+ <a href="../p5/pushpop_test.html">← p5 version</a>
</div>
<h1>Push / Pop State <small style="font-size:0.55em;color:#8a9aa8;">standalone</small></h1>
<p>
diff --git a/test/standalone/transform_test.html b/test/standalone/transform_test.html
index 9a18de0..a2a3c89 100644
--- a/test/standalone/transform_test.html
+++ b/test/standalone/transform_test.html
@@ -72,9 +72,9 @@
<body>
<main>
<div class="nav">
- <a href="../index.html">All tests</a>
+ <a href="../p5/index.html">All tests</a>
<span class="sep">·</span>
- <a href="../transform_test.html">← p5 version</a>
+ <a href="../p5/transform_test.html">← p5 version</a>
</div>
<h1>Transform Alignment <small style="font-size:0.55em;color:#8a9aa8;">standalone</small></h1>
<p>
diff --git a/test/standalone/visual_suite.html b/test/standalone/visual_suite.html
index e2f924c..192ecda 100644
--- a/test/standalone/visual_suite.html
+++ b/test/standalone/visual_suite.html
@@ -72,9 +72,9 @@
<body>
<main>
<div class="nav">
- <a href="../index.html">All tests</a>
+ <a href="../p5/index.html">All tests</a>
<span class="sep">·</span>
- <a href="../visual_suite.html">← p5 version</a>
+ <a href="../p5/visual_suite.html">← p5 version</a>
</div>
<h1>Visual API Suite <small style="font-size:0.55em;color:#8a9aa8;">standalone</small></h1>
<p>
diff --git a/test/standalone/wash_test.html b/test/standalone/wash_test.html
index 70dd7f7..5ce504d 100644
--- a/test/standalone/wash_test.html
+++ b/test/standalone/wash_test.html
@@ -113,9 +113,9 @@
<body>
<main>
<div class="nav">
- <a href="../index.html">All tests</a>
+ <a href="../p5/index.html">All tests</a>
<span class="sep">·</span>
- <a href="../wash_test.html">← p5 version</a>
+ <a href="../p5/wash_test.html">← p5 version</a>
</div>
<h1>Wash Test <small style="font-size:0.55em;color:#8a9aa8;">standalone</small></h1>
<p>
diff --git a/test/test-nav.js b/test/test-nav.js
index d94e2cd..5bc768c 100644
--- a/test/test-nav.js
+++ b/test/test-nav.js
@@ -1,29 +1,29 @@
(() => {
const GROUPS = [
[
- "visual_suite.html",
- "fill_circle_explorer.html",
- "wash_test.html",
- "pastel_hatching_test.html",
- "angle_mode_test.html",
- "transform_test.html",
- "pushpop_test.html",
- "hatch_test.html",
- "field_explorer.html",
- "p5_specific/offscreen_target_test.html",
- "p5_specific/instance_mode_test.html",
- "p5_specific/multi_instance_async_test.html",
+ "p5/visual_suite.html",
+ "p5/fill_circle_explorer.html",
+ "p5/wash_test.html",
+ "p5/pastel_hatching_test.html",
+ "p5/angle_mode_test.html",
+ "p5/transform_test.html",
+ "p5/pushpop_test.html",
+ "p5/hatch_test.html",
+ "p5/field_explorer.html",
+ "p5/offscreen_target_test.html",
+ "p5/instance_mode_test.html",
+ "p5/multi_instance_async_test.html",
],
[
"standalone/visual_suite.html",
"standalone/fill_circle_explorer.html",
- "standalone/hatch_test.html",
- "standalone/field_explorer.html",
- "standalone/transform_test.html",
- "standalone/pushpop_test.html",
"standalone/wash_test.html",
"standalone/pastel_hatching_test.html",
"standalone/angle_mode_test.html",
+ "standalone/transform_test.html",
+ "standalone/pushpop_test.html",
+ "standalone/hatch_test.html",
+ "standalone/field_explorer.html",
],
];
diff --git a/test/fill.test.js b/test/unit/fill.test.js
similarity index 86%
rename from test/fill.test.js
rename to test/unit/fill.test.js
index 5a52e53..7e83be7 100644
--- a/test/fill.test.js
+++ b/test/unit/fill.test.js
@@ -21,7 +21,7 @@ const { blend, mockCtx, mockState } = vi.hoisted(() => ({
mockState: {},
}));
-vi.mock("../src/core/color.js", () => ({
+vi.mock("../../src/core/color.js", () => ({
Mix: {
blend,
ctx: mockCtx,
@@ -32,7 +32,7 @@ vi.mock("../src/core/color.js", () => ({
registerFillComposite: () => {},
}));
-vi.mock("../src/core/target.js", () => ({
+vi.mock("../../src/core/target.js", () => ({
Renderer: {
color: () => ({
_getBlue: () => 64,
@@ -45,12 +45,12 @@ vi.mock("../src/core/target.js", () => ({
Density: 1,
}));
-vi.mock("../src/fill/mask.js", () => ({
+vi.mock("../../src/fill/mask.js", () => ({
circle: vi.fn(),
drawPolygon: vi.fn(),
}));
-vi.mock("../src/core/flowfield.js", () => ({
+vi.mock("../../src/core/flowfield.js", () => ({
Matrix: {
a: () => 1,
b: () => 0,
@@ -62,15 +62,15 @@ vi.mock("../src/core/flowfield.js", () => ({
isFieldReady: () => {},
}));
-vi.mock("../src/core/polygon.js", () => ({
+vi.mock("../../src/core/polygon.js", () => ({
Polygon: class Polygon {},
}));
-vi.mock("../src/core/plot.js", () => ({
+vi.mock("../../src/core/plot.js", () => ({
Plot: class Plot {},
}));
-vi.mock("../src/core/runtime.js", () => ({
+vi.mock("../../src/core/runtime.js", () => ({
createColor: (r, g, b) => ({
r: typeof r === 'string' ? 255 : r,
g: g ?? r ?? 0,
@@ -84,7 +84,7 @@ vi.mock("../src/core/runtime.js", () => ({
}),
}));
-import { createFill, fill } from "../src/fill/fill.js";
+import { createFill, fill } from "../../src/fill/fill.js";
describe("createFill()", () => {
beforeEach(() => {
diff --git a/test/stroke_pressure.test.js b/test/unit/stroke_pressure.test.js
similarity index 87%
rename from test/stroke_pressure.test.js
rename to test/unit/stroke_pressure.test.js
index 15bd377..6f9ecd3 100644
--- a/test/stroke_pressure.test.js
+++ b/test/unit/stroke_pressure.test.js
@@ -1,20 +1,20 @@
import { describe, it, expect, vi } from "vitest";
-vi.mock("../src/core/color.js", () => ({
+vi.mock("../../src/core/color.js", () => ({
Mix: {},
State: {},
isCanvasReady: () => {},
registerStrokeComposite: () => {},
}));
-vi.mock("../src/core/target.js", () => ({
+vi.mock("../../src/core/target.js", () => ({
Cwidth: 800,
Cheight: 600,
Renderer: {},
Instance: null,
}));
-vi.mock("../src/core/utils.js", () => ({
+vi.mock("../../src/core/utils.js", () => ({
rr: () => 0,
map: (value, start1, stop1, start2, stop2) =>
start2 + ((value - start1) / (stop1 - start1 || 1)) * (stop2 - start2),
@@ -28,7 +28,7 @@ vi.mock("../src/core/utils.js", () => ({
_onSeed: () => {},
}));
-vi.mock("../src/core/flowfield.js", () => ({
+vi.mock("../../src/core/flowfield.js", () => ({
Position: class Position {},
Matrix: {
a: () => 1,
@@ -41,15 +41,15 @@ vi.mock("../src/core/flowfield.js", () => ({
isFieldReady: () => {},
}));
-vi.mock("../src/core/polygon.js", () => ({
+vi.mock("../../src/core/polygon.js", () => ({
Polygon: class Polygon {},
}));
-vi.mock("../src/core/plot.js", () => ({
+vi.mock("../../src/core/plot.js", () => ({
Plot: class Plot {},
}));
-vi.mock("../src/stroke/gl_draw.js", () => ({
+vi.mock("../../src/stroke/gl_draw.js", () => ({
isReady: () => {},
glDraw: () => {},
glDrawImages: () => {},
@@ -59,7 +59,7 @@ vi.mock("../src/stroke/gl_draw.js", () => ({
snapshotMatrix: () => {},
}));
-import { add, box, normalizePressure } from "../src/stroke/stroke.js";
+import { add, box, normalizePressure } from "../../src/stroke/stroke.js";
describe("normalizePressure()", () => {
it("keeps function pressure in explicit custom mode", () => {
diff --git a/test/unit.test.js b/test/unit/unit.test.js
similarity index 96%
rename from test/unit.test.js
rename to test/unit/unit.test.js
index 0c0591d..e3e3e38 100644
--- a/test/unit.test.js
+++ b/test/unit/unit.test.js
@@ -14,7 +14,7 @@ const { currentAngleMode, mockState, plotInstances } = vi.hoisted(() => ({
}));
// Mock color.js (pulls in GLSL shaders and WebGL — not available in Node)
-vi.mock("../src/core/color.js", () => ({
+vi.mock("../../src/core/color.js", () => ({
Mix: {},
State: mockState,
isCanvasReady: () => {},
@@ -22,7 +22,7 @@ vi.mock("../src/core/color.js", () => ({
}));
// Mock runtime.js to properly handle angle mode
-vi.mock("../src/core/runtime.js", () => ({
+vi.mock("../../src/core/runtime.js", () => ({
usesRadians: () => currentAngleMode.value === "radians",
fromDegrees: (angle) => currentAngleMode.value === "radians" ? (angle * Math.PI) / 180 : angle,
createColor: () => ({}),
@@ -30,7 +30,7 @@ vi.mock("../src/core/runtime.js", () => ({
setRuntime: () => {},
}));
-vi.mock("../src/core/target.js", () => ({
+vi.mock("../../src/core/target.js", () => ({
Renderer: {
angleMode: () => currentAngleMode.value,
RADIANS: "radians",
@@ -45,18 +45,18 @@ vi.mock("../src/core/target.js", () => ({
Cheight: 600,
}));
-vi.mock("../src/stroke/stroke.js", () => ({
+vi.mock("../../src/stroke/stroke.js", () => ({
BrushState: () => ({}),
BrushSetState: () => {},
set: () => {},
line: () => {},
}));
-vi.mock("../src/core/polygon.js", () => ({
+vi.mock("../../src/core/polygon.js", () => ({
Polygon: class Polygon {},
}));
-vi.mock("../src/core/plot.js", () => ({
+vi.mock("../../src/core/plot.js", () => ({
Plot: class Plot {
constructor(type) {
this.type = type;
@@ -81,10 +81,10 @@ import {
seed,
weightedRand,
toDegreesSigned,
-} from "../src/core/utils.js";
-import { arc } from "../src/core/primitives.js";
-import { Position, addField, field as activateField, noField } from "../src/core/flowfield.js";
-import { hatch } from "../src/hatch/hatch.js";
+} from "../../src/core/utils.js";
+import { arc } from "../../src/core/primitives.js";
+import { Position, addField, field as activateField, noField } from "../../src/core/flowfield.js";
+import { hatch } from "../../src/hatch/hatch.js";
beforeEach(() => {
currentAngleMode.value = "radians";
diff --git a/vitest.config.js b/vitest.config.js
index c16046f..106adff 100644
--- a/vitest.config.js
+++ b/vitest.config.js
@@ -3,6 +3,6 @@ import { defineConfig } from "vitest/config";
export default defineConfig({
test: {
environment: "node",
- include: ["test/**/*.test.js"],
+ include: ["test/unit/**/*.test.js"],
},
});