Generative flow field lab for pen plotter–ready art featuring multiple vector field algorithms, multi-source radial & spiral flows, dynamic method parameters, and optional path repulsion to reduce line crossings. Added functionality to export the results as cordinates in a csv for your own further experimentation.
- 9 field methods with tunable parameters, including Reaction-Diffusion and LIC
- Multi-core path tracing using Web Workers (hybrid parallelization)
- Multi-source radial & spiral patterns (random / grid / circle / ring layouts)
- Magnetic-style path repulsion (inverse-square) with post-processing pass
- Auto-regenerate mode + R keyboard shortcut + deterministic seed display
- Progress overlay with cancel button keeps the UI responsive
- Export to SVG / CSV / JSON with full metadata
| Method | Purpose | Key Parameters |
|---|---|---|
| Quantized Perlin | Perlin angle snapped to equal divisions | Divisions, Angle Noise Mult, Jitter |
| Smooth Perlin | Classic smooth Perlin directional field | Angle Scale, Rotation Offset |
| Pseudo Curl | Curl-like rotational flow from noise derivatives | Derivative ε, Vector Strength |
| Radial (Inward) | Attraction/repulsion toward multiple centers | Inward vs Outward, Falloff, Sources Count, Distribution, Blend Mode |
| Spiral | Multi-arm spiral blends around sources | Inwardness, Twist, Spiral Arms, Arm Sharpness, Sources Count, Distribution, Rotation Dir |
| Sine Waves | Angular interference from sine/cosine waves | Frequency X, Frequency Y, Direction Mode, Amplitude |
| Reaction-Diffusion | Gray-Scott simulation gradients steer flow | Feed Rate, Kill Rate, Diffusion A/B, Iterations, Gradient Mode, Pattern Seed |
| Line Integral Convolution | Texture-driven flow built from LIC over a base field | Base Field, Streamline Length, Kernel, Texture Resolution, Contrast Boost, Flow Direction |
| (Future-ready) Extensions | Add your own by extending field-methods.js |
Custom params |
For Radial / Spiral:
- Sources Count: number of centers
- Distribution: random, grid, circle/ring
- Randomize Sources: regenerate positions instantly
- Blend Mode (Radial): closest, average, weighted
- Rotation Dir (Spiral): auto (alternating), cw, ccw
Toggle Enable Repulsion to apply inverse-square separation between nearby path points.
Parameters:
- Repel Radius: search radius for neighbor points
- Repel Strength: base coefficient k in F = k / r^2
- Max Neighbors: performance cap
- Angle Dampen: blend factor between original flow direction and repulsion-influenced direction
Repulsion is disabled by default; spatial hashing only activates when enabled.
- Simulations are expensive: anything above ~2000 iterations will log a warning and can take multiple seconds on large canvases.
Gradient Modechanges how the flow vectors are derived — trydifferencefor maze-like negative space andlaplacianfor edge-following paths.Pattern Seedcontrols how many initial B-chemical patches spawn; lower values yield isolated blobs, higher values form labyrinths.- Results are cached by seed and parameters; tweak sliders gradually to reuse the cache, or hit Random Seed to spin up a fresh simulation.
Base Fieldreuses any existing method; its own parameters (e.g., Spiral arms) are respected, so adjust those first if you want a different underlying flow.Streamline LengthandKernelcontrol streak sharpness — longer streaks blur more but emphasize directionality.- For fast iteration, temporarily lower
Texture Resolution(0.6–0.8) andStreamline Length; restore higher values for final renders. Flow Directionlets you switch between following the base field, moving perpendicular, or following the texture gradients for painterly crosshatching.
| Parameter | Effect |
|---|---|
| Field Scale | Noise sampling increment (smaller = smoother) |
| Resolution | Steps per path (path length) |
| Number of Paths | How many particle traces to draw |
| Step Size | Grid spacing and movement magnitude |
| Stroke Weight | Line thickness |
| Seed | Deterministic noise seeding (blank = random; Random Seed button shows the active value) |
| Field Method | Select algorithm from dropdown |
| Auto Regenerate | Recompute after every change |
| Action | Description |
|---|---|
| R key | Force regenerate current field |
| Random Seed button | Generates and displays a new deterministic noise seed |
| Randomize Sources button | Resamples source positions for radial/spiral |
| Enable Repulsion checkbox | Toggles path separation |
| Auto Regenerate checkbox | Live update while adjusting sliders |
| Format | Contents |
|---|---|
| SVG | Polylines for each path (plotter-ready) |
| CSV | path_id, point_index, x, y for all points |
| JSON | Metadata only (timestamp, canvas, seed, parameters — no path coordinates) |
JSON output now omits all point data; it only includes metadata and parameters (interaction values are still included when repulsion is active).
- Field Generation: Pre-compute p5.Vector directions for each grid cell based on selected method.
- Path Construction: For each path, iteratively sample field → move → record point. Stops on boundary.
- Repulsion (optional): Spatial bucket hash (size ≈ Repel Radius) collects prior points. For each step, neighbor vectors aggregated with inverse-square attenuation, blended into step direction.
- Multi-Source Methods: Source list generated on method change or parameter update; each cell’s vector mixes contributions.
- Reaction-Diffusion: Gray-Scott grids are simulated once per parameter+seed combination and cached for reuse while the setup is unchanged.
- LIC: Base field vectors and LIC textures are cached per parameter set to avoid recomputing heavy convolutions on every cell.
| Scenario | Tip |
|---|---|
| High path count | Lower Resolution or disable Repulsion |
| Dense repulsion | Reduce Repel Radius / Max Neighbors |
| Detailed spirals | Moderate arms (3–6) & adjust Twist slowly |
| Smooth gradients | Lower Field Scale (0.002–0.006) |
| Reaction-Diffusion taking seconds | Lower Simulation Steps or Pattern Seed; consider smaller canvas |
| LIC preview sluggish | Reduce Streamline Length or Texture Resolution while tuning |
The generator splits path tracing across multiple CPU cores via Web Workers. Keep in mind:
- Workers require the app to be served over HTTP/HTTPS; opening
index.htmlwithfile://will fall back to single-threaded mode. path-worker.jsreceives transferableFloat32Arrayfield data—avoid modifying it to use p5.js helpers.- Repulsion now runs as a sequential post-processing pass on the main thread, so the UI remains responsive while workers stream back path batches.
- The progress overlay reflects total paths completed; the Cancel button safely terminates all workers and resets the overlay.
Add a new method object:
FIELD_METHODS.myMethod = {
name: 'My Method',
description: 'Custom behavior',
params: {
myParam: {label:'My Param', type:'range', min:0, max:1, step:0.01, default:0.5}
},
generate: ({i,j,xoff,yoff}) => {
// Return a p5.Vector direction
return p5.Vector.fromAngle(noise(xoff,yoff)*TWO_PI);
}
};The UI auto-populates controls and stores values in METHOD_PARAMS.myMethod.myParam.
- From the project root, start a lightweight web server so Web Workers can load, e.g.
python3 -m http.server 8000. - Open
http://localhost:8000/index.htmlin your browser (Chrome, Edge, or Safari). - Pick a Field Method and adjust its parameters on the right panel.
- (Optional) Enable Auto Regenerate for live tweaking; otherwise press Regenerate or hit R. The overlay progress bar shows worker activity and lets you cancel mid-run.
- Use Random Seed to lock a new deterministic seed or clear the field for automatic reseeding between runs.
- Export via SVG / CSV / JSON buttons once satisfied.
├── index.html # UI layout & script includes
├── field-methods.js # Registry of field definitions + parameter metadata
├── flowfields.js # Core controller, caching, workers, repulsion, exports
├── path-worker.js # Web Worker that traces path batches off the main thread
├── img/gui.png # Interface screenshot
├── cli/ # Node.js CLI generator (build outputs, methods, noise)
└── README.md # Documentation
MIT
Built with p5.js. Inspired by classic flow field, curl noise, and generative plotting techniques.
