- Python
中国国旗
- 2023-1-2 14:19:50 @
中国国旗我不行 报错,求救!!
6 条评论
-
毛奕辰 LV 6 @ 2023-4-23 19:05:41
丁泓森很对
-
2023-1-10 9:36:05@
from wonderLang import * def rect(x, y, w, h): jump(x, y) angle = 90 i = 0 while i < 2: forward(w) right(angle) forward(h) right(angle) i = i + 1 def center_rect(x, y, w, h): jump(x, y) x1 = x - w / 2 y1 = y + h / 2 rect(x1, y1, w, h) def cos(degree): import math radians = degree * math.pi / 180 return math.cos(radians) def sin(degree): import math radians = degree * math.pi / 180 return math.sin(radians) def star(x, y, length): jump(x, y) angle = 144 i = 0 while i < 5: forward(length) right(angle) i = i + 1 def center_star(x, y, r): jump(x, y) angle = 18 x1 = x - cos(angle) * r y1 = y + sin(angle) * r length = cos(angle) * r * 2 star(x1, y1, length) def china(x, y): jump(x, y) w = 300 h = 200 center_rect(x, y, w, h) center_star(x - 100, y + 50, 30) center_star(x - 50, y + 10, 10) center_star(x - 50, y + 80, 10) center_star(x - 30, y + 30, 10) center_star(x - 30, y + 60, 10) china(0,0)
画国旗需要用的那些函数放前面
最后用函数把它们全部引用
-
2023-1-8 20:35:21@
只能说一句,自己国家国旗都不会画。😕😕 😕
-
2023-1-2 19:56:42@
from wonderLang import * import math def china(x,y): jump(x,y) w=300 h=200 center_rect(x,y,w,h) center_star(x - 100, y + 50, 30) center_star(x - 50, y + 10, 10) center_star(x - 50, y + 80, 10) center_star(x - 30, y + 30, 10) center_star(x - 30, y + 60, 10) def center_rect(x, y, w, h): jump(x,y) x1=x-w/2 y1=y+h/2 rext(x1,y1,w,h) def center_star(x, y, r): jump(x,y) angle=18 x1 = x - cos(angle) * r y1 = y + sin(angle) * r length = cos(angle) * r * 2 star(x1,y1,length) def cos(degree): import math radians = degree * math.pi / 180 return math.cos(radians) def sin(degree): import math radians = degree * math.pi / 180 return math.sin(radians) def star(x,y,length): jump(x,y) angle = 144 i=0 while i<5: forward(length) right(angle) i=i+1 def rext(x,y,w,h): jump(x,y) angle = 90 i=0 while i<2: forward(w) right(angle) forward(h) right(angle) i=i+1 china(0,0)
-
2023-1-2 19:56:28@
我猜你的报错内容应该是NameError(我当初也是这样),放到空白文件运行就知道了
😕 1 -
2023-1-2 17:44:07@
from wonderLang import * import math def polygon(sides, length): # jump(x,y) i = 0 while i < sides: forward(length) right(180 - ((sides - 2) * 180 / sides)) i = i + 1 def circle(x, y, r): jump(x, y) sides = 36 length = (2 * math.pi * r) / sides left_angle = (90 + (360 / sides) / 2) right(-left_angle) forward(r) right(left_angle) polygon(sides, length) def rect(x1, y1, w, h): jump(x1, y1) angle=90 i = 0 while i < 2: forward(w) right(angle) forward(h) right(angle) i = i + 1 def center_rect(x, y, w, h): jump(x, y) x1 = x - w/2 y1 = y + h/2 rect(x1, y1 ,300, 200) def japan(x, y): w = 300 h = 200 center_rect(x, y, w, h) # circle(x, y, 60) # japan(0, 0) # center_rect(0, 0, 100, 50) def sin(degree): import math radians = degree * math.pi / 180 return math.sin(radians) def cos(degree): import math radians = degree * math.pi / 180 return math.cos(radians) def star(x, y, length): jump(x, y) angle = 144 i = 0 while i < 5: forward(length) right(angle) i = i + 1 def center_star(x, y, r): angle = 18 x1 = x - cos(angle) * r y1 = y + sin(angle) * r length = cos(angle) * r * 2 star(x1, y1, length) # center_star(100, 10, 200) # Todo 任务 六 # 实现一个函数画中国国旗 # 五角星不要求角度朝向(统一用正五角星),国旗宽高 300 * 200 # https://static.wonderland.run/cmw/china.jpg # x, y 是国旗中心点 # china(x, y) # 提示: # 1. 使用 rect 函数画一个矩形 # 2. 计算比例,画 5 个五角星(调用 5 次), 计算好坐标 def china(x, y): jump(x, y) w=300 h=200 center_rect(x, y, w, h) center_star(x-100, y+50, 30) center_star(x-50, y+10, 10) center_star(x-50, y+80, 10) center_star(x-30, y+30, 10) center_star(x-30, y+60, 10) china(0, 0)
怎么才做到这😕
🤣 1
- 1