...loading...
Canvas size:
Grid:
Creating an Eye Using Core Classes - Stage
...loading...
Canvas size:
Grid:
Every complex shape starts somewhere simple. Eye 1 is that starting point for the SWEyeball Saga: two plain white disks on a grid — nothing more. No pupils, no glints, no interaction. Just the question: what is the minimum structure needed to place an eye-shaped object in space?
Big Picture — What This Stage Establishes
The answer turns out to be three things working together:
SWGrid) — The canvas is mapped to a
user-unit space (−10 to +10 on both axes). All positions and sizes are expressed
in those units, not pixels. This means the sketch is resolution-independent from the
very first line of code, and the math stays intuitive: a radius of 2 means
2 user-units, not 2 pixels.
SWPoint) — Each disk owns a named,
colored center point. In Eye 1, the left eye center is a green SWPoint
labeled “A” at (−3, 6); the right is a red
SWPoint labeled “B” at (3, 6). Giving the center
point its own identity matters: later stages will move it independently to make the
pupil look around.
SWDisk) — Each sclera is a
SWDisk with a white fill, a black (or gray) stroke, and a radius of
2 user-units. The disk delegates all color management to
SWColor, so HSB values and alpha are handled cleanly even at this
earliest stage.
Why Start Here?
Starting with just the sclera — and nothing else — forces clear answers to foundational design questions before complexity arrives:
SWPoint, decided here.SWColor instances, decided here.shouldShowCenter = true), useful for debugging placement in early stages.These decisions carry through every subsequent stage unchanged. Eye 2 adds a pupil disk; Eye 3 adds glints; later stages add drag and the look-at constraint — but all of them build directly on the structure laid out here.
What to Notice in the Sketch
swBlack vs swLightGray) — a preview of how easily SWColor variations will style individual eye components.testPt2) is created as a SWPoint.copy() of the first and then repositioned — demonstrating the copy-then-move pattern that the pupil will use in Eye 2.SWGrid, not drawn manually.The Road Ahead
Eye 1 → Eye 2 adds a second SWDisk as the pupil, offset from the sclera center.
Eye 3 → introduces glint disks computed from polar offsets.
Eyes 4–6 → wire up mouse drag and the sclera-boundary constraint.
Eyes 7–9 → refine geometry and add programmatic look-at control.
Eye 10 → encapsulates everything into the reusable SWEyeball class.