Stage 2 introduces inheritance: SWCross
extends SWWheel, locking in 4 spokes, hiding the rim,
and hiding the hub — leaving only the four arms visible.
A new initialRotation property lets you pre-tilt the
arms to any angle before animation begins.
🔩 What Was Built in Stage 2
SWCross extends SWWheel — inherits all wheel
machinery; locks numSpokes = 4,
rimThickness = 0, and invisible hub.
initialRotation — degrees of pre-tilt baked into
every rotate() call so the arms always start from
the chosen orientation.
setInitialRotation(deg) — live setter wired to
the Initial Rotation slider; instantly repositions the arms and
rebases the animation time.
reset() — overridden to return arms to
initialRotation (not 0).
🎮 How to Use the Controls
- Drag Initial Rotation to pre-tilt the arms (0° = plus,
45° = times/cross).
- Set Rotation speed and press ▶ Start to spin.
- ↺ Reset snaps the arms back to the current
initial rotation, not to 0°.
- Check Breathe to oscillate the arm length; the
Arm Length slider is disabled while breathing.
- Press G to toggle the grid.
⚠️ p5.js Global State: strokeCap()
By default, p5.js draws all line endpoints with round caps.
This is controlled by the global strokeCap() function —
and that setting persists until something changes it back.
SWLine now explicitly sets and restores
strokeCap around every draw call, so it does not pollute
the global state for other shapes in your sketch.
The three cap options (see the Arm caps selector):
- Round — p5’s default;
semicircular end cap; line length equals exact nominal length.
- Flat (square) —
SQUARE;
flat end cut exactly at the endpoint. Default for
SWCross because precise, blunt tips give the
cleanest crosshair geometry.
- Projected —
PROJECT;
flat end that extends beyond the endpoint by half the
stroke weight — making each arm appear slightly longer
than specified.
🔮 What’s Next
Stage 3 will place a grid of SWCross instances on
screen to produce the Troxler’s Effect optical illusion
— stare at the center dot and watch the plus signs fade…