...loading...
Canvas size:
Grid:
Adding Eye Glints- Stage
...loading...
Canvas size:
Grid:
Eye 4 adds the glint — the small white highlight that makes an eye look alive.
It is just another SWDisk, but its position is computed using
polar coordinates, introducing a placement technique
that reappears throughout the saga.
Big Idea 1 — Polar Coordinates Place the Glint
Instead of picking an x/y offset by trial and error, the glint center is computed from an angle and a radius:
let glintAngleDeg = 135; // upper-left
let glintOffsetX = glintRadius * cos(radians(glintAngleDeg));
let glintOffsetY = glintRadius * sin(radians(glintAngleDeg));
135° places the glint in the upper-left quadrant of the pupil. Changing one number relocates the entire highlight precisely — no pixel hunting required.
Big Idea 2 — Chained Proportional Scaling
The glint radius is derived from the pupil radius, which is derived from the eye radius:
let glintFactor = 0.3;
let glintRadius = eyeRadius * pupilFactor * glintFactor;
The whole eye — sclera, pupil, and glint — scales coherently from
a single eyeRadius value. This proportional chaining becomes
the foundation for SWEyeball's constructor parameters.
Big Idea 3 — Same Fill & Stroke Hides the Border
The glint disk is constructed with glintColor for both fill and stroke:
leftGlint = new SWDisk(leftGlintCenter, glintRadius, 1, glintColor, glintColor);
When fill and stroke are the same color, the border is invisible — leaving only a clean, solid circle. A simple trick with a big visual payoff.
Big Idea 4 — Drawing Order Is Everything
Each eye is drawn in three layers, back to front:
Swap the order and the glint disappears behind the pupil.
What to Notice
glintAngleDeg would need to change
to move the highlight to the lower-right instead.The Road Ahead
The glint is currently anchored to the eye center. In later stages the pupil
will gain its own independent SWPoint, and the glint will follow
it — recomputed each frame so the highlight always sits correctly
regardless of where the pupil has moved.