Modularization by Functions
The same emoji. The same animation. A completely different structure.
draw() is now five words. Each feature has its own name.
One Feature. One Function.
Phase 1 makes one structural change: every facial feature moves out of draw()
and into its own named function. The drawing commands are unchanged — same
numbers, same colors, same geometry as Ethan’s original. Only the organization is new.
// ORIGINAL draw(): ~40 lines of interleaved drawing commands
// PHASE 1 draw(): a five-line recipe
function draw() {
background(240);
translate(width / 2, height / 2);
drawFace(); // ← one name, one job
drawEyebrows();
drawEyes();
drawMouth();
drawTongue();
}//end draw
/* */ around the drawEyes(); call inside p.draw.
Refresh. The face, brows, mouth, and tongue all render — only the eyes vanish.
Restore the call. That cause-and-effect is the modularization lesson.
No slide deck delivers it as convincingly.
Live Animation — Phase 1
Visually identical to the original — the refactor touched only the structure,
not the drawing commands. draw() calls five functions; they do the work.