python turtle库绘图 520表白红玫瑰 樱花树 动漫 海绵宝宝 小猪佩奇 哆啦A梦 时钟等多个例满足你的需求
盾牌
import turtle
import math
turtle.setup(650,350,200,200)
turtle.penup()
turtle.pendown()
turtle.pensize(7)
turtle.pencolor("gold")
turtle.fillcolor('#33cc8c')
turtle.seth(30)
turtle.begin_fill()
turtle.forward(200)
turtle.seth(-90)
turtle.fd(200)
turtle.seth(150)
turtle.fd(200)
turtle.seth(270)
turtle.circle(math.sqrt(3)*200/3,420)
turtle.seth(90)
turtle.fd(200)
turtle.seth(-30)
turtle.fd(200)
turtle.seth(210)
turtle.fd(200)
turtle.end_fill()
turtle.done()
520表白
import turtle
turtle.pensize(10)
turtle.pencolor("pink")
turtle.penup()
turtle.goto(-50,180)
turtle.pendown()
turtle.goto(50,180)
turtle.penup()
turtle.goto(-75,90)
turtle.pendown()
turtle.goto(75,90)
turtle.penup()
turtle.goto(-100,0)
turtle.pendown()
turtle.goto(100,0)
turtle.penup()
turtle.goto(-125,-90)
turtle.pendown()
turtle.goto(125,-90)
turtle.penup()
turtle.goto(-125,-180)
turtle.pendown()
turtle.goto(125,-180)
turtle.penup()
turtle.goto(-50,180)
turtle.pendown()
turtle.goto(-50,90)
turtle.penup()
turtle.goto(0,180)
turtle.pendown()
turtle.goto(0,90)
turtle.penup()
turtle.goto(50,180)
turtle.pendown()
turtle.goto(50,90)
turtle.penup()
turtle.goto(-75,90)
turtle.pendown()
turtle.goto(-75,0)
turtle.penup()
turtle.goto(-25,90)
turtle.pendown()
turtle.goto(-25,0)
turtle.penup()
turtle.goto(25,90)
turtle.pendown()
turtle.goto(25,0)
turtle.penup()
turtle.goto(75,90)
turtle.pendown()
turtle.goto(75,0)
turtle.penup()
turtle.goto(-100,0)
turtle.pendown()
turtle.goto(-100,-90)
turtle.penup()
turtle.goto(-50,0)
turtle.pendown()
turtle.goto(-50,-90)
turtle.penup()
turtle.goto(0,0)
turtle.pendown()
turtle.goto(0,-90)
turtle.penup()
turtle.goto(50,0)
turtle.pendown()
turtle.goto(50,-90)
turtle.penup()
turtle.goto(100,0)
turtle.pendown()
turtle.goto(100,-90)
turtle.penup()
turtle.goto(-125,-90)
turtle.pendown()
turtle.goto(-125,-180)
turtle.penup()
turtle.goto(-75,-90)
turtle.pendown()
turtle.goto(-75,-180)
turtle.penup()
turtle.goto(-25,-90)
turtle.pendown()
turtle.goto(-25,-180)
turtle.penup()
turtle.goto(25,-90)
turtle.pendown()
turtle.goto(25,-180)
turtle.penup()
turtle.goto(75,-90)
turtle.pendown()
turtle.goto(75,-180)
turtle.penup()
turtle.goto(125,-90)
turtle.pendown()
turtle.goto(125,-180)
turtle.penup()
turtle.goto(-50,150)
turtle.pendown()
turtle.goto(-25,150)
turtle.penup()
turtle.goto(-25,120)
turtle.pendown()
turtle.goto(0,120)
turtle.penup()
turtle.goto(25,150)
turtle.pendown()
turtle.goto(25,120)
turtle.penup()
turtle.goto(-75,30)
turtle.pendown()
turtle.goto(-50,30)
turtle.penup()
turtle.goto(-50,60)
turtle.pendown()
turtle.goto(0,60)
turtle.penup()
turtle.goto(0,30)
turtle.pendown()
turtle.goto(25,30)
turtle.penup()
turtle.goto(50,60)
turtle.pendown()
turtle.goto(50,30)
turtle.penup()
turtle.goto(-75,-20)
turtle.pendown()
turtle.goto(-75,-30)
turtle.penup()
turtle.goto(-100,-50)
turtle.pendown()
turtle.goto(-75,-50)
turtle.goto(-75,-70)
turtle.penup()
turtle.goto(-25,0)
turtle.pendown()
turtle.goto(-25,-55)
turtle.penup()
turtle.goto(-50,-80)
turtle.pendown()
turtle.goto(-25,-80)
turtle.penup()
turtle.goto(-4,0)
turtle.pendown()
turtle.goto(-4,-55)
turtle.penup()
turtle.goto(-4,-80)
turtle.pendown()
turtle.goto(-4,-90)
turtle.penup()
turtle.goto(0,-30)
turtle.pendown()
turtle.goto(25,-30)
turtle.penup()
turtle.goto(25,-60)
turtle.pendown()
turtle.goto(50,-60)
turtle.penup()
turtle.goto(75,-30)
turtle.pendown()
turtle.goto(75,-60)
turtle.penup()
turtle.goto(-125,-150)
turtle.pendown()
turtle.goto(-100,-150)
turtle.penup()
turtle.goto(-100,-120)
turtle.pendown()
turtle.goto(-75,-120)
turtle.penup()
turtle.goto(-50,-110)
turtle.pendown()
turtle.goto(-50,-120)
turtle.penup()
turtle.goto(-75,-145)
turtle.pendown()
turtle.goto(-50,-145)
turtle.goto(-50,-165)
turtle.penup()
turtle.goto(0,-90)
turtle.pendown()
turtle.goto(0,-145)
turtle.penup()
turtle.goto(-25,-170)
turtle.pendown()
turtle.goto(0,-170)
turtle.penup()
turtle.goto(21,-90)
turtle.pendown()
turtle.goto(21,-145)
turtle.penup()
turtle.goto(21,-170)
turtle.pendown()
turtle.goto(21,-180)
turtle.penup()
turtle.goto(25,-120)
turtle.pendown()
turtle.goto(50,-120)
turtle.penup()
turtle.goto(50,-150)
turtle.pendown()
turtle.goto(75,-150)
turtle.penup()
turtle.goto(100,-120)
turtle.goto(100,-150)
turtle.penup()
turtle.goto(200,-250)
turtle.done()
海绵宝宝
import turtle as t
t.tracer(3)
t.penup()
t.goto(-80,160)
t.pendown()
t.seth(-120)
t.begin_fill()
t.fillcolor('yellow')
for i in range(4):
t.circle(20,60)
t.circle(-20,60)
t.seth(-30)
for i in range(4):
t.circle(20,60)
t.circle(-20,60)
t.seth(60)
for i in range(4):
t.circle(20,60)
t.circle(-20,60)
t.seth(150)
for i in range(4):
t.circle(20,60)
t.circle(-20,60)
t.end_fill()
t.penup()
t.goto(0,100)
t.pd()
t.begin_fill()
t.fillcolor('white')
t.seth(90)
t.circle(-26)
t.circle(26)
t.end_fill()
t.penup()
t.goto(-36,100)
t.pendown()
t.seth(90)
t.circle(-10)
t.penup()
t.goto(-30,100)
t.pendown()
t.begin_fill()
t.fillcolor('black')
t.seth(90)
t.circle(-4)
t.end_fill()
t.penup()
t.goto(36,100)
t.pendown()
t.seth(90)
t.circle(10)
t.penup()
t.goto(30,100)
t.pendown()
t.seth(90)
t.begin_fill()
t.fillcolor('black')
t.circle(4)
t.end_fill()
t.penup()
t.goto(10,75)
t.pd()
t.circle(10,270)
t.penup()
t.goto(-52,70)
t.pd()
t.begin_fill()
t.fillcolor('pink')
t.seth(-30)
t.circle(104,60)
t.seth(-90)
t.circle(-52,180)
t.end_fill()
t.penup()
t.goto(-80,0)
t.pendown()
t.seth(-90)
t.fd(50)
t.seth(0)
t.fd(160)
t.seth(90)
t.fd(50)
t.penup()
t.goto(-80,-15)
t.pd()
t.goto(80,-15)
t.penup()
t.begin_fill()
t.fillcolor('red')
t.goto(-5,-15)
t.pendown()
t.goto(-10,-20)
t.goto(0,-50)
t.goto(10,-20)
t.goto(5,-15)
t.end_fill()
t.penup()
t.goto(-50,-50)
t.pendown()
t.begin_fill()
t.fillcolor('brown')
t.goto(-50,-60)
t.goto(-20,-60)
t.goto(-20,-50)
t.penup()
t.goto(-40,-60)
t.pendown()
t.goto(-40,-90)
t.seth(90)
t.circle(8,180)
t.goto(-56,-100)
t.goto(-30,-100)
t.goto(-30,-60)
t.end_fill()
t.penup()
t.goto(50,-50)
t.pendown()
t.begin_fill()
t.fillcolor('brown')
t.goto(50,-60)
t.goto(20,-60)
t.goto(20,-50)
t.penup()
t.goto(40,-60)
t.pendown()
t.goto(40,-90)
t.seth(90)
t.circle(-8,180)
t.goto(56,-100)
t.goto(30,-100)
t.goto(30,-60)
t.end_fill()
t.penup()
t.goto(-82.68,70)
t.pendown()
t.goto(-97.68,60)
t.goto(-97.68,20)
t.goto(-82.68,30)
t.penup()
t.goto(77.32,70)
t.pendown()
t.goto(97.32,60)
t.goto(97.32,20)
t.goto(77.32,30)
t.penup()
t.goto(-97.68,45)
t.pendown()
t.goto(-137.68,25)
t.seth(150)
t.circle(10,300)
t.goto(-97.68,35)
t.penup()
t.goto(97.32,45)
t.pendown()
t.goto(137.32,25)
t.seth(30)
t.circle(-10,300)
t.goto(97.32,35)
t.done()
动漫人物头
import turtle as te
WriteStep=15
Speed=5
Width=600
Height=600
Xh=0
Yh=0
def Bezier(p1,p2,t):
return p1*(1-t)+p2*t
def Bezier_2(x1,y1,x2,y2,x3,y3):
te.goto(x1,y1)
te.pendown()
for t in range(0,WriteStep+1):
x=Bezier(Bezier(x1,x2,t/WriteStep),Bezier(x2,x3,t/WriteStep),t/WriteStep)
y=Bezier(Bezier(y1,y2,t/WriteStep),Bezier(y2,y3,t/WriteStep),t/WriteStep)
te.goto(x,y)
te.penup()
def Bezier_3(x1,y1,x2,y2,x3,y3,x4,y4):
x1=-Width/2+x1
y1=Height/2-y1
x2=-Width/2+x2
y2=Height/2-y2
x3=-Width/2+x3
y3=Height/2-y3
x4=-Width/2+x4
y4=Height/2-y4
te.goto(x1,y1)
te.pendown()
for t in range(0,WriteStep+1):
x=Bezier(Bezier(Bezier(x1,x2,t/WriteStep),Bezier(x2,x3,t/WriteStep),t/WriteStep),Bezier(Bezier(x2,x3,t/WriteStep),Bezier(x3,x4,t/WriteStep),t/WriteStep),t/WriteStep)
y=Bezier(Bezier(Bezier(y1,y2,t/WriteStep),Bezier(y2,y3,t/WriteStep),t/WriteStep),Bezier(Bezier(y2,y3,t/WriteStep),Bezier(y3,y4,t/WriteStep),t/WriteStep),t/WriteStep)
te.goto(x,y)
te.penup()
def Moveto(x,y):
te.penup()
te.goto(-Width/2+x,Height/2-y)
def line(x1,y1,x2,y2):
te.penup()
te.goto(-Width/2+x1,Height/2-y1)
te.pendown()
te.goto(-Width/2+x2,Height/2-y2)
te.penup()
def lineto(dx,dy):
te.pendown()
te.goto(te.xcor()+dx,te.ycor()-dy)
te.penup()
def Lineto(x,y):
te.pendown()
te.goto(-Width/2+x,Height/2-y)
te.penup()
def Horizontal(x):
te.pendown()
te.setx(x-Width/2)
te.penup()
def horizontal(dx):
te.seth(0)
te.pendown()
te.fd(dx)
te.penup()
def vertical(dy):
te.seth(-90)
te.pendown()
te.fd(dy)
te.penup()
te.seth(0)
def polyline(x1,y1,x2,y2,x3,y3):
te.penup()
te.goto(-Width/2+x1,Height/2-y1)
te.pendown()
te.goto(-Width/2+x2,Height/2-y2)
te.goto(-Width/2+x3,Height/2-y3)
te.penup()
def Curveto(x1,y1,x2,y2,x,y):
te.penup()
X_now=te.xcor()+Width/2
Y_now=Height/2-te.ycor()
Bezier_3(X_now,Y_now,x1,y1,x2,y2,x,y)
global Xh
global Yh
Xh=x-x2
Yh=y-y2
def curveto_r(x1,y1,x2,y2,x,y):
te.penup()
X_now=te.xcor()+Width/2
Y_now=Height/2-te.ycor()
Bezier_3(X_now,Y_now,X_now+x1,Y_now+y1,X_now+x2,Y_now+y2,X_now+x,Y_now+y)
global Xh
global Yh
Xh=x-x2
Yh=y-y2
def Smooth(x2,y2,x,y):
global Xh
global Yh
te.penup()
X_now=te.xcor()+Width/2
Y_now=Height/2-te.ycor()
Bezier_3(X_now,Y_now,X_now+Xh,Y_now+Yh,x2,y2,x,y)
Xh=x-x2
Yh=y-y2
def smooth_r(x2,y2,x,y):
global Xh
global Yh
te.penup()
X_now=te.xcor()+Width/2
Y_now=Height/2-te.ycor()
Bezier_3(X_now,Y_now,X_now+Xh,Y_now+Yh,X_now+x2,Y_now+y2,X_now+x,Y_now+y)
Xh=x-x2
Yh=y-y2
te.tracer(100)
te.pensize(1)
te.speed(Speed)
te.penup()
te.color("black","#F2F2F2")
Moveto(61,462)
te.begin_fill()
smooth_r(12,-41,27,-58)
curveto_r(-6,-36,6,-118,9,-132)
curveto_r(-15,-27,-23,-51,-26,-74)
curveto_r(4,-66,38,-105,65,-149)
Horizontal(486)
curveto_r(12,24,40,99,33,114)
curveto_r(39,82,55,129,39,144)
smooth_r(-31,23,-39,28)
smooth_r(-12,37,-12,37)
lineto(50,92)
Horizontal(445)
smooth_r(-29,-38,-31,-46)
smooth_r(78,-107,72,-119)
Smooth(355,178,340,176)
Smooth(272,63,264,64)
smooth_r(-29,67,-27,73)
Curveto(99,292,174,428,173,439)
smooth_r(-8,23,-8,23)
Lineto(61,462)
te.end_fill()
Moveto(60.5,461.5)
te.color("black","#D3DFF0")
te.begin_fill()
curveto_r(0,0,17,-42,27,-59)
curveto_r(-6,-33,6,-128,10,-133)
curveto_r(-15,-10,-27,-66,-27.285,-75)
te.pencolor("#D3DFF0")
curveto_r(12.285,11,82.963,156,82.963,156)
te.pencolor("black")
smooth_r(12.322,75,19.322,86)
curveto_r(-1,11,-8,25,-8,25)
Horizontal(60.5)
te.end_fill()
Moveto(444.5,464)
te.begin_fill()
curveto_r(0,0,-29,-36,-31,-46)
smooth_r(53.59,-82.337,53.59,-82.337)
te.pencolor("#D3DFF0")
smooth_r(86.41,-47.663,96.072,-54.85)
Curveto(563.5,297.5,570.5,299.5,518.5,334)
te.pencolor("black")
curveto_r(-2,16,-12,33,-12,37)
smooth_r(50,92,50,93)
Horizontal(444.5)
te.end_fill()
Moveto(195,50)
te.begin_fill()
te.pencolor("#D3DFF0")
polyline(195,50,175.5,106.5,202.522,50)
Horizontal(195)
te.end_fill()
Moveto(327.997,49)
te.begin_fill()
curveto_r(0,0,11.503,121.087,13.503,128.087)
curveto_r(11,2,54,37,54,37)
lineto(-40,-164)
Horizontal(327.997)
te.end_fill()
Moveto(94.5,397.5)
te.pencolor("black")
line(94.5,397.5,107.5,373.5)
line(122.5,317.5,95.875,274.699)
line(122.5,341.5,141.5,402.5)
line(141.5,409.5,153.5,431.5)
line(340.023,49,360.5,144)
line(478.5,95.5,518.5,161.5)
line(518.5,332.5,460.5,359.5)
polyline(506.5,369.5,493.5,402.5,502.5,443.5)
Moveto(530,429)
curveto_r(4,16,-5,33,-5,33)
te.color("black","#2b1d2a")
Moveto(225,462)
te.begin_fill()
Horizontal(165)
smooth_r(9,-15,8,-25)
curveto_r(-47,-126,6,-212,12,-225)
Curveto(185,305,202,428,225,462)
Lineto(225,462)
te.end_fill()
Moveto(390,462)
te.begin_fill()
curveto_r(10,-23,34,-180,35,-222)
curveto_r(7,4,54,45,61,61)
smooth_r(-73,101,-72,118)
curveto_r(5,15,31,46,31,45)
Lineto(390,462)
te.end_fill()
te.color("black","#2b1d29")
Moveto(225,462)
te.begin_fill()
curveto_r(-28,-50,-40,-166,-40,-250)
curveto_r(6,51,-6,87,45,106)
smooth_r(64,27,89,24)
smooth_r(49,-18,56,-20)
smooth_r(50,-10,51,-85)
curveto_r(0,29,-25,201,-36,225)
Lineto(225,462)
te.end_fill()
te.color("black","#3D3D3D")
Moveto(225,462)
te.begin_fill()
curveto_r(-5,-5,-22,-53,-23,-70)
lineto(32,-13)
curveto_r(3,-25,6,-28,12,-36)
smooth_r(13,-12,16,-12)
vertical(-2)
curveto_r(45,20,64,14,94,1)
vertical(2)
curveto_r(8,-2,15,2,17,4)
smooth_r(0,6,-2,9)
curveto_r(10,10,10,29,11,33)
smooth_r(23,4,25,6)
smooth_r(-17,83,-17,78)
Lineto(225,462)
te.end_fill()
te.color("black","#968281")
Moveto(262,329)
te.begin_fill()
vertical(17)
curveto_r(1,2,44,14,45,15)
smooth_r(3,12,3,12)
horizontal(3)
vertical(-5)
curveto_r(1,-3,4,-6,5,-7)
lineto(36,-14)
curveto_r(1,-1,3,-16,2,-17)
Curveto(318,348,296,344,262,329)
te.end_fill()
te.color("black","#E7F1FF")
Moveto(225,462)
te.begin_fill()
lineto(-3,-5)
curveto_r(0,-2,4,-4,5,-6)
smooth_r(16,3,19,-8)
smooth_r(0,-7,0,-11)
smooth_r(5,-8,9,-5)
smooth_r(19,-8,19,-11)
smooth_r(6,-7,6,-7)
smooth_r(7,-2,9,-4)
lineto(41,-2)
lineto(12,9)
smooth_r(3,15,7,18)
smooth_r(15,4,17,4)
smooth_r(4,-4,6,-4)
smooth_r(6,4,5,9)
smooth_r(0,9,0,9)
smooth_r(1,7,7,6)
smooth_r(8,0,8,0)
lineto(-2,8)
Lineto(225,462)
te.end_fill()
te.pensize(2)
Moveto(240,450)
smooth_r(0,9,3,12)
Moveto(372,462)
curveto_r(-2,-4,-5,-29,-7,-28)
te.pensize(1)
te.color("black","#A2B8D6")
Moveto(262,331)
te.begin_fill()
curveto_r(0,8,-1,13,0,15)
smooth_r(43,14,45,15)
lineto(3,12)
horizontal(3)
smooth_r(-1,-3,0,-5)
lineto(5,-7)
lineto(36,-14)
curveto_r(1,-1,2,-12,2,-15)
smooth_r(25,-2,15,13)
curveto_r(-2,4,-7,29,-7,32)
smooth_r(-35,19,-41,22)
smooth_r(-9,14,-12,14)
smooth_r(-7,-12,-14,-15)
curveto_r(-19,-2,-41,-25,-41,-25)
smooth_r(-10,-26,-10,-30)
Smooth(255,332,262,331)
te.end_fill()
Moveto(262,346)
lineto(-12,-6)
Moveto(369,333)
curveto_r(2,4,-6,10,-15,14)
te.color("black","#151515")
Moveto(247,358)
te.begin_fill()
curveto_r(-5,3,-8,20,-6,23)
curveto_r(25,21,50,17,50,17)
lineto(-23,64)
horizontal(22)
smooth_r(1,-13,2,-16)
lineto(13,-50)
curveto_r(2,2,7,3,10,1)
smooth_r(18,65,18,65)
horizontal(19)
lineto(-24,-65)
curveto_r(21,5,39,-10,44,-13)
curveto_r(5,-20,1,-21,0,-24)
curveto_r(-18,-2,-49,15,-52,17)
smooth_r(-11,-3,-15,-1)
Smooth(252,356,247,358)
te.end_fill()
te.color("black","#A2B8D6")
Moveto(297,387)
te.begin_fill()
lineto(-11,6)
curveto_r(-1,0,-20,-7,-30,-19)
Curveto(259,373,297,385,297,387)
te.end_fill()
Moveto(323,384)
te.begin_fill()
lineto(8,7)
lineto(30,-14)
curveto_r(1,-1,5,-6,4,-7)
Smooth(329,379,323,384)
te.end_fill()
te.color("black","#F3EEEB")
Moveto(185,212)
te.begin_fill()
curveto_r(4,-9,46,-77,52,-75)
curveto_r(-2,-17,19,-68,27,-73)
curveto_r(16,15,71,108,76,112)
smooth_r(76,53,86,60)
curveto_r(0,65,-27,75,-31,76)
curveto_r(-50,28,-70,30,-85,30)
smooth_r(-77,-22,-86,-26)
Curveto(180,302,186,228,185,212)
te.end_fill()
te.color("black","#2B1D29")
Moveto(189,202)
te.begin_fill()
curveto_r(-1,22,19,51,19,51)
smooth_r(-10,-42,7,-92)
Curveto(212,168,196,189,189,202)
te.end_fill()
Moveto(221,155)
te.begin_fill()
curveto_r(-2,6,5,48,5,48)
smooth_r(18,-28,20,-48)
curveto_r(-5,24,4,43,7,50)
curveto_r(-10,-49,3,-72,13,-106)
curveto_r(-2,-7,-3,-32,-3,-35)
curveto_r(-17,18,-27,71,-27,71)
Lineto(221,155)
te.end_fill()
Moveto(264,64)
te.begin_fill()
curveto_r(-4,5,14,100,14,100)
smooth_r(-6,-79,-5,-85)
curveto_r(0,98,49,139,49,139)
smooth_r(8,-50,3,-65)
Smooth(272,64,264,64)
te.end_fill()
Moveto(342,176)
te.begin_fill()
curveto_r(-1,27,-10,57,-10,57)
smooth_r(20,-33,17,-54)
Lineto(342,176)
te.end_fill()
te.penup()
te.begin_fill()
polyline(349,180,353,203,361,203)
polyline(361,203,362,188,349,180)
te.end_fill()
te.pensize(2)
Moveto(210,180)
curveto_r(5,-4,63,9,63,14)
Moveto(338,193)
curveto_r(0,-3,18,-6,18,-6)
te.pensize(1)
te.color("black","#D1D1D1")
te.pensize(2)
Moveto(206,212)
te.begin_fill()
lineto(15,-7)
curveto_r(4,-1,26,-2,30,0)
smooth_r(10,3,12,7)
te.pencolor("#D1D1D1")
te.pensize(1)
smooth_r(2,27,-1,30)
smooth_r(-39,5,-44,1)
Smooth(206,212,206,212)
te.end_fill()
Moveto(384,204)
te.begin_fill()
te.pencolor("black")
te.pensize(2)
curveto_r(-3,-1,-18,-1,-28,1)
smooth_r(-9,6,-10,9)
te.pencolor("#D1D1D1")
te.pensize(1)
smooth_r(3,18,6,23)
smooth_r(38,6,40,4)
smooth_r(10,-9,13,-22)
te.pencolor("black")
te.pensize(2)
Lineto(384,204)
te.end_fill()
te.color("#0C1631","#0C1631")
te.pensize(1)
Moveto(216,206)
te.begin_fill()
curveto_r(-1,5,0,26,7,35)
smooth_r(30,2,33,0)
smooth_r(5,-31,2,-34)
Smooth(219,203,216,206)
te.end_fill()
Moveto(354,207)
te.begin_fill()
curveto_r(-2,1,2,29,4,31)
smooth_r(30,3,33,1)
smooth_r(6,-24,4,-27)
lineto(-11,-8)
Curveto(382,204,357,206,354,207)
te.end_fill()
te.color("#F5F5F5","#F5F5F5")
Moveto(253,211)
te.begin_fill()
curveto_r(-3,0,-8,8,1,10)
Smooth(258,210,253,211)
te.end_fill()
Moveto(392,209)
te.begin_fill()
lineto(4,3)
vertical(4)
lineto(-4,2)
Curveto(386,214,392,209,392,209)
te.end_fill()
te.color("#352F53","#352F53")
Moveto(219,229)
te.begin_fill()
smooth_r(2,-5,6,-4)
smooth_r(18,13,27,1)
curveto_r(3,0,5,3,5,3)
vertical(13)
Horizontal(224)
Lineto(219,229)
te.end_fill()
Moveto(357,227)
te.begin_fill()
smooth_r(4,-6,10,-2)
smooth_r(10,13,19,1)
curveto_r(6,0,8,6,8,6)
lineto(-2,9)
curveto_r(-12,3,-29,0,-32,-2)
Smooth(357,227,357,227)
te.end_fill()
te.color("#9A90CB","#9A90CB")
Moveto(227,231)
te.begin_fill()
curveto_r(-6,0,-5,5,-3,8)
smooth_r(24,2,27,0)
smooth_r(0,-8,-1,-8)
Smooth(234,231,227,231)
te.end_fill()
Moveto(361,227)
te.begin_fill()
curveto_r(2,18,26,14,30,6)
smooth_r(-1,-3,-2,-4)
smooth_r(-15,9,-24,-4)
Curveto(363,224,361,225,361,227)
te.end_fill()
te.pencolor("black")
te.pensize(3)
Moveto(225,215)
curveto_r(10,28,22,16,24,6)
Moveto(365,219)
curveto_r(4,14,18,24,22,-3)
te.pensize(2)
line(240.5,207.5,227.5,211.5)
line(245.5,209.5,227.5,214.5)
line(247.5,211.5,227.5,217.5)
line(247.5,214.5,229.5,220.5)
line(247.5,218.5,230.5,223.5)
line(246.5,222.5,232.5,226.5)
line(244.5,225.5,234.5,228.5)
line(377.5,207.5,367.5,210.5)
line(384.5,207.5,366.5,212.5)
line(385.5,210.5,366.5,215.5)
line(384.5,213.5,366.5,218.5)
line(384.5,215.5,367.5,220.5)
line(384.5,218.5,368.5,223.5)
line(382.5,223.5,370.5,227.5)
te.pencolor("black")
Moveto(309,270)
curveto_r(0,0,4,7,1,9)
line(296.5,307.5,303.5,307.5)
Moveto(315,307)
smooth_r(10,-1,10,2)
te.penup()
te.hideturtle()
te.update()
te.done()
偷看的皮卡丘
from turtle import *
def wall():
penup()
speed(0)
seth(180)
fd(40)
seth(90)
fd(255)
pendown()
seth(-90)
pensize(5)
pencolor("#915442")
fd(450)
print(position())
penup()
def nut():
penup()
pencolor("#915442")
fillcolor("chocolate")
goto(-40.00,-110.00)
pendown()
begin_fill()
seth(20)
for i in range(1,7):
fd(9)
left(7)
for i in range(1,4):
fd(10)
left(13)
seth(120)
for i in range(1,7):
fd(5)
left(13)
for i in range(1,7):
fd(5)
left(5)
end_fill()
penup()
goto(-40.00,-103.00)
pendown()
fillcolor("sandybrown")
begin_fill()
seth(24)
for i in range(1,7):
fd(9)
left(7)
for i in range(1,4):
fd(9)
left(13)
seth(120)
for i in range(1,5):
fd(5)
left(19)
for i in range(1,7):
fd(5)
left(5)
end_fill()
penup()
def body():
penup()
goto(-40.00,-190)
pendown()
pencolor("#915442")
pensize(3)
fillcolor("#fff699")
begin_fill()
seth(0)
fd(8)
print(position())
seth(60)
for i in range(1,7):
fd(3)
right(9)
for i in range(1,4):
fd(4)
right(4)
penup()
goto(-30.00,-190.00)
pendown()
seth(-30)
for i in range(1,5):
fd(3)
left(12)
print(position())
seth(60)
for i in range(1,4):
fd(2)
right(10)
penup()
goto(-18.58,-193.43)
pendown()
seth(0)
fd(4)
for i in range(1,4):
fd(3)
left(9)
print(position())
for i in range(1,3):
fd(3)
left(9)
penup()
goto(-5.76,-192.03)
pendown()
seth(-40)
for i in range(1,3):
fd(1)
left(20)
fd(8)
seth(10)
for i in range(1,9):
fd(3)
left(7)
seth(70)
fd(25)
circle(25,15)
seth(95)
fd(35)
circle(-18,25)
seth(85)
fd(30)
for i in range(1,21):
fd(5)
left(7)
end_fill()
penup()
goto(-32.00,-190.00)
pendown()
begin_fill()
seth(60)
for i in range(1,7):
fd(3)
right(9)
for i in range(1,4):
fd(4)
right(4)
end_fill()
penup()
goto(-27.00,-187.50)
pendown()
pencolor("#fff699")
pensize(4.5)
goto(-5.00,-180.0)
penup()
def marginal():
goto(-40,100)
pencolor("#915442")
fillcolor("#fff699")
begin_fill()
pendown()
seth(15)
fd(13)
pencolor("#bda537")
seth(-100)
pensize(3)
fd(10)
goto(-27.44,103.36)
seth(70)
pencolor("#915442")
for i in range(4):
fd(15)
rt(5)
for i in range(3):
fd(17)
rt(8)
seth(-45)
fd(3)
seth(-100)
fd(15)
for i in range(8):
rt(1)
fd(1)
seth(-108)
fd(20)
for i in range(3):
fd(19)
rt(9)
pencolor("#915442")
fd(8)
penup()
goto(3.46,96.21)
pendown()
pensize(4)
seth(-10)
fd(15)
pensize(3)
circle(-40,30)
pensize(4)
fd(10)
pensize(3)
circle(30,20)
for i in range(5):
fd(1.5)
lt(2)
pensize(2)
seth(0)
fd(5)
pensize(3)
seth(-160)
circle(-80,10)
pensize(2)
fd(4)
penup()
lt(180)
fd(4)
pendown()
seth(-30)
pensize(3)
fd(20)
circle(-1,140)
fd(8)
seth(-30)
pencolor("#d06521")
circle(-20,45)
penup()
pencolor("#915442")
goto(61.53,54.30)
pendown()
seth(10)
pensize(4)
fd(50)
print(position())
for i in range(5):
fd(10)
rt(3)
seth(-10)
pensize(3)
for i in range(9):
fd(1.5)
rt(20)
lt(55)
circle(-90,30)
circle(-120,25)
seth(110)
pensize(1)
fd(3)
pensize(4)
seth(-80)
fd(25)
for i in range(10):
fd(2)
rt(2)
for i in range(5):
fd(3)
rt(3)
fd(40)
circle(-20,60)
circle(-10,40)
lt(25)
fd(64.91)
end_fill()
penup()
def eyes():
goto(-38,10)
seth(45)
pendown()
begin_fill()
pencolor("#6b2a18")
fillcolor("#6b2a18")
circle(50,30)
circle(7,170)
end_fill()
goto(-34,39)
pencolor("#fffcea")
dot(5)
penup()
goto(-50,100)
penup()
pencolor("#743212")
goto(45,-35)
pendown()
seth(50)
begin_fill()
fillcolor("#6b2a18")
circle(50,30)
circle(6,170)
rt(25)
circle(50,25)
circle(7,30)
circle(6,35)
circle(7,45)
goto(45,-35)
end_fill()
penup()
goto(45,-9)
pendown()
pencolor("#fffcea")
dot(5)
penup()
hideturtle()
def printleft():
penup()
goto(-27.44,103.36)
fillcolor("#8b3c15")
seth(70)
pencolor("#915442")
for i in range(3):
fd(15)
rt(5)
begin_fill()
for i in range(1):
fd(15)
rt(5)
for i in range(3):
fd(17)
rt(8)
seth(-45)
fd(3)
seth(-100)
fd(15)
for i in range(8):
rt(1)
fd(1)
seth(-108)
fd(20)
for i in range(1):
fd(19)
rt(9)
seth(95)
circle(60,20)
circle(10,70)
end_fill()
penup()
def rightprint():
goto(61.53,54.30)
pendown()
seth(10)
pensize(4)
fd(50)
fillcolor("#8b3c15")
begin_fill()
for i in range(5):
fd(10)
rt(3)
seth(-10)
for i in range(9):
fd(1.5)
rt(20)
lt(55)
circle(-90,30)
circle(-120,7)
seth(60)
circle(40,30)
circle(15,40)
penup()
end_fill()
def hand():
penup()
goto(16,-80)
pencolor("#915442")
pensize(3)
fillcolor("#fff699")
pendown()
begin_fill()
seth(100)
fd(10)
circle(10,30)
fd(15)
circle(10,40)
fd(10)
seth(300)
fd(5)
seth(170)
fd(7)
seth(280)
fd(7)
seth(170)
fd(5)
seth(250)
fd(7)
for i in range(1,6):
fd(0.5)
left(10)
seth(-70)
fd(15)
circle(30,10)
for i in range(1,5):
fd(7)
left(4)
end_fill()
pendown()
def nose():
penup()
goto(2,-15)
pendown()
pencolor("#915442")
dot(4)
penup()
wall()
body()
marginal()
nut()
printleft()
rightprint()
hand()
nose()
eyes()
done()
菱形太阳花
import turtle
def draw_diamond(turt):
for i in range(1,3):
turt.forward(100)
turt.right(45)
turt.forward(100)
turt.right(135)
def draw_art():
window=turtle.Screen()
window.bgcolor("blue")
brad=turtle.Turtle()
brad.shape("turtle")
brad.color("orange")
brad.speed('fast')
for i in range(1,13):
draw_diamond(brad)
brad.right(30)
brad.right(90)
brad.forward(300)
window.exitonclick()
draw_art()
搞笑-斜眼笑黄色圆脸娃
import turtle as t
t.penup()
t.fd(75)
t.pendown()
t.pensize(150)
t.pencolor("gold")
t.seth(90)
t.circle(75)
t.seth(0)
t.penup()
t.fd(21)
t.seth(-90)
t.fd(72)
t.seth(53)
t.pendown()
t.pencolor("black")
t.pensize(5)
t.circle(120,-106)
t.seth(90)
t.penup()
t.fd(82)
t.seth(180)
t.fd(44)
t.seth(90)
t.seth(0)
t.pendown()
t.pensize(20)
t.pencolor("pink")
t.fd(60)
t.penup()
t.fd(160)
t.pendown()
t.fd(60)
t.seth(90)
t.penup()
t.fd(40)
t.seth(180)
t.fd(10)
t.seth(163)
t.pendown()
t.pencolor("whitesmoke")
t.pensize(30)
t.circle(154.54,30)
t.seth(180)
t.penup()
t.fd(100)
t.seth(164)
t.pendown()
t.circle(154.54,30)
t.penup()
t.seth(0)
t.fd(25)
t.seth(90)
t.fd(2)
t.pendown()
t.pencolor("black")
t.pensize(16)
t.circle(8)
t.penup()
t.seth(0)
t.fd(180)
t.seth(90)
t.pendown()
t.circle(8)
t.penup()
t.seth(180)
t.fd(10)
t.seth(90)
t.fd(33)
t.seth(-120)
t.pendown()
t.pensize(5)
t.circle(40,-120)
t.penup()
t.seth(180)
t.fd(201.56)
t.seth(120)
t.pendown()
t.circle(40,120)
t.done()
爱心-填字-表白
import turtle
import time
def hart_arc():
for i in range(200):
turtle.right(1)
turtle.forward(2)
def move_pen_position(x, y):
turtle.hideturtle()
turtle.up()
turtle.goto(x, y)
turtle.down()
turtle.showturtle()
love = input("请输入表白话语,默认为‘I Love You’:")
signature = input("请签署你的大名,不填写默认不显示:")
if love == '':
love = 'I Love You'
turtle.setup(width=800, height=500)
turtle.color('red', 'pink')
turtle.pensize(3)
turtle.speed(1)
move_pen_position(x=0, y=-180)
turtle.left(140)
turtle.begin_fill()
turtle.forward(224)
hart_arc()
turtle.left(120)
hart_arc()
turtle.forward(224)
turtle.end_fill()
move_pen_position(0, 0)
turtle.hideturtle()
turtle.color('#CD5C5C', 'pink')
turtle.write(love, font=('Arial', 30, 'bold'), align="center")
if signature != '':
turtle.color('red', 'pink')
time.sleep(2)
move_pen_position(180, -180)
turtle.hideturtle()
turtle.write(signature, font=('Arial', 20), align="center")
window = turtle.Screen()
window.exitonclick()
红玫瑰
from turtle import *
import time
setup(600, 800, 0, 0)
speed(0)
penup()
seth(90)
fd(340)
seth(0)
pendown()
speed(5)
begin_fill()
fillcolor('red')
circle(50, 30)
for i in range(10):
fd(1)
left(10)
circle(40, 40)
for i in range(6):
fd(1)
left(3)
circle(80, 40)
for i in range(20):
fd(0.5)
left(5)
circle(80, 45)
for i in range(10):
fd(2)
left(1)
circle(80, 25)
for i in range(20):
fd(1)
left(4)
circle(50, 50)
time.sleep(0.1)
circle(120, 55)
speed(0)
seth(-90)
fd(70)
right(150)
fd(20)
left(140)
circle(140, 90)
left(30)
circle(160, 100)
left(130)
fd(25)
penup()
right(150)
circle(40, 80)
pendown()
left(115)
fd(60)
penup()
left(180)
fd(60)
pendown()
end_fill()
right(120)
circle(-50, 50)
circle(-20, 90)
speed(1)
fd(75)
speed(0)
circle(90, 110)
penup()
left(162)
fd(185)
left(170)
pendown()
circle(200, 10)
circle(100, 40)
circle(-52, 115)
left(20)
circle(100, 20)
circle(300, 20)
speed(1)
fd(250)
penup()
speed(0)
left(180)
fd(250)
circle(-300, 7)
right(80)
circle(200, 5)
pendown()
left(60)
begin_fill()
fillcolor('green')
circle(-80, 100)
right(90)
fd(10)
left(20)
circle(-63, 127)
end_fill()
penup()
left(50)
fd(20)
left(180)
pendown()
circle(200, 25)
penup()
right(150)
fd(180)
right(40)
pendown()
begin_fill()
fillcolor('green')
circle(-100, 80)
right(150)
fd(10)
left(60)
circle(-80, 98)
end_fill()
penup()
left(60)
fd(13)
left(180)
pendown()
speed(1)
circle(-200, 23)
exitonclick()
樱花树
第1种:樱花飘舞
from turtle import *
from random import *
from math import *
def tree(n,l):
pd()
t = cos(radians(heading()+45))/8+0.25
pencolor(t,t,t)
pensize(n/3)
forward(l)
if n>0:
b = random()*15+10
c = random()*15+10
d = l*(random()*0.25+0.7)
right(b)
tree(n-1,d)
left(b+c)
tree(n-1,d)
right(c)
else:
right(90)
n=cos(radians(heading()-45))/4+0.5
pencolor(n,n*0.8,n*0.8)
circle(3)
left(90)
if(random()>0.7):
pu()
t = heading()
an = -40 +random()*40
setheading(an)
dis = int(800*random()*0.5 + 400*random()*0.3 + 200*random()*0.2)
forward(dis)
setheading(t)
pd()
right(90)
n = cos(radians(heading()-45))/4+0.5
pencolor(n*0.5+0.5,0.4+n*0.4,0.4+n*0.4)
circle(2)
left(90)
pu()
t=heading()
setheading(an)
backward(dis)
setheading(t)
pu()
backward(l)
bgcolor(0.5,0.5,0.5)
ht()
speed(0)
tracer(0,0)
pu()
backward(100)
left(90)
pu()
backward(300)
tree(12,100)
done()
第2种:掉落花瓣樱花树
import turtle
import random
from turtle import *
from time import sleep
def tree(branchLen, t):
sleep(0.0005)
if branchLen > 3:
if 8 <= branchLen <= 12:
if random.randint(0, 2) == 0:
t.color('snow')
else:
t.color('lightcoral')
t.pensize(branchLen / 3)
elif branchLen < 8:
if random.randint(0, 1) == 0:
t.color('snow')
else:
t.color('lightcoral')
t.pensize(branchLen / 2)
else:
t.color('sienna')
t.pensize(branchLen / 10)
t.forward(branchLen)
a = 1.5 * random.random()
t.right(20 * a)
b = 1.5 * random.random()
tree(branchLen - 10 * b, t)
t.left(40 * a)
tree(branchLen - 10 * b, t)
t.right(20 * a)
t.up()
t.backward(branchLen)
t.down()
def petal(m, t):
for i in range(m):
a = 200 - 400 * random.random()
b = 10 - 20 * random.random()
t.up()
t.forward(b)
t.left(90)
t.forward(a)
t.down()
t.color('lightcoral')
t.circle(1)
t.up()
t.backward(a)
t.right(90)
t.backward(b)
def main():
t = turtle.Turtle()
w = turtle.Screen()
t.hideturtle()
t.getscreen().tracer(5, 0)
w.screensize(bg='wheat')
t.left(90)
t.up()
t.backward(150)
t.down()
t.color('sienna')
tree(60, t)
petal(200, t)
w.exitonclick()
main()
第3种:灰色樱花树
from turtle import *
from random import *
from math import *
def tree(n, l):
pd()
t = cos(radians(heading() + 45)) / 8 + 0.25
pencolor(t, t, t)
pensize(n / 4)
forward(l)
if n > 0:
b = random() * 15 + 10
c = random() * 15 + 10
d = l * (random() * 0.35 + 0.6)
right(b)
tree(n - 1, d)
left(b + c)
tree(n - 1, d)
right(c)
else:
right(90)
n = cos(radians(heading() - 45)) / 4 + 0.5
pencolor(n, n, n)
circle(2)
left(90)
pu()
backward(l)
bgcolor(0.5, 0.5, 0.5)
ht()
speed(0)
tracer(0, 0)
left(90)
pu()
backward(300)
tree(13, 100)
done()
皮卡丘-脸
import turtle
def drawNose():
turtle.penup()
turtle.seth(90)
turtle.fd(100)
turtle.pendown()
turtle.begin_fill()
turtle.fillcolor('black')
turtle.seth(45)
turtle.fd(25)
turtle.seth(135)
turtle.circle(25, 95)
turtle.seth(315)
turtle.fd(25)
turtle.end_fill()
def drawEyes(seth, fd, r):
turtle.penup()
turtle.seth(seth)
turtle.fd(fd)
turtle.pendown()
turtle.begin_fill()
turtle.fillcolor('black')
turtle.circle(50)
turtle.end_fill()
turtle.penup()
turtle.circle(50, r)
turtle.pendown()
turtle.begin_fill()
turtle.fillcolor('white')
turtle.circle(20)
turtle.end_fill()
def drawFace(seth, fd):
turtle.penup()
turtle.seth(seth)
turtle.fd(fd)
turtle.pendown()
turtle.begin_fill()
turtle.fillcolor('red')
turtle.circle(70)
turtle.end_fill()
def drawLip():
turtle.penup()
turtle.seth(135)
turtle.fd(250)
turtle.pendown()
turtle.seth(-300)
turtle.circle(30, -65)
turtle.begin_fill()
turtle.fillcolor('Firebrick')
turtle.seth(165)
turtle.fd(140)
turtle.seth(195)
turtle.fd(140)
turtle.seth(-360)
turtle.circle(30, -65)
turtle.penup()
turtle.seth(-60)
turtle.circle(30, 65)
turtle.pendown()
turtle.seth(-70)
turtle.fd(240)
turtle.circle(55, 140)
turtle.seth(70)
turtle.fd(240)
turtle.end_fill()
turtle.seth(-110)
turtle.fd(80)
turtle.begin_fill()
turtle.fillcolor('Firebrick')
turtle.seth(120)
turtle.circle(120, 123)
turtle.seth(-70)
turtle.fd(165)
turtle.circle(55, 140)
turtle.seth(72)
turtle.fd(165)
turtle.end_fill()
def main():
turtle.pensize(4)
turtle.hideturtle()
turtle.setup(1000, 600)
turtle.speed(10)
turtle.screensize(bg='yellow')
drawNose()
drawEyes(160, 250, 60)
drawEyes(-9.5, 530, 230)
drawFace(195, 600)
drawFace(-11, 720)
drawLip()
turtle.done()
if __name__ == '__main__':
main()
小猪佩奇
import turtle as t
t.pensize(4)
t.hideturtle()
t.colormode(255)
t.color((255, 155, 192), "pink")
t.setup(840, 500)
t.speed(10)
t.pu()
t.goto(-100, 100)
t.pd()
t.seth(-30)
t.begin_fill()
a = 0.4
for i in range(120):
if 0 <= i < 30 or 60 <= i < 90:
a = a + 0.08
t.lt(3)
t.fd(a)
else:
a = a - 0.08
t.lt(3)
t.fd(a)
t.end_fill()
t.pu()
t.seth(90)
t.fd(25)
t.seth(0)
t.fd(10)
t.pd()
t.pencolor(255, 155, 192)
t.seth(10)
t.begin_fill()
t.circle(5)
t.color(160, 82, 45)
t.end_fill()
t.pu()
t.seth(0)
t.fd(20)
t.pd()
t.pencolor(255, 155, 192)
t.seth(10)
t.begin_fill()
t.circle(5)
t.color(160, 82, 45)
t.end_fill()
t.color((255, 155, 192), "pink")
t.pu()
t.seth(90)
t.fd(41)
t.seth(0)
t.fd(0)
t.pd()
t.begin_fill()
t.seth(180)
t.circle(300, -30)
t.circle(100, -60)
t.circle(80, -100)
t.circle(150, -20)
t.circle(60, -95)
t.seth(161)
t.circle(-300, 15)
t.pu()
t.goto(-100, 100)
t.pd()
t.seth(-30)
a = 0.4
for i in range(60):
if 0 <= i < 30 or 60 <= i < 90:
a = a + 0.08
t.lt(3)
t.fd(a)
else:
a = a - 0.08
t.lt(3)
t.fd(a)
t.end_fill()
t.color((255, 155, 192), "pink")
t.pu()
t.seth(90)
t.fd(-7)
t.seth(0)
t.fd(70)
t.pd()
t.begin_fill()
t.seth(100)
t.circle(-50, 50)
t.circle(-10, 120)
t.circle(-50, 54)
t.end_fill()
t.pu()
t.seth(90)
t.fd(-12)
t.seth(0)
t.fd(30)
t.pd()
t.begin_fill()
t.seth(100)
t.circle(-50, 50)
t.circle(-10, 120)
t.circle(-50, 56)
t.end_fill()
t.color((255, 155, 192), "white")
t.pu()
t.seth(90)
t.fd(-20)
t.seth(0)
t.fd(-95)
t.pd()
t.begin_fill()
t.circle(15)
t.end_fill()
t.color("black")
t.pu()
t.seth(90)
t.fd(12)
t.seth(0)
t.fd(-3)
t.pd()
t.begin_fill()
t.circle(3)
t.end_fill()
t.color((255, 155, 192), "white")
t.pu()
t.seth(90)
t.fd(-25)
t.seth(0)
t.fd(40)
t.pd()
t.begin_fill()
t.circle(15)
t.end_fill()
t.color("black")
t.pu()
t.seth(90)
t.fd(12)
t.seth(0)
t.fd(-3)
t.pd()
t.begin_fill()
t.circle(3)
t.end_fill()
t.color((255, 155, 192))
t.pu()
t.seth(90)
t.fd(-95)
t.seth(0)
t.fd(65)
t.pd()
t.begin_fill()
t.circle(30)
t.end_fill()
t.color(239, 69, 19)
t.pu()
t.seth(90)
t.fd(15)
t.seth(0)
t.fd(-100)
t.pd()
t.seth(-80)
t.circle(30, 40)
t.circle(40, 80)
t.color("red", (255, 99, 71))
t.pu()
t.seth(90)
t.fd(-20)
t.seth(0)
t.fd(-78)
t.pd()
t.begin_fill()
t.seth(-130)
t.circle(100, 10)
t.circle(300, 30)
t.seth(0)
t.fd(230)
t.seth(90)
t.circle(300, 30)
t.circle(100, 3)
t.color((255, 155, 192), (255, 100, 100))
t.seth(-135)
t.circle(-80, 63)
t.circle(-150, 24)
t.end_fill()
t.color((255, 155, 192))
t.pu()
t.seth(90)
t.fd(-40)
t.seth(0)
t.fd(-27)
t.pd()
t.seth(-160)
t.circle(300, 15)
t.pu()
t.seth(90)
t.fd(15)
t.seth(0)
t.fd(0)
t.pd()
t.seth(-10)
t.circle(-20, 90)
t.pu()
t.seth(90)
t.fd(30)
t.seth(0)
t.fd(237)
t.pd()
t.seth(-20)
t.circle(-300, 15)
t.pu()
t.seth(90)
t.fd(20)
t.seth(0)
t.fd(0)
t.pd()
t.seth(-170)
t.circle(20, 90)
t.pensize(10)
t.color((240, 128, 128))
t.pu()
t.seth(90)
t.fd(-75)
t.seth(0)
t.fd(-180)
t.pd()
t.seth(-90)
t.fd(40)
t.seth(-180)
t.color("black")
t.pensize(15)
t.fd(20)
t.pensize(10)
t.color((240, 128, 128))
t.pu()
t.seth(90)
t.fd(40)
t.seth(0)
t.fd(90)
t.pd()
t.seth(-90)
t.fd(40)
t.seth(-180)
t.color("black")
t.pensize(15)
t.fd(20)
t.pensize(4)
t.color((255, 155, 192))
t.pu()
t.seth(90)
t.fd(70)
t.seth(0)
t.fd(95)
t.pd()
t.seth(0)
t.circle(70, 20)
t.circle(10, 330)
t.circle(70, 30)
t.done()
哆啦A梦
import turtle as t
t.pensize(8)
t.hideturtle()
t.screensize(500, 500, bg='white')
t.fillcolor('#00A1E8')
t.begin_fill()
t.circle(120)
t.end_fill()
t.pensize(3)
t.fillcolor('white')
t.begin_fill()
t.circle(100)
t.end_fill()
t.pu()
t.home()
t.goto(0, 134)
t.pd()
t.pensize(4)
t.fillcolor("#EA0014")
t.begin_fill()
t.circle(18)
t.end_fill()
t.pu()
t.goto(7, 155)
t.pensize(2)
t.color('white', 'white')
t.pd()
t.begin_fill()
t.circle(4)
t.end_fill()
t.pu()
t.goto(-30, 160)
t.pensize(4)
t.pd()
t.color('black', 'white')
t.begin_fill()
a = 0.4
for i in range(120):
if 0 <= i < 30 or 60 <= i < 90:
a = a + 0.08
t.lt(3)
t.fd(a)
else:
a = a - 0.08
t.lt(3)
t.fd(a)
t.end_fill()
t.pu()
t.goto(30, 160)
t.pensize(4)
t.pd()
t.color('black', 'white')
t.begin_fill()
for i in range(120):
if 0 <= i < 30 or 60 <= i < 90:
a = a + 0.08
t.lt(3)
t.fd(a)
else:
a = a - 0.08
t.lt(3)
t.fd(a)
t.end_fill()
t.pu()
t.goto(-38, 190)
t.pensize(8)
t.pd()
t.right(-30)
t.forward(15)
t.right(70)
t.forward(15)
t.pu()
t.goto(15, 185)
t.pensize(4)
t.pd()
t.color('black', 'black')
t.begin_fill()
t.circle(13)
t.end_fill()
t.pu()
t.goto(13, 190)
t.pensize(2)
t.pd()
t.color('white', 'white')
t.begin_fill()
t.circle(5)
t.end_fill()
t.pu()
t.home()
t.goto(0, 134)
t.pensize(4)
t.pencolor('black')
t.pd()
t.right(90)
t.forward(40)
t.pu()
t.home()
t.goto(0, 124)
t.pensize(3)
t.pencolor('black')
t.pd()
t.left(10)
t.forward(80)
t.pu()
t.home()
t.goto(0, 114)
t.pensize(3)
t.pencolor('black')
t.pd()
t.left(6)
t.forward(80)
t.pu()
t.home()
t.goto(0, 104)
t.pensize(3)
t.pencolor('black')
t.pd()
t.left(0)
t.forward(80)
t.pu()
t.home()
t.goto(0, 124)
t.pensize(3)
t.pencolor('black')
t.pd()
t.left(170)
t.forward(80)
t.pu()
t.home()
t.goto(0, 114)
t.pensize(3)
t.pencolor('black')
t.pd()
t.left(174)
t.forward(80)
t.pu()
t.home()
t.goto(0, 104)
t.pensize(3)
t.pencolor('black')
t.pd()
t.left(180)
t.forward(80)
t.pu()
t.goto(-70, 70)
t.pd()
t.color('black', 'red')
t.pensize(6)
t.seth(-60)
t.begin_fill()
t.circle(80, 40)
t.circle(80, 80)
t.end_fill()
t.pu()
t.home()
t.goto(-80, 70)
t.pd()
t.forward(160)
t.pu()
t.home()
t.goto(-50, 50)
t.pd()
t.pensize(1)
t.fillcolor("#eb6e1a")
t.seth(40)
t.begin_fill()
t.circle(-40, 40)
t.circle(-40, 40)
t.seth(40)
t.circle(-40, 40)
t.circle(-40, 40)
t.seth(220)
t.circle(-80, 40)
t.circle(-80, 40)
t.end_fill()
t.pu()
t.goto(-70, 12)
t.pensize(14)
t.pencolor('red')
t.pd()
t.seth(-20)
t.circle(200, 30)
t.circle(200, 10)
t.pu()
t.goto(0, -46)
t.pd()
t.pensize(3)
t.color("black", '#f8d102')
t.begin_fill()
t.circle(25)
t.end_fill()
t.pu()
t.goto(-5, -40)
t.pd()
t.pensize(2)
t.color("black", '#79675d')
t.begin_fill()
t.circle(5)
t.end_fill()
t.pensize(3)
t.right(115)
t.forward(7)
t.mainloop()
t.done()
时钟
import turtle as t
import datetime as d
def skip(step):
t.penup()
t.forward(step)
t.pendown()
def drawClock(radius):
t.speed(0)
t.mode("logo")
t.hideturtle()
t.pensize(7)
t.home()
for j in range(60):
skip(radius)
if (j % 5 == 0):
t.forward(20)
skip(-radius - 20)
else:
t.dot(5)
skip(-radius)
t.right(6)
def makePoint(pointName, len):
t.penup()
t.home()
t.begin_poly()
t.back(0.1 * len)
t.forward(len * 1.1)
t.end_poly()
poly = t.get_poly()
t.register_shape(pointName, poly)
def drawPoint():
global hourPoint, minPoint, secPoint, fontWriter
makePoint("hourPoint", 100)
makePoint("minPoint", 120)
makePoint("secPoint", 140)
hourPoint = t.Pen()
hourPoint.shape("hourPoint")
hourPoint.shapesize(1, 1, 6)
minPoint = t.Pen()
minPoint.shape("minPoint")
minPoint.shapesize(1, 1, 4)
secPoint = t.Pen()
secPoint.shape("secPoint")
secPoint.pencolor('red')
fontWriter = t.Pen()
fontWriter.pencolor('gray')
fontWriter.hideturtle()
def getWeekName(weekday):
weekName = ['星期一', '星期二', '星期三', '星期四', '星期五', '星期六', '星期日']
return weekName[weekday]
def getDate(year, month, day):
return "%s-%s-%s" % (year, month, day)
def realTime():
curr = d.datetime.now()
curr_year = curr.year
curr_month = curr.month
curr_day = curr.day
curr_hour = curr.hour
curr_minute = curr.minute
curr_second = curr.second
curr_weekday = curr.weekday()
t.tracer(False)
secPoint.setheading(360 / 60 * curr_second)
minPoint.setheading(360 / 60 * curr_minute)
hourPoint.setheading(360 / 12 * curr_hour + 30 / 60 * curr_minute)
fontWriter.clear()
fontWriter.home()
fontWriter.penup()
fontWriter.forward(80)
fontWriter.write(getWeekName(curr_weekday), align="center", font=("Courier", 14, "bold"))
fontWriter.forward(-160)
fontWriter.write(getDate(curr_year, curr_month, curr_day), align="center", font=("Courier", 14, "bold"))
t.tracer(True)
print(curr_second)
t.ontimer(realTime, 100)
def main():
t.tracer(False)
drawClock(160)
drawPoint()
realTime()
t.tracer(True)
t.mainloop()
if __name__ == '__main__':
main()