Skip to content

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

docs: restructure llms.txt to clearly separate p5 and standalone builds

acamposuribedd201d681c0f
diff --git a/llms.txt b/llms.txt
index ce1d598..62df833 100644
--- a/llms.txt
+++ b/llms.txt
@@ -1,8 +1,32 @@
# p5.brush
-p5.brush is a p5.js library for natural drawing — pencils, charcoal, markers, watercolor fills, hatch patterns, and vector fields. Requires **p5.js 2.x** and a **WEBGL canvas**.
+p5.brush is a natural drawing library — pencils, charcoal, markers, watercolor fills, hatch patterns, and vector fields.
-## Installation
+---
+
+## ⚠️ TWO BUILDS — READ THIS FIRST
+
+p5.brush ships in **two completely different builds**. Before generating any code, identify which build the user is using. Getting this wrong produces broken code.
+
+| | **p5 build** | **Standalone build** |
+|---|---|---|
+| File | `dist/p5.brush.js` | `dist/brush.js` / `dist/brush.esm.js` |
+| Requires | p5.js 2.x | Nothing — browser WebGL2 only |
+| Canvas | `createCanvas(w, h, WEBGL)` — p5 creates it | `brush.createCanvas(w, h)` — brush creates it |
+| Transforms | p5's `push()`, `pop()`, `translate()`, `rotate()`, `scale()` | `brush.push()`, `brush.pop()`, `brush.translate()`, `brush.rotate()`, `brush.scale()` |
+| Angle mode | p5's `angleMode(DEGREES / RADIANS)` | `brush.angleMode(brush.DEGREES / brush.RADIANS)` |
+| Seeding | `randomSeed(n)` / `noiseSeed(n)` | `brush.seed(n)` / `brush.noiseSeed(n)` |
+| Frame flush | Automatic — p5 handles it | **Must call `brush.render()`** at end of each frame |
+| Clear canvas | p5's `background()` | `brush.clear(color?)` |
+| Offscreen targets | `brush.load(p5Graphics \| framebuffer)` | `brush.load(htmlCanvas \| offscreenCanvas)` |
+
+**Do not mix these up.** Using p5 functions (`push`, `background`, `randomSeed`, etc.) in a standalone sketch will break silently or throw errors. Using `brush.render()` or `brush.clear()` in a p5 sketch is unnecessary and wrong.
+
+---
+
+## p5 build
+
+### Installation
```html
<script src="https://cdn.jsdelivr.net/npm/[email protected]/lib/p5.min.js"></script>
@@ -14,55 +38,195 @@ p5.brush is a p5.js library for natural drawing — pencils, charcoal, markers,
import * as brush from 'p5.brush'
```
-## Setup
+### Setup
-The canvas **must use WEBGL mode**. The library initializes automatically when `createCanvas()` is called, so for the **main canvas** you normally do **not** need `brush.load()`.
+The canvas **must use WEBGL mode**. The library initializes automatically when `createCanvas()` is called — **no `brush.load()` needed for the main canvas**.
```js
-async function setup() {
+function setup() {
createCanvas(600, 600, WEBGL)
- angleMode(DEGREES) // optional, but all angle-taking brush APIs follow p5's angleMode
- brush.scaleBrushes(3) // usually necessary: good starting point for a 600x600 canvas, then confirm visually
+ angleMode(DEGREES) // brush angle APIs follow p5's angleMode
+ brush.scaleBrushes(3) // scale brushes to canvas size; 3 is a good start for 600×600
+}
+
+function draw() {
+ background("#fffceb")
+ translate(-width/2, -height/2) // WEBGL origin is center — shift to top-left
+
+ brush.set("HB", "#222", 1)
+ brush.line(50, 50, 550, 550)
}
```
-In **instance mode**, call `brush.instance(p)` before setup/draw — auto-initialization still applies:
+### p5 integration — what hooks automatically
+
+- `push()` / `pop()` — saves and restores brush stroke, fill, and hatch state
+- `translate()`, `rotate()`, `scale()` — all p5 transforms apply to brush strokes
+- `randomSeed(n)` — seeds both p5 and the brush library
+- `noiseSeed(n)` — seeds both p5 noise and the brush library
+- `angleMode(mode)` — all brush angle APIs follow p5's current angle mode
+
+**No separate `brush.push()`, `brush.translate()`, or `brush.seed()` calls are needed or exist in this build.**
+
+### Instance mode
```js
const sketch = (p) => {
- brush.instance(p)
+ brush.instance(p) // must be called before setup/draw
p.setup = () => { p.createCanvas(600, 600, p.WEBGL) }
+ p.draw = () => { ... }
}
new p5(sketch)
```
-## p5 Integration
+### Offscreen targets (p5 build)
-p5.brush hooks into p5 automatically:
-- `push()` / `pop()` — saves and restores brush stroke, fill, and hatch state
-- `translate()`, `rotate()`, `scale()` — all p5 transforms apply to brush strokes
-- `randomSeed(n)` — seeds both p5 and the brush library
-- `noiseSeed(n)` — seeds both p5 noise and the brush library
-- `angleMode(mode)` — public brush APIs that accept angles follow p5's current angle mode; with no `angleMode()` call, this defaults to radians just like p5
+`brush.load()` is only for redirecting drawing to a secondary surface:
-No separate `brush.push()`, `brush.translate()`, or `brush.seed()` calls are needed.
-Exception: `brush.addField(name, fn, { angleMode })` lets custom field generators declare whether returned angles are in degrees or radians before the library stores them internally in degrees.
+```js
+// p5.Graphics
+const pg = createGraphics(300, 200, WEBGL)
+brush.load(pg)
+brush.set("HB", "black", 1)
+brush.circle(150, 100, 70)
+brush.load() // restore main canvas
+image(pg, 20, 20)
+
+// p5.Framebuffer
+const fb = createFramebuffer({ width: 300, height: 200 })
+fb.draw(() => {
+ brush.load(fb)
+ brush.circle(150, 100, 70)
+})
+brush.load()
+image(fb, 20, 240)
+```
---
-## API Reference
+## Standalone build
+
+### Installation
+
+```html
+<!-- UMD — exposes global `brush` -->
+<script src="path_to/brush.js"></script>
+```
+
+```js
+// ESM
+import * as brush from './dist/brush.esm.js'
+```
+
+### Setup
+
+Use `brush.createCanvas()` — it creates the canvas **and** loads it as the draw target automatically. No separate `brush.load()` needed.
+
+```js
+import * as brush from './dist/brush.esm.js'
+
+brush.createCanvas(600, 600, {
+ parent: document.body,
+ pixelDensity: window.devicePixelRatio,
+})
+brush.scaleBrushes(3)
+brush.angleMode(brush.DEGREES)
+brush.seed(42)
+```
+
+`brush.load(canvas)` is only needed if you create the canvas yourself:
+
+```js
+const canvas = document.createElement('canvas')
+canvas.width = 600; canvas.height = 600
+document.body.appendChild(canvas)
+brush.load(canvas) // register external canvas as draw target
+```
+
+### Frame lifecycle — mandatory
+
+The standalone build does **not** flush or clear automatically. You must do both yourself every frame.
+
+```js
+brush.clear('#f5f0e0') // clear to background color
+brush.push()
+brush.translate(-W/2, -H/2) // WEBGL origin is center — shift to top-left
+
+// ... all drawing calls here ...
+
+brush.pop()
+brush.render() // ← REQUIRED: flush compositing to canvas
+```
+
+**Forgetting `brush.render()` means nothing appears on screen.**
+
+### Transforms (standalone)
+
+```js
+brush.push() // saves transform + brush state
+brush.pop() // restores
+brush.translate(x, y)
+brush.rotate(angle) // angle follows brush.angleMode()
+brush.scale(x, y?) // omit y to scale uniformly
+```
+
+### Angle mode (standalone)
+
+```js
+brush.angleMode(brush.DEGREES) // all angle APIs use degrees
+brush.angleMode(brush.RADIANS) // default
+```
+
+### Seeding (standalone)
+
+```js
+brush.seed(42)
+brush.noiseSeed(42)
+```
+
+### Standalone example
+
+```js
+import * as brush from './dist/brush.esm.js'
+
+const W = 600, H = 600
+brush.createCanvas(W, H, { parent: document.body })
+brush.scaleBrushes(3)
+brush.angleMode(brush.DEGREES)
+brush.seed(42)
+
+brush.clear('#f5f0e0')
+brush.push()
+brush.translate(-W/2, -H/2)
+
+brush.set('HB', '#222', 1)
+brush.line(50, 50, 550, 550)
+
+brush.fill('#003c32', 120)
+brush.fillBleed(0.15)
+brush.noStroke()
+brush.circle(300, 300, 120)
+
+brush.pop()
+brush.render() // required
+```
+
+---
+
+## Shared API (both builds)
+
+Everything below works identically in both builds. The only differences are setup, transforms, angle mode, seeding, frame flush, and clear — all covered above.
### Configuration
-- `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.scaleBrushes(scale)` — Scale all currently registered brushes. Usually necessary to match canvas size. `3` is a good starting point for a 600×600 canvas; confirm visually. Call before adding custom brushes if you only want built-ins scaled.
+- `brush.load(target)` — Redirect drawing to a secondary target. In the **p5 build**: pass a `p5.Graphics` (WEBGL) or active `p5.Framebuffer`; call with no args to restore the main canvas. In the **standalone build**: pass an `HTMLCanvasElement` or `OffscreenCanvas`; call again to switch targets.
---
### Stroke Operations
-- `brush.set(name, color, weight)` — Set brush name, color (hex string or p5.Color), and weight multiplier. Enables stroke.
+- `brush.set(name, color, weight)` — Set brush name, color (hex string or p5.Color in p5 build; hex/CSS string in standalone), and weight multiplier. Enables stroke.
- `brush.pick(name)` — Change brush type only, keeping current color and weight.
- `brush.stroke(r, g, b)` or `brush.stroke(color)` — Set stroke color. Enables stroke.
- `brush.strokeWeight(weight)` — Set weight multiplier only.
@@ -74,30 +238,22 @@ Exception: `brush.addField(name, fn, { angleMode })` lets custom field generator
Fill simulates watercolor — soft edges, bleed, texture layering.
-- `brush.fill(color, opacity)` or `brush.fill(r, g, b, opacity)` — Set fill color. Opacity uses p5-style alpha values (typically 0–255). Enables fill.
+- `brush.fill(color, opacity)` or `brush.fill(r, g, b, opacity)` — Set fill color. Opacity 0–255. Enables fill.
- `brush.noFill()` — Disable fill.
-- `brush.wash(color, opacity)` — Fast solid fill pass for subsequent shapes. No watercolor bleed or texture simulation.
+- `brush.wash(color, opacity)` — Fast solid fill, no watercolor simulation.
- `brush.noWash()` — Disable wash.
-- `brush.fillBleed(strength, direction?)` — Edge bleed amount, 0–1. Direction: `"out"` or `"in"`.
+- `brush.fillBleed(strength, direction?)` — Edge bleed 0–1. Direction: `"out"` or `"in"`.
- `brush.fillTexture(textureStrength, borderIntensity)` — Texture and border, both 0–1.
-- For better fill performance, prefer drawing fills in color batches when possible. Group shapes by fill color/opacities so the library can reuse its internal color-specific caching more effectively.
+- For better fill performance, group shapes by fill color/opacity so the library can reuse its internal caching.
---
### Hatch Operations
-Hatching draws parallel lines inside shapes. Activate before drawing a shape, disable after.
-
-- `brush.hatch(dist, angle, options?)` — Enable hatching. `dist` = spacing in canvas units, `angle` is interpreted using the current `angleMode()` when `brush.hatch()` is called. Options: `{rand: 0–1, continuous: bool, gradient: 0–1}`.
+- `brush.hatch(dist, angle, options?)` — Enable hatching. `dist` = spacing in canvas units. `angle` follows current `angleMode()`. Options: `{rand: 0–1, continuous: bool, gradient: 0–1}`.
- `brush.noHatch()` — Disable hatching.
-- `brush.hatchStyle(name, color, weight)` — Set brush used for hatching (independent of stroke brush).
-- `brush.mass(brushName, color, options?)` — Enable a dry-media, hand-filled hatched fill for subsequent shapes. It emulates hand movement, is built from internal hatch geometry and curved gestures, and works best with crayon or pastel brushes. Unlike `brush.fill()`, which simulates watercolor transparency, `mass()` builds denser, more opaque pigment layers, so overlapping shapes can mix color in a pigment-like way and draw order matters.
-- `brush.mass(...)` does not inherit the current brush from `brush.set()` or `brush.pick()`; `brushName` is required explicitly.
-- `brush.mass(...)` options:
-- `precision` = 0–1 control over hand jitter and hatch irregularity. Lower values feel rougher and looser; higher values feel steadier and more controlled.
-- `strength` = 0–1 control over how many internal mass passes are drawn. Low values use a single pass, mid values add a second pass, and high values build all three passes for denser pigment.
-- `gradient` = 0–1 directional fade across the mass. It also slightly tightens the internal hatch spacing as the gradient increases.
-- `outline` = whether to draw the shape's outer contour with the same brush and color before the mass fill.
+- `brush.hatchStyle(name, color, weight)` — Set brush used for hatching.
+- `brush.mass(brushName, color, options?)` — Dry-media, hand-filled hatched fill. Works best with crayon or pastel brushes. `brushName` is always required explicitly. Options: `precision` 0–1, `strength` 0–1, `gradient` 0–1, `outline` bool.
- `brush.noMass()` — Disable massing.
- `brush.hatchArray(polygons)` — Apply current hatch style directly to a `brush.Polygon` or array of polygons.
@@ -105,16 +261,14 @@ Hatching draws parallel lines inside shapes. Activate before drawing a shape, di
### Vector Fields
-When a field is active, `flowLine()` and shape outlines follow its flow.
-
Built-in fields: `"hand"`, `"curved"`, `"zigzag"`, `"waves"`, `"seabed"`, `"spiral"`, `"columns"`.
-- `brush.field(name)` — Activate a named vector field.
-- `brush.noField()` — Deactivate the current field.
-- `brush.wiggle(intensity)` — Shorthand for activating `"hand"` field with a given wobble strength (e.g. 1–10).
+- `brush.field(name)` — Activate a named field.
+- `brush.noField()` — Deactivate.
+- `brush.wiggle(intensity)` — Shorthand for `"hand"` field with given wobble strength.
- `brush.listFields()` — Returns array of all field names.
-- `brush.refreshField(t)` — Update field values using its time-dependent generator. Call in draw loop.
-- `brush.addField(name, fn, options?)` — Create a custom field. `fn(t, field)` fills a 2D angle grid and returns it. By default the grid values are degrees; pass `{ angleMode: "radians" }` if your generator writes radians.
+- `brush.refreshField(t)` — Update field with time value. Call in draw loop for animation.
+- `brush.addField(name, fn, options?)` — Custom field. `fn(t, field)` fills a 2D angle grid (degrees by default) and returns it. Pass `{ angleMode: "radians" }` if your generator writes radians.
```js
brush.addField("diagonal", (t, field) => {
@@ -130,10 +284,10 @@ brush.field("diagonal")
### Primitives
-#### Lines (stroke only, no fill/hatch)
+#### Lines (stroke only)
-- `brush.line(x1, y1, x2, y2)` — Straight line with current brush.
-- `brush.flowLine(x, y, length, dir)` — Line that follows the active vector field. `dir` is the initial angle and follows the current `angleMode()`.
+- `brush.line(x1, y1, x2, y2)`
+- `brush.flowLine(x, y, length, dir)` — Follows active vector field. `dir` follows current `angleMode()`.
- `brush.spline(points, curvature?)` — Smooth curve through `[[x,y], [x,y,pressure], ...]`. Curvature 0–1.
#### Manual strokes (stroke only)
@@ -141,32 +295,25 @@ brush.field("diagonal")
```js
brush.beginStroke("curve", x, y) // or "segments"
brush.move(angle, length, pressure)
-brush.move(angle, length, pressure)
brush.endStroke(angle, pressure)
```
-#### Shapes (affected by stroke + fill + hatch)
+#### Shapes (stroke + fill + hatch)
-- `brush.rect(x, y, w, h, mode?)` — Rectangle. `mode`: `"corner"` (default) or `"center"`.
-- `brush.circle(x, y, radius, r?)` — Circle. `r` = hand-drawn irregularity (0–1). Circles can be stroked, hatched, and filled.
-- `brush.arc(x, y, radius, start, end)` — Arc. `start` and `end` follow the current `angleMode()`. Stroke only.
-- `brush.polygon(pointsArray)` — Polygon from `[[x,y], ...]`. Not affected by vector fields.
-- Prefer avoiding `brush.polygon(...)` in generated examples when field-following behavior or robust fill behavior matters. It bypasses the field-aware primitive generation used by `rect()`, `circle()`, `beginShape()`, etc., and it can be a poor choice when fills are involved.
-- `brush.beginShape(curvature?)` / `brush.vertex(x, y, pressure?)` / `brush.endShape(close?)` — Custom shape.
+- `brush.rect(x, y, w, h, mode?)` — `mode`: `"corner"` (default) or `"center"`.
+- `brush.circle(x, y, radius, r?)` — `r` = hand-drawn irregularity 0–1.
+- `brush.arc(x, y, radius, start, end)` — Stroke only. Angles follow current `angleMode()`.
+- `brush.polygon(pointsArray)` — Polygon from `[[x,y], ...]`. Not affected by vector fields. Avoid when fills or field-following matter.
+- `brush.beginShape(curvature?)` / `brush.vertex(x, y, pressure?)` / `brush.endShape(close?)`
---
### Brush Management
- `brush.box()` — Returns array of all brush names.
-- `brush.clip([x1, y1, x2, y2])` — Clip all strokes to a rectangle in the same coordinate space as brush drawing calls. The current p5 transform is captured when you call it.
+- `brush.clip([x1, y1, x2, y2])` — Clip strokes to a rectangle. Transform is captured at call time.
- `brush.noClip()` — Remove clipping.
-- `brush.add(name, params)` — Define a custom brush.
-
-If an LLM is helping a user design a brush, prefer pointing them to the interactive Brush Maker first:
-
-- Brush Maker: `https://acamposuribe.github.io/p5.brush/tools/brush-maker.html`
-- It supports live preview, editable generated code, light/dark mode, custom tip drawing, image tip upload/preview, and direct numeric entry for parameters.
+- `brush.add(name, params)` — Define a custom brush. Use the [Brush Maker](https://acamposuribe.github.io/p5.brush/tools/brush-maker.html) for interactive design.
**`brush.add()` params:**
@@ -175,26 +322,22 @@ If an LLM is helping a user design a brush, prefer pointing them to the interact
| `type` | `"default"`, `"spray"`, `"marker"`, `"custom"`, `"image"` |
| `weight` | Base thickness in canvas units |
| `scatter` | Sideways spread |
-| `sharpness` | Edge softness 0–1 (`"default"` type only) |
-| `grain` | Texture density (`"default"` type only) |
+| `sharpness` | Edge softness 0–1 (`"default"` only) |
+| `grain` | Texture density (`"default"` only) |
| `opacity` | Mark opacity 0–255 |
| `spacing` | Stamp gap along stroke (1 = no overlap) |
| `pressure` | `[start, end]` or `[start, mid, end]` or `(t) => value` |
-| `tip` | `"custom"` type: `(_m) => { _m.rect(...) }`. In the **p5 build** `_m` is a `p5.Graphics` — any p5 drawing command works. In the **standalone build** `_m` is a minimal 2D-canvas wrapper with the same method names (`rect`, `circle`, `ellipse`, `line`, `beginShape`/`vertex`/`endShape`, `fill`, `noFill`, `stroke`, `noStroke`, `strokeWeight`, `push`, `pop`, `translate`, `scale`, `rotate`) but colors must be a grayscale number or CSS string (not `p5.Color`), and `rotate()` always takes radians. |
+| `tip` | `"custom"` type. **p5 build**: `(_m) => { ... }` where `_m` is a `p5.Graphics` — any p5 command works. **Standalone build**: `_m` is a minimal 2D-canvas wrapper — same method names but colors must be a grayscale number or CSS string (no `p5.Color`), and `rotate()` always takes radians. Draw in a 100×100 unit space, origin at centre. Dark = opaque, white = transparent. |
| `image` | `"image"` type: `{ src: "./tip.jpg" }` |
| `rotate` | `"none"`, `"natural"`, `"random"` |
-| `markerTip` | `"marker"`, `"custom"`, `"image"` only. Boolean. Defaults to `true`. Set `false` to disable the extra soft tip buildup at the start/end of strokes. |
-| `noise` | Per-stroke opacity variation. Each stroke drawn with this brush gets a randomly modulated alpha — subtly lighter or darker — giving repeated strokes an organic feel. `0` disables variation (every stroke identical). `1` is maximum variation. Defaults to `0.3`. |
-
-Important `brush.add()` guidance for LLMs:
+| `markerTip` | `"marker"`, `"custom"`, `"image"` only. Boolean, default `true`. Set `false` to disable soft tip buildup at stroke ends. |
+| `noise` | Per-stroke opacity variation. `0` = every stroke identical. `1` = maximum variation. Default `0.3`. |
- Image brushes return a Promise — use `await brush.add(...)` inside `async setup()`.
- Custom brushes do **not** need `await`.
-- `rotate` is most relevant for `"custom"` and `"image"` tips.
-- `markerTip: false` is useful when a user wants cleaner custom/image/marker stamps without the extra marker-style buildup.
```js
-// Custom tip
+// Custom tip — works in both builds (uses radians, no p5.Color)
brush.add("diamond", {
type: "custom",
weight: 5, scatter: 0.08, opacity: 23, spacing: 0.6,
@@ -204,7 +347,7 @@ brush.add("diamond", {
markerTip: false
})
-// Image tip (must await)
+// Image tip — must await, setup must be async
await brush.add("photo", {
type: "image",
weight: 10, scatter: 2, opacity: 30, spacing: 1.5,
@@ -234,100 +377,48 @@ p.intersect(line) // returns [{x,y}, ...]
#### `brush.Plot(type)`
-For constructing custom stroke paths programmatically.
-
```js
let plot = new brush.Plot("curve")
plot.addSegment(angle, length, pressure)
plot.endPlot(angle, pressure)
-plot.draw(x, y) // draws with current stroke state
-plot.fill(x, y) // fills with current fill state
-plot.wash(x, y) // washes with current wash state
-plot.hatch(x, y) // hatches with current hatch state
-plot.mass(x, y) // masses with current mass state
+plot.draw(x, y)
+plot.fill(x, y)
+plot.wash(x, y)
+plot.hatch(x, y)
+plot.mass(x, y)
plot.rotate(angle)
-plot.genPol(x, y) // returns a Polygon
+plot.genPol(x, y) // returns a Polygon
```
#### `brush.Position(x, y)`
-Point that can move through a vector field.
-
```js
let pos = new brush.Position(x, y)
-pos.moveTo(dir, length, stepLength) // direction follows the current angleMode()
+pos.moveTo(dir, length, stepLength) // dir follows current angleMode()
pos.plotTo(plot, length, stepLength, scale)
```
---
-## Common Patterns
-
-### Basic sketch
-
-```js
-async function setup() {
- createCanvas(600, 600, WEBGL)
- brush.scaleBrushes(3)
- angleMode(DEGREES)
- background("#fffceb")
-}
-
-function draw() {
- translate(-width/2, -height/2) // shift origin to top-left in WEBGL
-
- brush.set("HB", "#222", 1)
- brush.line(50, 50, 550, 550)
-
- brush.fill("#003c32", 120)
- brush.fillBleed(0.15)
- brush.noStroke()
- brush.rect(100, 100, 200, 200, "center")
-}
-```
-
-### Vector field + flowLine
-
-```js
-angleMode(DEGREES)
-brush.field("waves")
-brush.set("charcoal", "white", 1)
-for (let i = 0; i < 40; i++)
- brush.flowLine(random(width), random(height), 120, random(360))
-brush.noField()
-```
-
-### Hatch inside a shape
-
-```js
-brush.hatchStyle("HB", "#333", 1)
-brush.hatch(8, 45, { rand: 0.05 })
-brush.noStroke()
-brush.polygon([[100,100],[300,100],[300,300],[100,300]])
-brush.noHatch()
-```
-
-### push/pop with transforms
-
-```js
-push()
-translate(300, 300)
-rotate(45)
-brush.set("marker", "red", 1)
-brush.rect(0, 0, 100, 100, "center")
-pop()
-```
-
----
-
## Key Gotchas
-- Canvas **must be WEBGL** — `createCanvas(w, h, WEBGL)`.
-- In WEBGL mode the origin is at the center. Use `translate(-width/2, -height/2)` at the start of `draw()` to work in top-left coordinates.
-- `brush.circle()` can be stroked, hatched, and filled. `brush.arc()` is stroke-only.
-- `brush.load()` is **not needed** for the main canvas — it initializes automatically on `createCanvas()`. Only call it when switching to a `p5.Graphics` or `p5.Framebuffer` target.
-- For image brushes, `setup()` must be `async` and you must `await brush.add(...)`.
-- `randomSeed()` and `noiseSeed()` seed the library automatically — no separate brush seed call needed.
-- `brush.flowLine()` direction and `brush.hatch()` angles follow the current `angleMode()`.
+### Both builds
+- The WebGL canvas origin is at the **center**. Use `translate(-width/2, -height/2)` (p5) or `brush.translate(-W/2, -H/2)` (standalone) to work in top-left coordinates.
+- `brush.arc()` is stroke-only. `brush.circle()` supports stroke, fill, and hatch.
- `brush.rect()` mode uses strings: `"corner"` or `"center"` — not p5 constants.
-- Fill opacity follows p5-style alpha values, not 0–100.
+- Fill opacity is 0–255, not 0–100.
+- `brush.flowLine()` and `brush.hatch()` angles follow the current `angleMode()`.
+
+### p5 build only
+- Canvas must be WEBGL: `createCanvas(w, h, WEBGL)`.
+- `brush.load()` is not needed for the main canvas — only for `p5.Graphics` / `p5.Framebuffer` targets.
+- `randomSeed()` and `noiseSeed()` seed the brush library automatically.
+- For image brushes, `setup()` must be `async` and you must `await brush.add(...)`.
+
+### Standalone build only
+- **Always call `brush.render()` at the end of every drawing pass** — nothing appears otherwise.
+- Use `brush.clear(color?)` to clear, not `background()`.
+- Use `brush.push/pop/translate/rotate/scale`, not p5 equivalents.
+- Use `brush.angleMode(brush.DEGREES)`, not `angleMode(DEGREES)`.
+- Use `brush.seed(n)` and `brush.noiseSeed(n)`, not `randomSeed()`/`noiseSeed()`.
+- In custom tip functions, `rotate()` always takes radians and colors must be numbers or CSS strings.