Mason’s Nerdy Icon — Refactored
Same artwork. Same turtle commands. Organized into constants, functions, and comments.
Stage 2: the upgrade. Open Stage 1 in another tab to compare side by side.
The Code, Organized
Every turtle command in this version is identical to Mason’s original. The output image is the proof. What changed is structure: hard-coded numbers became named constants, logical groups of commands became functions, and comments explain the purpose of each step.
- Magic numbers like
75,72.5, and145are now named constants:FACE_RADIUS,EYE_SPACING,BRIDGE_LENGTH. - Seven functions, one per facial feature:
setup,draw_face,draw_glasses,draw_eyes,reposition_to_mouth,draw_mouth,draw_cheeks. main()shows the entire draw order in seven lines — a high-level outline before any detail.- Inline comments explain why, not just what:
# negative = clockwise quarter turn.
Output
Identical to Stage 1.
Same commands — better organized.
See How It Started
Stage 1 shows Mason’s original code exactly as written — 154 lines, no comments, no functions, no constants. Opening both pages side by side is the fastest way to see what modularization actually buys you: the output is the same, but the Stage 2 code can be understood, changed, and extended without re-reading the whole file.
Stage 1 — Original Code Open in New Tab