Python实现草莓熊手拿风车和鲜花
短信预约 -IT技能 免费直播动态提醒
样式:
代码:
#-*- coding: UTF-8 -*-import turtle as t # 设置背景颜色,窗口位置以及大小 t.colormode(255)# 颜色模式t.speed(0)t.screensize(850,760,"white")#画布大小背景颜色t.setup(width=850, height=760,startx=260, starty=0) #绘图窗口的大小和起始坐标# t.bgpic("C:/Users/Angle/Desktop/1.gif")t.title("专属XX的草莓熊!")#设置绘图窗口的标题t.resizemode('noresize') #大小调整模式:auto,user,noresizet.tracer(1) scolor=["#E6005C","#00BFFF","#538a30","#F28500"] # 深色列表qcolor=["#FF007F","#87CEFA","#7fbc2b","#FFA500"] # 浅色列表blsize=80 # blsize值,blsize,是大等腰直角三角形的斜边风车等比例缩放bs=2**0.5/2*blsize # bs是直角边,2**0.5 表示数学中的“根号2”# zjsjxxb是小等腰直角三角形的斜边,zjb是直角边zjb=blsize/2 # zjb是小等腰直角三角形的直角边zjsjxxb=2**0.5 *zjb # zjsjxxb是小等腰直角三角形的斜边length=1.7*blsize # 风车杆长width=2/15*blsize # 风车杆宽def fongche():#风车 t.penup() t.goto(-205,-42) t.begin_fill() t.pensize(4) t.pencolor("#321320") t.fillcolor("#D2B48C") t.circle(15) t.end_fill() t.penup() t.goto(-220,80) t.pendown() t.setheading(-90) t.pensize(width) t.pencolor("#5f4a1d") t.forward(length) t.pensize(2) t.backward(length) t.setheading(90) for i in range(4): # 小等腰直角三角形 t.color(scolor[i]) # 遍历深色列表scolor t.begin_fill() t.forward(zjb) t.left(90) t.forward(zjb) t.left(135) t.forward(zjsjxxb) t.end_fill() #t.pencolor(scolor[i]) #t.pensize(4) # 大等腰直角三角形 t.color(qcolor[i]) # 遍历浅色列表qcolor t.begin_fill() t.backward(zjsjxxb) t.right(90) t.forward(bs) t.left(135) t.forward(blsize) t.end_fill() #t.pencolor(scolor[i]) #t.pensize(4) # 旋转180度后,画下一片风车叶片 t.right(180) t.penup() mling_circle_list = iter([ # 每段弧线(半径,弧角度数) (18, 360), (14, 360), (10, 360), (6, 360), (18, 360), (14, 360), (10, 360), (6, 360),]) def mling_draw_eyeball(zb1,zb2,zb3,zb4): for zb, color_ in zip([zb1,zb2,zb3,zb4], ['#ffffff', '#482d08', '#000000', '#ffffff']): t.penup() t.goto(*zb) t.pendown() t.begin_fill() t.setheading(0) t.color(color_) t.pencolor('#000000') t.pensize(2) t.circle(*next(mling_circle_list)) t.end_fill() t.penup()p = t.home()t.pencolor("#321320")t.fillcolor("#cb3263")t.pensize(4)t.goto(120,110)t.pendown()t.begin_fill()t.goto(200,0)t.left(-40)t.circle(-110,105)t.left(75)t.goto(170,-110)t.left(-80)t.circle(30,40)t.left(60)t.circle(-80,70)t.left(83)t.circle(-35,95)t.goto(60,-270)t.left(-80)t.circle(-65,70)t.left(63)t.circle(35,30)t.left(130)t.circle(-65,70)t.goto(-120,-270)t.left(-110)t.circle(-35,80)t.left(83)t.circle(-80,50)t.left(60)t.circle(-80,60)t.left(60)t.circle(30,30)t.left(20)t.circle(80,80)t.left(-105)t.circle(-70,150)t.left(50)t.circle(-170,50)t.goto(120,110)#Author:Adversity Awaket.end_fill()t.penup()p = t.home()t.pencolor("#321320")t.fillcolor("#ffffff")t.pensize(4)t.goto(90,60)t.pendown()t.begin_fill()t.right(30)t.circle(-130,360)t.end_fill()t.penup()p = t.home()t.pencolor("#321320")t.fillcolor("#f3d2ad")t.pensize(4)t.goto(-250,-55)t.seth(0)t.pendown()t.begin_fill()t.right(-55)t.circle(-45,270)t.goto(-220,-75)t.goto(-250,-55)t.end_fill() fongche() t.penup()p = t.home()t.pencolor("#321320")t.fillcolor("#f3d2ad")t.pensize(4)t.goto(185,-90)t.pendown()t.begin_fill()t.right(140)t.circle(43,95)t.goto(185,-90)t.end_fill()t.penup()t.seth(0)t.pencolor('#321320')t.fillcolor('#cb3263')t.pensize(4)t.begin_fill()t.goto(21,0)t.pendown()t.circle(123,134)t.left(-90)t.circle(40,185)t.left(-60)t.circle(120,60)t.left(-90)t.circle(50,200)t.left(-90)t.circle(100,100)t.left(-12)t.circle(100,40)t.goto(21,0)t.penup()#Author:Adversity Awaket.end_fill()t.penup()t.goto(0, 0)t.seth(0)t.pencolor('#321320')t.fillcolor('#ffffff')t.pensize(4)t.begin_fill()t.goto(-70,210)t.left(140)t.pendown()t.circle(30,200)t.goto(-70,210)t.penup()t.end_fill()t.penup()t.goto(0, 0)t.seth(0)t.pencolor('#321320')t.fillcolor('#ffffff')t.pensize(4)t.begin_fill()t.goto(90,220)t.left(45)t.pendown()t.circle(22,200)t.goto(90,220)t.penup()t.end_fill()t.penup()t.goto(0, 0)t.seth(0)t.pencolor('#321320')t.fillcolor('#ffffff')t.pensize(4)t.begin_fill()t.left(-98)t.left(90)t.goto(18,10)t.pendown()t.circle(100,134)t.left(10)t.circle(110,30)t.left(10)t.circle(160,40)t.circle(85,40)t.left(2)t.circle(95,40)t.left(5)t.circle(95,60)t.goto(18,10)t.penup()t.end_fill()t.penup()p = t.home()t.pencolor("#321320")t.fillcolor("#8f3a52")t.pensize(2)t.goto(25,240)t.pendown()t.begin_fill()t.goto(60,235)t.left(30)t.fd(8)t.left(90)t.fd(22)t.circle(90, 8)t.left(20)t.circle(90, 8)t.left(20)t.circle(90, 20)t.left(40)t.circle(50, 20)t.end_fill()t.penup()t.pensize(12)t.goto(-2,250)t.pencolor("#4D1F00")t.fillcolor("#4D1F00")t.pendown()t.goto(60,240)t.end_fill()t.penup()p = t.home()t.pencolor("#321320")t.fillcolor("#8f3a52")t.pensize(2)t.goto(-55,193)t.pendown()t.begin_fill()t.left(65)t.circle(-90, 25)t.goto(-10,230)t.left(30)t.fd(8)t.left(90)t.fd(18)t.circle(90, 8)t.left(20)t.circle(90, 10)t.left(40)t.circle(90, 30)t.left(30)t.circle(40, 20)t.penup()t.end_fill()t.pensize(12)t.goto(-63,195)t.pencolor("#4D1F00")t.fillcolor("#4D1F00")t.pendown()t.left(100)t.circle(-85,45)t.end_fill() mling_draw_eyeball((-20,180), (-23,185), (-25,188), (-30,200)) mling_draw_eyeball((30, 193), (27, 200), (25,203), (20,213)) t.penup()p = t.home()t.pencolor("#321320")t.fillcolor("#8f3a52")t.pensize(3)t.goto(25,105)p = t.pos()t.pendown()t.begin_fill()t.circle(85, 65)t.left(16)t.circle(30, 55)t.left(20)t.circle(145, 58)t.left(8)t.circle(20, 55)t.left(8)t.circle(50, 65)t.left(-5)t.circle(310, 8)t.end_fill()t.penup()t.goto(0, 0)t.seth(0)t.pencolor('#321320')t.fillcolor('#a93e54')t.pensize(3)t.begin_fill()t.left(-20)t.goto(9,66)t.pendown()t.circle(68,40)t.left(10)t.circle(65,40)t.left(160)t.circle(-75,85)t.left(158)t.circle(48,37)t.goto(9,66)t.penup()t.end_fill()t.color('#321320')t.penup()t.goto(380,60)t.pendown()t.write("成\n功\n上\n岸\n一\n研\n为\n定\n",align="center",font=("黑体",20,"normal"))t.penup()t.goto(290,183)t.pendown()# t.write("成\n功\n上\n岸\n",align="center",font=("黑体",10,"normal"))t.hideturtle()# t.done()t.fillcolor("red")t.begin_fill()t.circle(10, 180)t.circle(25, 110)t.left(50)t.circle(60, 45)t.circle(20, 170)t.right(24)t.fd(30)t.left(-8)#原本是10t.circle(30, 110)t.fd(20)t.left(40)t.circle(90, 70)t.circle(30, 150)t.right(30)t.fd(15)t.circle(80, 90)t.left(15)t.fd(45)t.right(165)t.fd(20)t.left(155)t.circle(150, 80)t.left(50)t.circle(150, 90)t.end_fill()# 花瓣1t.left(150)t.circle(-90, 70)t.left(20)t.circle(75, 105)t.setheading(60)t.circle(80, 98)t.circle(-90, 40)# 花瓣2t.left(180)t.circle(90, 40)t.circle(-80, 98)t.setheading(-83)# 叶子1t.fd(30)t.left(90)t.fd(25)t.left(45)t.fillcolor("green")t.begin_fill()t.circle(-80, 90)t.right(90)t.circle(-80, 90)t.end_fill()t.right(135)t.fd(60)t.left(180)t.fd(85)t.left(90)t.fd(80)# 叶子2t.right(90)t.right(45)t.fillcolor("green")t.begin_fill()t.circle(80, 90)t.left(90)t.circle(80, 90)t.end_fill()t.left(135)t.fd(60)t.left(180)t.fd(60)t.right(90)t.circle(200, 60)t.done()
来源地址:https://blog.csdn.net/qq_44727672/article/details/127750274
免责声明:
① 本站未注明“稿件来源”的信息均来自网络整理。其文字、图片和音视频稿件的所属权归原作者所有。本站收集整理出于非商业性的教育和科研之目的,并不意味着本站赞同其观点或证实其内容的真实性。仅作为临时的测试数据,供内部测试之用。本站并未授权任何人以任何方式主动获取本站任何信息。
② 本站未注明“稿件来源”的临时测试数据将在测试完成后最终做删除处理。有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341