...loading...
Canvas size:
Grid:
The Eyes Have It — Stage
...loading...
Canvas size:
Grid:
Stage 3 gives the ghost eyes. Two SWEyeball instances are now built
and managed entirely inside the SWGhost class โ the sketch only had
to supply two color arrays. This stage also demonstrates three independent
SWGhost instances side by side, each with its own body color,
iris color, and toe count.
Eye Geometry
Eye size and spacing are derived from two randomly chosen factors stored in each ghost instance:
random(0.7, 0.95)) — controls how far the eyes spread across the head diameter. A value of 1.0 would push the outer edges to the head's rim.random(0.0, 0.10)) — controls the spacing between the eyes. From these two fractions the eye radius and center-to-center distance are derived exactly.Interaction Priority
SWGhost.handleMousePressed() now checks the eyes
before checking for a whole-ghost drag:
Pupil positions are preserved across ghost drags โ pupils don't snap to center when you pick up the ghost.
Three Ghosts, Three Looks
The sketch constructs three SWGhost instances equally spaced
across the canvas. Each ghost is independently draggable and has its own
pupil-drag behavior:
All three share white sclerae, black pupils, and borders hidden
(shouldShowStroke = false) for a clean, painterly look.
The toe progression (0 → 1 → 2) demonstrates the full
range of the flat-bottom feature introduced this stage; any value 0–8 is valid.
What Changed in the Sketch
Compared to Stage 2, the sketch gains:
eyeColors and pupilColors arrays passed as the seventh and eighth arguments to new SWGhost()GHOST_TOES array ([0, 1, 2]) and GHOST_BODY_COLOR_NAMES / GHOST_IRIS_COLOR_NAMES parallel arrays replacing the single color variablesSWGhost instances into a ghosts[] arrayshouldShowStroke = false โ borders hidden on all partsMouse handlers now loop over ghosts[]; everything else — draw loop, save image — is identical to Stage 2.
The Road Ahead
Stage 4 will add animation โ floating, wobble, or patrol behavior using
SWSinusoid. A future lookAt() method will let both
eyes track a target position simultaneously.