Turtle Graphics Just keep swimming …
Fill Shapes turtle.fillcolor(“#color_code”) turtle.begin_fill() turtle.end_fill() You must tell turtle when to begin filling and when to end. If you decide to end filling the shape before actually reaching your original destination, it will assume a shape from your final point to the original point.
Show/Hide Turtle turtle.hideturtle() turtle.showturtle() turtle.shape(“object”) You can change your cursor’s shape to be a “turtle”, “square”, “circle”, “arrow”, “triangle”, “classic”
Speedy Gonzalez Maybe the speed function isn’t fast enough for you … turtle.tracer(0) # put # program # here turtle.update()
Writing on Turtle turtle.write(“string”, font = (“font type”, size, “style”) ) Your text will appear wherever your turtle is Takes multiple arguments but this is standard First, type in string literal as message Then define font by: type (Arial, Times New Roman, etc.) # in quotes size (integer) style (normal, bold, italic, bold italic) # in quotes
Change Pensize You can change the thickness of your lines This function takes a single integer argument from 1 to however big you want the pen thickness turtle.pensize(integer)
Clear the Stage You can use this command to clear your canvas in the middle of your program and start all over turtle.clear()
Turn Your Turtle STRAIGHT We’ve seen turtle turn right or left by a number of degrees but you can also set the heading by an exact degree point by this function: turtle.setheading(degrees)
Renaming Your Module t = turtle.Turtle() t.forward() t.goto() t.penup()
Naming Your Turtles You can make multiple turtles at a time! ethan = turtle.Turtle() brian = turtle.Turtle() ethan.goto(100,100) brian.goto(150, 50)
Screen Adjustments You can adjust your screen too! screen = turtle.Screen() screen.bgcolor(“color_code”) screen.setworldcoordinates(min_x, min_y, max_x, max_y)