Gallery › Generative and L-systems
Lodestone
1,400 iron filings tracing a flow field around a rock, like the field lines of a magnet.
How it is made
Each filing is traced through a flow field with advect. The field comes from curl2 applied to a hand-composed potential, coherent noise2 texture plus a radial term, whose perpendicular gradient curls a purely radial field into the concentric loops real filings make around a magnet.
Details
- Category
- Generative and L-systems
- Libraries
- artkit
- Added
- 2026-08-14
- Built in
- issue #19
- Page size
- 640 × 640 points
Source
View source the whole program in a scrolling window, or read gallery/lodestone.ps on GitHub. To draw it yourself, from a checkout of the repository:
pscat --page 640x640 gallery/lodestone.ps
The first 40 of 127 lines of the source
%!PS-Adobe-3.0
%%Title: Lodestone
%%BoundingBox: 0 0 640 640
%%Creator: Claude & a nostalgic LaserWriter fan
%%EndComments
% A naturalist's demonstration plate: a lodestone on a parchment page,
% its magnetism made visible as a scatter of iron filings. Each filing
% is one very short `advect` trace (issue #19) through a curl-noise
% flow field (`curl2`) built from a hand-composed potential -- a
% coherent `noise2` texture for organic irregularity, plus a term
% proportional to distance from the stone. Curl is the perpendicular
% gradient, so a purely radial term curls into concentric tangential
% flow (any radial field's gradient points straight at/away from the
% center; rotate that 90 degrees and it runs in loops around it) --
% the noise term breaks the perfect circles into the ragged, organic
% loops real filings actually make. Run from the repo root:
%
% pscat --page 640x640 gallery/lodestone.ps
(lib/artkit.ps) run
21 srand
noiseinit
% --- page: parchment wash -------------------------------------------------
0 1 15 {
/band exch def
/bt band 15 div def
/parchment pal 0 get /parchment pal 1 get bt mix3 setrgbcolor
newpath 0 band 640 mul 15 div 640 640 15 div 1 add rectfill
} for
/lcx 330 def /lcy 300 def
% --- the lodestone: a jittered rock, fixed once so fill and stroke ------
% trace the same silhouette (same convention as hexgrid/trigrid calling
% hex/tri twice in examples/tiling.ps).
/lodeR 76 def
/lodeN 24 def
/lodeVerts lodeN 2 mul array def