为这段程序加上加上旗杆,旗杆长度是五星红旗宽度的4倍。并在旗杆最下方绘制一个旗杆固定底座(什么图形都可以,底座颜色为灰色。主要是为旗杆起固 定作用)。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()
时间: 2023-09-25 16:09:13 浏览: 179
这里是为程序加上旗杆和底座的代码:
```
from turtle import *
def wujiaoxing(size):
for i in range(6):
forward(size)
right(144)
# 绘制旗杆
def qigan(size):
color("black")
# 绘制旗杆固定底座
up()
goto(-10,-200)
down()
begin_fill()
color("gray")
for i in range(2):
forward(20)
left(90)
forward(40)
left(90)
end_fill()
up()
goto(-5,-200)
down()
# 绘制旗杆本体
for i in range(2):
forward(size)
left(90)
forward(20)
left(90)
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))
# 调用旗杆函数
qigan(40)
hideturtle()
done()
```
旗杆的长度是原本的40,即五星红旗宽度的4倍。旗杆固定底座是一个灰色矩形,宽20,高40。代码中的注释可以更好地理解绘图过程。
阅读全文