利用turtle库画国旗

from turtle import * #导入turtle库
height=160*3 #设置高
width=240*3 #设置长
a=pen()
penup()
goto(-400,400) #我测试了一下,-400,400作为国旗的左上角比较合适
pendown() #下笔
def star(angle,long):
    pendown()
    setheading(0)
    right(angle)
    fillcolor('yellow')
    begin_fill()
    for i in range(5):
        forward(long)
        right(144)
    end_fill()
 
begin_fill()
fillcolor('red')
 
for j in range(2):
    forward(width)
    right(90)
    forward(height)
    right(90)
 
end_fill()
 
penup()
goto(-400+width/30*2,400-height/20*4)
star(0,width/30*6)
 
penup()
goto(-400+width/30*9,400-height/20*2)
star(-45,width/30*2)
 
penup()
goto(-400+width/30*11,400-height/20*4)
star(-10,width/30*2)
 
penup()
goto(-400+width/30*11,400-height/20*7)
star(0,width/30*2)
 
penup()
goto(-400+width/30*9,400-height/20*10)
star(-45,width/30*2)
 
 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值