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 forward
  • backward(distance) - Move backward
  • right(angle) - Turn right (degrees)
  • left(angle) - Turn left (degrees)
  • goto(x, y) - Move to position
  • setheading(angle) - Set direction
  • penup() - Stop drawing
  • pendown() - Start drawing
  • pencolor(color) - Set pen color
  • fillcolor(color) - Set fill color
  • pensize(width) - Set pen width
  • circle(radius) - Draw a circle
  • speed(value) - Set speed (0-10, 0 is fastest)
  • bgcolor(color) - Set background color
  • clear() - Clear the drawing
  • reset() - 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