加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > Python > 正文

画一个月饼

发布时间:2020-12-20 10:41:38 所属栏目:Python 来源:网络整理
导读:python画月饼,是动画效果的哦!!话不多说上效果图和代码 import turtledef goto(x,y): turtle.penup(); turtle.goto(x,y); turtle.pendown();def yuan(): turtle.color(‘#D1C185‘,‘#839F26‘) goto(0,-200); turtle.begin_fill(); turtle.circle(200);

  python画月饼,是动画效果的哦!!话不多说上效果图和代码

import turtle

def goto(x,y):
    turtle.penup();
    turtle.goto(x,y);
    turtle.pendown();

def yuan():
    turtle.color(‘#D1C185‘,‘#839F26‘)
    goto(0,-200);
    turtle.begin_fill();
    turtle.circle(200);
    turtle.end_fill();

def huabian():
    goto(0,0)
    turtle.color(‘#839F26‘)
    for _ in range(20):
        turtle.right(18)
        turtle.begin_fill()
        turtle.forward(220)
        turtle.circle(40,180)
        turtle.goto(0,0)
        turtle.right(180)
        turtle.end_fill()

def neitu():
    turtle.color(‘#D1C185‘)
    goto(0,-25)
    for _ in range(12):
        turtle.begin_fill();
        turtle.circle(150,60)
        turtle.left(90)
        turtle.circle(150,60)
        turtle.end_fill()

def write():
    goto(-40,10)
    turtle.color("red")
    turtle.write("中秋快乐",font={"Time",18,"bold"})
    turtle.done()

if __name__ == ‘__main__‘:
    turtle.speed(10)
    huabian()
    yuan()
    neitu()
    write()

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读