猫史档案馆


【Python作品分享】海龟绘图示例:绘制太阳花【教程贴】

用户:bigwubigwu查看:0 回复:2 评论:0 创建时间:2023-09-18T12:44:12


【作品展示】

center_image

 

【作品介绍】

海龟绘图示例:绘制太阳花

说明:color(colorstring1, colorstring2)相当于 pencolor(colorstring1) 加 fillcolor(colorstring2),即设置当前画笔颜色和填充颜色。

pos():返回当前位置的坐标(x.y);

abs(pos()):计算当前位置到原点的距离(如点(3,4)到原点的距离是5)。此外,画笔最开始在原点(0,0),如果abs(pos())<1即近似认为画笔回到了原点。

 

【作品源代码】

from turtle import *
color('red', 'yellow')
begin_fill()
while True:
    forward(200)
    left(170)
    if abs(pos()) < 1:
       break
end_fill()
done()

 

【提示】

部分含有Python第三方库相关内容的作品,在海龟编辑器网页端无法运行哦!如遇到这种情况,可以打开下面的链接,下载海龟编辑器客户端:

https://python.codemao.cn


回复

上一页1 页 / 共 1下一页
bigwubigwu

转换为积木模式后,需要手工修改几处代码,如下:center_image

点赞0


评论


不会做游戏只会玩游戏不会做游戏只会玩游戏

emotion_编程猫_紧张emotion_编程猫_嗨起来center_image

点赞0


评论