fieldGraphics
p5.Renderer
An offscreen graphics buffer where the metaball field is computed at lower resolution before being scaled to full screen
let fieldGraphics; // initialized in initField()
NUM_METABALLS
number
Constant that defines how many metaballs to create (set to 6)
const NUM_METABALLS = 6;
metaballs
array
Array storing objects for each metaball, containing radius, amplitude, speed, and phase parameters
let metaballs = []; // filled in initMetaballs()
bgColor
array
RGB color array for the dark background (very dark blue)
const bgColor = [4, 2, 20];
startColor
array
RGB color array for the starting blob color (orange)
const startColor = [255, 170, 0];
endColor
array
RGB color array for the ending blob color (magenta)
const endColor = [255, 0, 200];
centersX
array
Temporary array storing the current X position of each metaball in the current frame
const centersX = new Array(n);
centersY
array
Temporary array storing the current Y position of each metaball in the current frame
const centersY = new Array(n);
strengths
array
Temporary array storing the field strength (radius²) of each metaball
const strengths = new Array(n);
isoLevel
number
Threshold value that determines where the blob 'surface' appears (pixels with field > 1.0 are inside)
const isoLevel = 1.0;
falloff
number
Controls how quickly the color transitions from orange to magenta as you move deeper into the blob
const falloff = 3.0;
t
number
Time variable that increases each frame, used to drive smooth sine/cosine oscillation of metaballs
const t = frameCount * 0.02;