# Turtle_Shapes.py # # Description: Demo turtle shapes and colours. # # Author: Anne Lavergne # Last Modified Date: Oct. 2023 import turtle as tt # ideas for functions: def rectangle(aSide1, aSide2, aLineColour, aFilledColour = "none", anAngle = 90): """Draws a rectangle.""" tt.pencolor(aLineColour) if aFilledColour != "none" : tt.fillcolor(aFilledColour) tt.begin_fill() for i in range(2): tt.forward(aSide1) tt.right(anAngle) tt.forward(aSide2) tt.right(anAngle) if aFilledColour != "none" : tt.end_fill() return def square(aSide, aColour, anAngle = 90): """Draws a square.""" tt.pencolor(aColour) tt.pensize() for i in range(4): tt.forward(aSide) tt.left(anAngle) return def moveToNextShape(aTurtle, anAngle, aLength): """Gets aTurtle ready to draw the next shape.""" aTurtle.penup() aTurtle.left(anAngle) aTurtle.forward(aLength) aTurtle.pendown() return #***Main part of my program # pendown + circles tt.circle(20) # draw a circle tt.pencolor("red") tt.circle(120, 180) # draw a semicircle tt.pencolor("orange") tt.circle(50) tt.circle(120, 90) tt.right(90) tt.pencolor("blue") tt.circle(80) # penup + move forward moveToNextShape(tt, 90, 200) # green rectangle tt.pensize(4) rectangle(100, 50, "green") # penup + move to next shape moveToNextShape(tt, 90, 100) tt.right(90) # black square square(100, "black") # penup + move to next shape moveToNextShape(tt, 90, 150) # yellow rectangle - filled with violet rectangle(50, 100, "yellow", "hot pink") # Last bit! tt.penup() tt.backward(300) tt.right(90) tt.width(5) tt.colormode(255) red = 135 green = 240 blue = 15 col = (red,green,blue) tt.pencolor(col) tt.speed(10) tt.pendown() tt.circle(200, 180) # draw a semicircle # finale tt.penup() tt.home() tt.exitonclick()