Eye 9 wires up a full control panel — Randomize, Track mode, and a live iris color picker — without changing SWEyeball’s constructor or its drawOnGrid() call. The sketch gets richer; the class interface stays stable. That stability is the point.
Big Idea 1 — The Class Has an API (a Set of Controls for Outsiders)
API stands for Application Programming Interface — a fancy name for a simple idea:
it’s the set of methods a class makes available to the outside world.
Think of a TV remote. You don’t need to know how the television works inside;
you just press the buttons the manufacturer gave you.
Those buttons are the TV’s API.
Here, setPupilOffset(radius, angleDeg) is one of those buttons.
It is the single door through which any outside code — a button, a slider,
a color picker, a keyboard shortcut — moves a pupil.
Once that method exists, the class doesn’t know or care what presses it.
Randomize! presses it with random values. A future slider could press it with a sine wave.
The API is the method; whoever calls it doesn’t matter.
Big Idea 2 — Track Mode: Shared vs. Independent State
One boolean changes the social contract between two sibling objects.
Track ON: dragging or randomizing either eye immediately mirrors the other — both share the same polar offset.
Track OFF: each eye acts independently.
Neither object knows about the other; the sketch manages the synchronization by reading trackMode and calling setPupilOffset on both when needed.
Big Idea 3 — Live Property Update Without Rebuild
setIrisColor(swColor) updates the iris ring stroke color on a live SWEyeball instance without reconstructing any geometry.
The color picker fires on every drag through the chooser, and the canvas responds immediately.
This shows that a class can expose setters for live properties separate from its constructor — construction sets the structure; setters tune it.
Big Idea 4 — The Control Panel Is Just a Client
In programming, a client is any code that uses another piece of code
without needing to know how it works inside.
Think of ordering at a restaurant: you are the client.
You read the menu (the API), place your order (call a method), and get your food.
You never go into the kitchen — and you don’t need to.
Every button, toggle, and picker in the control panel is a client of SWEyeball.
Each one reads from the menu — calls a method like setPupilOffset()
or setIrisColor() — and trusts the class to do the work.
None of them go into the kitchen: they don’t touch the sclera disk,
the glints, or the drag state.
That’s the payoff of encapsulation — the controls are simple,
and all the complexity stays inside the object that owns it.