五星红旗(附厕纸)

五星红旗是国旗,小时候幼儿园画不标准,现在长大用程序画画

老规矩,先上模块

from turtle import*

还是老规矩,turtle的设置

speed(0)#速度
ht()#隐藏画笔
hq=Screen()#设置窗口"a"
hq.setup(300,200)#设置窗口大小

由于五颗五角星分散开goto不仅麻烦还麻烦,我反手封装进函数里、

def pg(x,y):
    pu()
    goto(x,y)
    pd()

接着把旗布居中画,这样就能分成四个部分,中心是0,0

pg(-150,-100)
pencolor('red')
fillcolor('red')
begin_fill()
for i in range(2):
    fd(300)
    left(90)
    fd(200)
    left(90)
end_fill()

按照我看到的视频来讲,小星星应该都在左上角

然后按照分布,我反手封装函数:

len1=(5**2+10**2)**0.5
pencolor('yellow')
def x(x1,x2,x3):
    seth(180)
    pg(x1,x2)
    fillcolor('yellow')
    begin_fill()
    for i in range(5):
        fd(x3)
        left(-72)
        fd(x3)
        left(144)
    end_fill()
x(-50,25,len1)
x(-25,40,5)
x(-15,30,5)
x(-15,15,5)
x(-25,5,5)

完整代码:

from turtle import*
speed(0);ht();a=Screen();a.setup(300,200)
def pg(x,y):pu();goto(x,y);pd()
pg(-150,-100);pencolor('red');fillcolor('red');begin_fill()
for i in range(2):fd(300);left(90);fd(200);left(90)
end_fill()
len1=(5**2+10**2)**0.5
pencolor('yellow')
def x(x1,x2,x3):
    seth(180);pg(x1,x2);fillcolor('yellow');begin_fill()
    for i in range(5):fd(x3);left(-72);fd(x3);left(144)
    end_fill()
x(-50,25,len1)
x(-25,40,5)
x(-15,30,5)
x(-15,15,5)
x(-25,5,5)

厕纸部分:

from turtle import*;speed(0);ht();a=Screen();a.setup(300,200);pencolor('red');pu();goto(0,-50);pd();fillcolor('red');begin_fill();circle(50);end_fill()

因为厕纸,所以我不给好脸色,有一行了,让它偷着乐去吧

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值