python turtle库绘图 520表白红玫瑰 樱花树 动漫 海绵宝宝 小猪佩奇 哆啦A梦 时钟等多个例满足你的需求

盾牌

import turtle  #引入一个绘图库
import math  #因为后面用到了根号,所以引入了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+x1y1=Height/2-y1x2=-Width/2+x2y2=Height/2-y2x3=-Width/2+x3y3=Height/2-y3x4=-Width/2+x4y4=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):                                #移动到svg坐标下(x,y)te.penup()te.goto(-Width/2+x,Height/2-y)
def line(x1,y1,x2,y2):                          #连接svg坐标下两点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):                              #连接当前点和相对坐标(dx,dy)的点te.pendown()te.goto(te.xcor()+dx,te.ycor()-dy)te.penup()
def Lineto(x,y):                                #连接当前点和svg坐标下(x,y)te.pendown()te.goto(-Width/2+x,Height/2-y)te.penup()
def Horizontal(x):                              #做到svg坐标下横坐标为x的水平线te.pendown()te.setx(x-Width/2)te.penup()
def horizontal(dx):                             #做到相对横坐标为dx的水平线te.seth(0)te.pendown()te.fd(dx)te.penup()
def vertical(dy):                               #做到相对纵坐标为dy的垂直线te.seth(-90)te.pendown()te.fd(dy)te.penup()te.seth(0)
def polyline(x1,y1,x2,y2,x3,y3):                #做svg坐标下的折线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):                   #三阶贝塞尔曲线到(x,y)te.penup()X_now=te.xcor()+Width/2Y_now=Height/2-te.ycor()Bezier_3(X_now,Y_now,x1,y1,x2,y2,x,y)global Xhglobal YhXh=x-x2Yh=y-y2
def curveto_r(x1,y1,x2,y2,x,y):                 #三阶贝塞尔曲线到相对坐标(x,y)te.penup()X_now=te.xcor()+Width/2Y_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 Xhglobal YhXh=x-x2Yh=y-y2
def Smooth(x2,y2,x,y):                          #平滑三阶贝塞尔曲线到(x,y)global Xhglobal Yh    te.penup()X_now=te.xcor()+Width/2Y_now=Height/2-te.ycor()Bezier_3(X_now,Y_now,X_now+Xh,Y_now+Yh,x2,y2,x,y)Xh=x-x2Yh=y-y2
def smooth_r(x2,y2,x,y):                        #平滑三阶贝塞尔曲线到相对坐标(x,y)global Xhglobal Yh    te.penup()X_now=te.xcor()+Width/2Y_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-x2Yh=y-y2
te.tracer(100)
te.pensize(1)
te.speed(Speed)
te.penup()#图层_2
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(328,47.712,344,175.977)
line(340.023,49,360.5,144)
# line(353.5,47.5,395.5,208.5)
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)#图层_3
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) #!!!227
curveto_r(7,4,54,45,61,61) #61
smooth_r(-73,101,-72,118)
curveto_r(5,15,31,46,31,45)
Lineto(390,462)
te.end_fill()
#图层_4
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()
#图层_5
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()
#图层_6
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()
#图层_8
te.color("black","#E7F1FF")     #白色褶皱
Moveto(225,462)
te.begin_fill()
lineto(-3,-5)#-3,-3,-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)
#图层_7
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)
#图层_9
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()
#图层_10
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()
#图层_11
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()
#图层_12
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()
#图层_13
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)
#图层_14
te.color("black","#D1D1D1") #眼睛1
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()
#图层_15
te.color("#0C1631","#0C1631") #眼睛2
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()#图层_17
te.color("#F5F5F5","#F5F5F5")     #眼睛3
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()
#图层_18
te.color("#352F53","#352F53")     #眼睛4
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()#图层_19
te.color("#9A90CB","#9A90CB") #眼睛5
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()#图层_16
te.pencolor("black")    #眼睛(线条)
te.pensize(3)
# Moveto(206,213)
# lineto(14,-8)
# curveto_r(3,-1,30,0,33,1)
# lineto(10,6)
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(383.5,220.5,368.5,225.5)
line(382.5,223.5,370.5,227.5)
#line(381.5,226.5,373.5,229.5)
#图层_20
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()

