语言:python
使用库:turtle
效果如下:
话不多说,进入正题↓
代码
from turtle import *
"""绘制五角星,大小可变"""
def wujiaoxing(size):
for i in range(6):
forward(size)
right(144)
"""绘制红色矩形"""
color("red","red")
begin_fill()
forward(192)
left(90)
forward(128)
left(90)
forward(192)
left(90)
forward(128)
end_fill()
"""绘制第一个大五角星"""
up()
goto(30,115)
down()
color("yellow","yellow")
begin_fill()
left(20)
wujiaoxing(30)
end_fill()
"""绘制第一个小五角星"""
up()
goto(55,110)
down()
color("yellow","yellow")
begin_fill()
right(10)
wujiaoxing(10)
end_fill()
"""绘制第二个小五角星"""
up()
goto(60,100)
down()
color("yellow","yellow")
begin_fill()
left(40)
wujiaoxing(10)
end_fill()
"""绘制第三个小五角星"""
up()
goto(70,87)
down()
color("yellow","yellow")
begin_fill()
right(30)
wujiaoxing(10)
end_fill()
"""绘制第四个小五角星"""
up()
goto(50,70)
down()
color("yellow","yellow")
begin_fill()
right(20)
wujiaoxing(10)
end_fill()
"""绘制文字"""
up()
goto(65,-50)
down()
color("black")
write("五星红旗",font=("微软雅黑",10))
hideturtle()
done()
运行截图
文章来源地址https://www.toymoban.com/news/detail-517480.html
文章来源:https://www.toymoban.com/news/detail-517480.html
到了这里,关于教你使用python绘制五星红旗的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!