0% found this document useful (0 votes)
9 views6 pages

Turtle Art Code for Shapes and Colors

This Python code uses the turtle module to draw shapes and letters on a canvas. It defines functions to control the turtle's movement and drawing. The code sets the background color, then draws a loop of triangles. It draws the letter P by filling and outlining it. Similarly, it draws the letter A and the letter T by filling and outlining. It then draws the numbers 1003. Finally, it draws 5 colored stars in different locations on the canvas before ending the program.

Uploaded by

api-327820167
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views6 pages

Turtle Art Code for Shapes and Colors

This Python code uses the turtle module to draw shapes and letters on a canvas. It defines functions to control the turtle's movement and drawing. The code sets the background color, then draws a loop of triangles. It draws the letter P by filling and outlining it. Similarly, it draws the letter A and the letter T by filling and outlining. It then draws the numbers 1003. Finally, it draws 5 colored stars in different locations on the canvas before ending the program.

Uploaded by

api-327820167
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

import turtle

[Link]("turtle")

[Link](10)
[Link](5)
[Link](90) #heads upward

#===================================================================
#Settings
def FW(distance):
[Link](distance)

def BW(distance):
[Link](distance)

def R(angle):
[Link](angle)

def L(angle):
[Link](angle)

def MoveL(distance):
[Link](90)
FW(distance)

def MoveR(distance):
[Link](90)
FW(distance)

def MoveRU(angle,distance):
R(angle)
FW(distance)

def MoveLU(angle,distance):
L(angle)
FW(distance)

def drawLoopTri(x,y):
[Link](100)
for times in range(x):
for triangle in range(3):
FW(400)
L(y)
[Link](10)

def drawLoopCir(times,largeness): #Unused


[Link](50)
for time in range(times):
for circle in range(360):
FW(largeness)
L(1)
[Link](10)

def pd():
[Link]()

def pu():
[Link]()

def drawP():
FW(250)
MoveRU(45, 50)
MoveRU(45, 100)
MoveRU(90, 100)
MoveRU(45, 50)
MoveRU(45, 60)
MoveL(100)
MoveRU(45,80)

def drawA():
[Link](225)
FW(100)
BW(100)
[Link](90)
FW(200)
MoveR(105)
MoveRU(60,60)
MoveRU(30,50)
MoveR(170)
BW(170)
L(90)
FW(100)

def drawT():
[Link](90)
FW(240)
MoveL(200)
MoveR(50)
MoveR(330)
MoveR(50)
MoveR(70)
MoveL(240)
MoveR(60)

def starA(line):
[Link](90)
MoveL(line/2)
R(180)
for times in range(5):
FW(line)
R(145)

#===================================================================
#Background
[Link]("#fffcb7")

pu()
[Link](100)
[Link](-100)

pd()
[Link]("#7caeff")
drawLoopTri(20,130)
pu()

#================================
#Letter P Filling

[Link](-250)
[Link](-200)

[Link](90)
pd()
[Link]("#ffb254")
turtle.begin_fill()
drawP()
turtle.end_fill()
pu()

#================================
# Letter P Linework
[Link](-250)
[Link](-200)

[Link](90)
pd()
[Link](10)
[Link]("#e28636")
drawP()
FW(50)
[Link](5)
pu()

#================================
#Letter A
[Link](-70)
[Link](-200)

[Link](90)
pd()
[Link]("#59aa31")
[Link](20)
drawA()

#================================
#Letter T Filling

[Link](10)
MoveL(40)
[Link]("#a18eff")
FW(50)

turtle.begin_fill()
drawT()
turtle.end_fill()

#================================
#Letter T Linework

[Link]("#7054ff")
[Link](15)
drawT()
pu()

#================================
#1003
[Link](5)
[Link]("#ffbb00")
[Link](-300,280)
pd()
#Number 1
[Link](0)
FW(5)
MoveR(20)
MoveR(5)
[Link](0)
FW(10)
pu()
FW(10)

Number 0s
#
def drawzero():
pd()
FW(10)
for times in range(2):
MoveL(20)
MoveL(10)

pu()
FW(10)

drawzero()
drawzero()

#Number 3
pd()
FW(10)
for times in range (2):
MoveL(10)
R(180)
FW(10)
for times in range (2):
MoveL(10)
pu()
#================================

# STARS
[Link](0,250)
[Link]("#ff3a3a")
pd()
turtle.begin_fill()
starA(50)
turtle.end_fill()
pu()

[Link](-100,250)
[Link]("#ff993a")
pd()
turtle.begin_fill()
starA(50)
turtle.end_fill()
pu()

[Link](100,250)
[Link]("#f8ff3a")
pd()
turtle.begin_fill()
starA(50)
turtle.end_fill()
pu()

[Link](-50,200)
[Link]("#58ff3a")
pd()
turtle.begin_fill()
starA(50)
turtle.end_fill()
pu()
[Link](50,200)
[Link]("#3abdff")
pd()
turtle.begin_fill()
starA(50)
turtle.end_fill()
pu()

#================================
[Link]()

You might also like