偷看的皮卡丘

#-*-coding:utf-8-*-from turtle import *#setup(450,535,None,None)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()

爱心-填字-表白

#!/usr/bin/env python
# -*- coding:utf-8 -*-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)  # 移动画笔到指定起始坐标(窗口中心为0,0)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)  # 向左旋转140度turtle.begin_fill()  # 标记背景填充位置# 画心形直线( 左下方 )
turtle.forward(224)  # 向前移动画笔,长度为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')  # 字体颜色
# font:设定字体、尺寸(电脑下存在的字体都可设置)  align:中心对齐
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 timesetup(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.25pencolor(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.5pencolor(n,n*0.8,n*0.8)circle(3)left(90)#添加0.3倍的飘落叶子if(random()>0.7):pu()#飘落t = heading()an = -40 +random()*40setheading(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.5pencolor(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()#隐藏turtle
speed(0)#速度 1-10渐进,0 最快
tracer(0,0)
pu()#抬笔
backward(100)
left(90)#左转90度
pu()#抬笔
backward(300)#后退300
tree(12,100)#递归7层
done()

第2种:掉落花瓣樱花树

#!/usr/bin/env python
# coding=utf-8import turtle
import random
from turtle import *
from time import sleep
# 画樱花的躯干(60,t)
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')  # 赭(zhě)色t.pensize(branchLen / 10)  # 6t.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')  # 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.25pencolor(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.5pencolor(n, n, n)circle(2)left(90)pu()backward(l)  # 退回
bgcolor(0.5, 0.5, 0.5)  # 背景色
ht()  # 隐藏turtle
speed(0)  # 速度,1-10渐进,0最快
tracer(0, 0)
left(90)  # 左转90度
pu()  # 抬笔
backward(300)  # 后退300
tree(13, 100)  # 递归7层
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()

小猪佩奇

# !/usr/bin/env python2
# coding=utf-8import turtle as tt.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.08t.lt(3)  # 向左转3度t.fd(a)  # 向前走a的步长else:a = a - 0.08t.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.08t.lt(3)  # 向左转3度t.fd(a)  # 向前走a的步长else:a = a - 0.08t.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.speed(5)
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.08t.lt(3)  # 向左转3度t.fd(a)  # 向前走a的步长else:a = a - 0.08t.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.08t.lt(3)  # 向左转3度t.fd(a)  # 向前走a的步长else:a = a - 0.08t.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()

时钟

# -*- coding:utf-8 –*-
# 用turtlr画时钟
# 以自定义shape的方式实现
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")  # 以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)  # 注册为一个shape
def drawPoint():  # 画指针global hourPoint, minPoint, secPoint, fontWritermakePoint("hourPoint", 100)makePoint("minPoint", 120)makePoint("secPoint", 140)hourPoint = t.Pen()  # 每个指针是一只新turtlehourPoint.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.yearcurr_month = curr.monthcurr_day = curr.daycurr_hour = curr.hourcurr_minute = curr.minutecurr_second = curr.secondcurr_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)# 用turtle写文字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)  # 每隔100毫秒调用一次realTime()
def main():t.tracer(False)drawClock(160)drawPoint()realTime()t.tracer(True)t.mainloop()
if __name__ == '__main__':main()

python turtle绘图多个实例相关推荐

  1. 巴斯光年python turtle绘图__附源代码

    巴斯光年python turtle绘图__附源代码 本文目录: 一.python turtle海龟绘图效果图 写在前面的题外话 二.绘图人物简介 三.代码演示方法和代码命令解释 四.怎么才能正常运行p ...

  2. 十分钟轻松学会python-10分钟轻松学会python turtle绘图

    python2.6版本中后引入的一个简单的绘图工具,叫做海龟绘图(Turtle Graphics),turtle库是python的内部库,使用导入即可 import turtle 先说明一下turtl ...

  3. python turtle循环图案-有趣的Python turtle绘图

    原标题:有趣的Python turtle绘图 Python Turtle是Python的一个编程教育类库,越来越受到教育者的关注,近日,以"智能时代,逐梦成长"为主题的第5届全国青 ...

  4. python turtle画椭圆-python turtle 绘制太极图的实例

    效果如下所示: # -*- coding: utf-8 -*- import turtle # 绘制太极图函数 def draw_TJT(R): turtle.screensize(800, 600, ...

  5. python turtle 绘图速度用函数会快吗_有趣的Python turtle绘图

    专 题 Feature Story 16 \ China Science & Technology Education 文 _ 毛京宇/北京师范大学第三附属中学 魏云靖/北京市师达中学 有趣的 ...

  6. Python Turtle绘图[难度2星]:甜美棒棒糖(基础效果 / 加描边优化)

    我喜欢turtle绘图,因为代码一点点的改动,总会带来意想不到的惊喜. 一些让我心动过的案例,分享给大家,也珍藏给自己. --Python教学路上的爬行者    案例1:棒棒糖(基础效果)       ...

  7. pythonturtle简单绘图_10分钟轻松学会 Python turtle 绘图

    10分钟轻松学会 Python turtle 绘图 python2.6版本中后引入的一个简单的绘图工具,叫做海龟绘图(Turtle Graphics),turtle库是python的内部库,使用导入即 ...

  8. Python Turtle绘图[难度3星]:24节气倒计时(2.使用字典存储数据)

    "我喜欢turtle绘图,因为代码一点点的改动,总会带来意想不到的惊喜. 一些让我心动过的案例,分享给大家,也珍藏给自己." -- 初中信息技术教师  许华丽 Python Tur ...

  9. python创意绘图-有趣的Python turtle绘图

    原标题:有趣的Python turtle绘图 Python Turtle是Python的一个编程教育类库,越来越受到教育者的关注,近日,以"智能时代,逐梦成长"为主题的第5届全国青 ...

最新文章

  1. c语言中求一个数的因数,【代码】求一个数的因数和、求优化、顺便也供新人参考算法...
  2. ICLR 2020| 最新NAS benchmark:0.1秒完成NAS算法搜索
  3. TP 框架没有考虑完善的功能点:1、表达式查询不支持INSTR形式的查询
  4. 2021略阳天津高级中学高考成绩查询,2021年天津高考成绩查询网站查分网址:http://www.zhaokao.net/...
  5. [网络安全自学篇] 八.Web漏洞及端口扫描之Nmap、ThreatScan和DirBuster原理详解
  6. volatile是Java提供的一种轻量级的同步机制
  7. zookeeper集群为什么是单数
  8. Linux查看so库访问的IP,linux-ip命令杂记
  9. 使用CSS在文字前面加上图标。
  10. 【渝粤教育】国家开放大学2018年春季 0605-22T中国古代文学(2) 参考试题
  11. 电商网站主动取消客户已支付成功订单感想
  12. TOGAF架构学习总结
  13. 谷歌浏览器无法调用java_怎么才能正常使用谷歌浏览器
  14. 数据管理与数据库 大学课程_根据数据显示的50种最佳免费在线大学课程
  15. (MIUI)小米手机录音丢失找回
  16. vue全家桶+koa2+mongoDB打造全栈社区博客
  17. QStatusBar
  18. 【webpack】记录hmr失效解决方案
  19. remote: Support for password authentication was removed
  20. 迎接我国第一款GNU操作系统的诞生

热门文章

  1. LINUX虚拟机与主机的文件交互
  2. videojs 销毁重新初始化
  3. 软件产品设计:学习与未来发展
  4. (转)当前中国互联网发展太快是否存在泡沫
  5. oracle查看外键约束哪个字段,oracle 查看主外键约束(转)
  6. 大连理工大学2021最优化方法大作业(3)
  7. Python day1 变量、常量、注释基础数据类型初始以及用户输入input
  8. c语言学习指南app,C语言学习指南下载-C语言学习指南 v1.0.0_手机乐园
  9. python commands模块_python之commands和subprocess入门介绍(可执行shell命令的模块)
  10. CF #499 div2 C. Fly(模拟)