python之turtle

Python之turtle

四叶草


import turtle as t

#准备设置
t.screensize(400, 300) #设置画布大小
t.setup(840, 500) #设置主窗口的大小为840*500
t.pensize(5) #设置外花边的大小
t.color('mediumseagreen', 'forestgreen') #设置画笔颜色和填充颜色
t.speed(10) #设置画笔速度为10

def draw_clover(radius, rotate): #参数radius控制叶子的大小,rotate控制叶子的旋转
    t.begin_fill() #外形填充开始标志
    for i in range(4): #从0到3开始的for循环,共四片花瓣
        direction = i * 90
        t.seth(60 + direction + rotate)   #控制叶子根部的角度为60度
        t.fd(4 * radius) 
        for j in range(2):
            t.seth(90 + direction + rotate)
            t.circle(radius, 180)
        t.seth(-60 + direction + rotate)
        t.fd(4 * radius)
        t.seth(60 + direction+rotate)   #控制叶子根部的角度为60度
        t.fd(2 * radius)
        for j in range(2): #从0到1开始的for循环,画内花边
            t.pencolor("whitesmoke") #设置内花边颜色
            t.pensize(8) #设置内花边的大小
            t.seth(90 + direction + rotate)
            t.circle(radius/2, 180)
            t.color('mediumseagreen', 'forestgreen')
            t.pensize(5)
        t.seth(-60 + direction + rotate)
        t.fd(2 * radius)
    t.end_fill() #依据轮廓填充颜色
    t.seth(-110)
    t.fd(6 * radius)

draw_clover(40, 25) 
t.done() #保持窗口停留

绘制狮子

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值