Now, let's write our Python code in main.py
! We need to set up our drawing screen and then draw a border around it.
Here are some helpful code examples:
1. Setting up your drawing screen:
import turtle
screen = turtle.Screen()
screen.setup(width=600, height=400) # Set the size of your drawing area
screen.bgcolor("lightblue") # Set the background color
2. Making a drawing pen (turtle):
my_pen = turtle.Turtle() # Create a new pen
my_pen.hideturtle() # Make the pen invisible
my_pen.speed(0) # Make the pen draw super fast!
my_pen.color("darkgray") # Set the pen color
my_pen.pensize(3) # Make the line thick
3. Moving your pen without drawing:
my_pen.penup() # Lift the pen up (no drawing)
my_pen.goto(50, 50) # Move to a new spot (like picking up your pencil and moving it)
my_pen.pendown() # Put the pen down (ready to draw)
4. Drawing lines by moving:
my_pen.forward(100) # Draw a line forward
my_pen.right(90) # Turn right
my_pen.goto(100, 0) # Go to a specific spot, drawing a line
5. Example of drawing a simple square:
# This is just an example, not for your border!
square_pen = turtle.Turtle()
square_pen.color("blue")
square_pen.pensize(2)
for _ in range(4):
square_pen.forward(50)
square_pen.left(90)