Drawing with Code: When Robots Hold Pens
Watch patterns emerge from simple commands
Watch patterns emerge from simple commands
This robot has a pen attached. You control it with simple commands: forward to move and turn to rotate. The pen draws a line wherever the robot goes!
Typing the same commands over and over is tedious. Loops let you repeat commands automatically. A square is just "forward, turn" repeated 4 times!
What if we turn MORE than the polygon angle? When we "skip" points, stars appear! A 5-pointed star uses 144° (that's 360° × 2 ÷ 5).
The "2" means we skip 2 points each time!
What if the distance GROWS each time? Instead of forward(100) every time, we increase it: 10, 15, 20, 25... This creates beautiful spirals!
Turn by small amounts (like 5° or 10°) to get smooth, flowing spirals.
Turn by 90° or 120° to get geometric, stepped spirals.
Use pen_color("red") to change colors. Lift the pen with pen_up() to move without drawing, then pen_down() to start again!
Now it's your turn! Use everything you've learned to create your own masterpiece. Start from scratch or remix one of the inspiring patterns below.
You've discovered how simple commands create complex art. Loops turn repetition into beauty, and angles unlock infinite patterns!
Just two commands can draw any polygon!
Repeat commands to create complex patterns from simple rules.
360/n gives you the turn angle for any n-sided shape.
Turn by 144° (or 360×2/5) and you get a perfect star!
Increase the distance each step and spirals appear.
Lift the pen to move without drawing - create gaps and jumps.
Put your new knowledge into practice!