程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式師世界 >> 編程語言 >  >> 更多編程語言 >> Python

Python turtle library code modification

編輯:Python
The phenomenon and background of the problem


I want to add this effect to the appearance of holes in my body , Like the picture below

from turtle import *

# General appearance
setup(600,600)
pensize(3)
speed(20)
color('black','yellow')
penup()
goto(-120,120)
pendown()
begin_fill()
seth(-45) #Turtle Medium turtle.seth(angle) The function represents the direction of movement when the little turtle starts
for i in range(0,4):
for i in range(0,5):
circle(15,90)
circle(-15,90)
right(90)
end_fill()

# eyes
pensize(1)
color('black','white')
penup()
goto(-70,30)
pendown()
begin_fill()
circle(30)
end_fill()

#1 eyes
color('white','blue')
penup()
goto(-40,43)
pendown()
begin_fill()
circle(10)
end_fill()

#2 eyes
color('white','black')
penup()
goto(-35,46)
pendown()
begin_fill()
circle(5)
end_fill()

# Left eyebrow 1
pensize(3)
color('black')
penup()
goto(-68,82)
pendown()
fd(6)

# Left eyebrow 2
pensize(3)
color('black')
penup()
goto(-50,88)
pendown()
right(45)
fd(6)

# Left eyebrow 3
pensize(3)
color('black')
penup()
goto(-30,82)
pendown()
right(30)
fd(6)

# Right eye
pensize(1)
color('black','white')
penup()
goto(3,67)
pendown()
begin_fill()
circle(30)
end_fill()

# Right 1 eyes
color('white','blue')
penup()
goto(3,56)
pendown()
begin_fill()
circle(10)
end_fill()

# Right 2 eyes
color('white','black')
penup()
goto(7,54)
pendown()
begin_fill()
circle(5)
end_fill()

# Right eyebrow 1
pensize(3)
color('black')
penup()
goto(10,82)
pendown()
left(50)
fd(6)

# Right eyebrow 2
pensize(3)
color('black')
penup()
goto(30,88)
pendown()
right(20)
fd(6)

# Right eyebrow 3
pensize(3)
color('black')
penup()
goto(50,82)
pendown()
right(15)
fd(6)

# mouth
pensize(1)
color('black','IndianRed3')
penup()
goto(-86,-20)
pendown()
left(65)
begin_fill()
right(33)
circle(70,150)

circle(120,80)

fd(10)
left(130)
circle(-184,45)
end_fill()

# The tongue
color('black', 'orange red')
penup()
goto(-66,-50)
pendown()
right(130)
circle(-140,46)

# nose
penup()
goto(-15,10)
pendown()
fd(40)
circle(5,180)
fd(40)

# The trousers
color('black','white')
penup()
goto(-123,-85)
pendown()
begin_fill()
left(100)
fd(20)

left(93)
fd(225)

left(95)
fd(20)

left(85)
fd(225)
end_fill()

# Two layer pants
color('black','orange4')
penup()
goto(-123,-106)
pendown()
begin_fill()
left(90)
fd(30)
left(90)
fd(225)
left(90)
fd(30)
left(90)
fd(225)
end_fill()

# Trouser seam
color('black')
pensize(8)
for i in range(0,4):
penup()
goto(-83+(i*60),-120)
pendown()
fd(30)

# Trouser leg 1
color('black','orange3')
pensize(1)
penup()
goto(-63,-137)
pendown()
begin_fill()
left(90)
fd(10)
left(30)
circle(15,120)
left(30)
fd(10)
left(90)
fd(30)
end_fill()

# Trouser leg 2
color('black','orange3')
pensize(1)
penup()
goto(23,-137)
pendown()
begin_fill()
left(90)
fd(10)
left(30)
circle(15,120)
left(30)
fd(10)
left(90)
fd(30)
end_fill()

# leg 1
color('black')
penup()
goto(-53,-155)
pendown()
left(90)
fd(65)
fd(30)
left(90)
fd(20)
penup()
goto(-43,-155)
pendown()
right(90)
fd(60)
circle(20,90)
fillcolor('black')
begin_fill()
fd(5)
circle(-7,180)
fd(35)
right(90)
fd(24)
end_fill()

# leg 2
color('black')
penup()
goto(33,-152)
pendown()
right(180)
fd(55)
fd(30)
left(90)
fd(20)
penup()
goto(43,-152)
pendown()
right(90)
fd(65)
circle(20,90)
fillcolor('black')
begin_fill()
circle(-7,180)
fd(32)
right(90)
fd(22)
end_fill()

# left hand
color('black','yellow')
penup()
goto(-120,-10)
pendown()
begin_fill()
left(45)
fd(100)
circle(-15,80)
fd(5)
circle(5,180)
fd(20)
# The first 2 Fingers
right(150)
fd(35)
circle(5,180)
fd(40)

# The first 3 Fingers
right(150)
fd(30)
circle(5,180)
fd(30)

# The first 4 Fingers
right(140)
fd(30)
circle(5,180)
fd(45)
circle(15,90)

right(40)
right(70)
fd(110)
end_fill()

# one 's right hand
color('black','yellow')
penup()
goto(90,-10)
pendown()
begin_fill()
left(90)
fd(100)
circle(-15,80)
fd(5)
circle(5,180)
fd(20)
# The first 2 Fingers
right(150)
fd(35)
circle(5,180)
fd(40)

# The first 3 Fingers

right(150)
fd(30)
circle(5,180)
fd(30)

# The first 4 Fingers

right(140)
fd(30)
circle(5,180)
fd(45)
circle(15,90)

right(40)
right(70)
fd(98)
end_fill()

penup()
goto(-120,160)
pendown()
color("red")
write("666", font=('Arial', 40, 'normal'))
hideturtle()
done()


  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式師世界 All Rights Reserved