Turtle Graphics
Turtle graphics is a fun way to create drawings using Python. Imagine a turtle with a pen that moves around the canvas, drawing as it goes!
Basic Movement
The turtle starts at the center (0, 0) facing right:
🐢 Interactive Graphics
Drawing a Square
Let's draw a complete square:
🐢 Interactive Graphics
Colors and Pen
Make your drawings colorful:
🐢 Interactive Graphics
Filled Shapes
Fill shapes with color:
🐢 Interactive Graphics
Drawing Circles
Circles are easy with turtle:
🐢 Interactive Graphics
Spirals
Create mesmerizing spirals:
🐢 Interactive Graphics
Rainbow Star
Combine colors and shapes:
🐢 Interactive Graphics
Flower Pattern
Create a beautiful flower:
🐢 Interactive Graphics
Useful Commands
Here are common turtle commands:
forward(distance)- Move forwardbackward(distance)- Move backwardright(angle)- Turn right (degrees)left(angle)- Turn left (degrees)goto(x, y)- Move to positionsetheading(angle)- Set directionpenup()- Stop drawingpendown()- Start drawingpencolor(color)- Set pen colorfillcolor(color)- Set fill colorpensize(width)- Set pen widthcircle(radius)- Draw a circlespeed(value)- Set speed (0-10, 0 is fastest)bgcolor(color)- Set background colorclear()- Clear the drawingreset()- Clear and reset position
Try Your Own!
Create your own design. Here's a starter:
🐢 Interactive Graphics
Next Steps
- Experiment with different shapes and colors
- Try combining multiple patterns
- Create animations by clearing and redrawing
- Check out the Canvas API for more drawing options