turtle画粽子(微改版)
发布日期:2021-06-29 14:39:38 浏览次数:2 分类:技术文章

本文共 1806 字,大约阅读时间需要 6 分钟。

from turtle import *import mathhideturtle()colormode(255)def zongzi():    pensize(2)    pencolor(2, 51, 12)    fillcolor(4, 77, 19)    begin_fill()    fd(200)    circle(15, 120)    fd(200)    circle(15, 120)    fd(200)    circle(15, 120)    fd(200)    circle(15, 60)    fd(100)    circle(15, 90)    fd(173)    circle(1, 90)    end_fill()    penup()    fd(100)    right(60)    back(105)    a = pos()    pendown()    color(60, 67, 0)    fillcolor(85, 97, 9)    begin_fill()    fd(120)    goto(a)    penup()    back(15)    left(90)    fd(20)    right(90)    pendown()    fd(150)    right(120)    fd(24)    right(60)    fd(120)    right(60)    fd(24)    end_fill()    begin_fill()    left(110)    fd(65)    left(100)    fd(24)    left(80)    fd(50)    end_fill()def ty(a,b,angle,steps,rotateAngle):    minAngle = (2*math.pi/360) * angle / steps    rotateAngle = rotateAngle/360*2*math.pi    penup()    setpos(b*math.sin(rotateAngle),-b*math.cos(rotateAngle))    pendown()    for i in range(steps):        nextPoint = [a*math.sin((i+1)*minAngle),-b*math.cos((i+1)*minAngle)]        nextPoint = [nextPoint[0]*math.cos(rotateAngle)-nextPoint[1]*math.sin(rotateAngle),                     nextPoint[0]*math.sin(rotateAngle)+nextPoint[1]*math.cos(rotateAngle)]        setpos(nextPoint)# fillcolor(244, 244, 244)''':cvar用绿色盘 不用白色'''fillcolor('green')begin_fill()ty(300, 100, 360, 300, 0)end_fill()penup()bk(40)pendown()color(229, 229, 229)''':cvar不要白色底盘'''# fillcolor(229, 229, 229)# begin_fill()ty(260, 60, 360, 300, 0)end_fill()pos_=pos()zongzi()penup()goto(pos_)seth(0)bk(200)right(90)fd(30)seth(0)pendown()zongzi()''':cvar画完图写文字'''hideturtle()penup()backward(230)setx(40)pendown()write("端    午    安      康 !", False, align="center", font=("Comic Sans", 30, "bold"))done()

在这里插入图片描述

参考别人代码修改了点,忘记是参考哪个作者的了,如果那位作者看到请联系我添加链接。

转载地址:https://chuanchuan.blog.csdn.net/article/details/117955181 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!

上一篇:前端网页让照片动起来(
下一篇:python制作一个机器人

发表评论

最新留言

做的很好,不错不错
[***.243.131.199]2024年04月24日 20时21分37秒