1 前言
最近了解到用 python 的 turtle 画图感到十分有趣,所以小编在网上学会了一些简单的绘画基础代码来完成经典的奥运五环图案。
2 实际操作
首先准备 python 环境(如果没有需要先行下载准备),环境准备好后,运用 python 中的内置模块 turtle 然后运行代码。
代码:
import turtle as t
t.pensize(10)
t.pencolor("black")
t.circle(100)
t.penup()
t.goto(150,0)
t.pendown()
t.pencolor("red")
t.circle(100)
t.left(180)
t.penup()
t.goto(-150,0)
t.left(180)
t.pendown()
t.pencolor("blue")
t.circle(100)
t.left(90)
t.penup()
t.goto(0,0)
t.pendown()
t.pencolor ("yellow")
t.circle(100)
t.right(180)
t.pencolor("green")
t.circle(100)
t.speed(0)
然后运行的到效果图:
3 总结
在编写图画过程中必须注意笔的方位,注意坐标,精确控制笔的落下点,注意格式对称的图像需要掌握方位。
END
编 辑 | 王文星
责 编 | 龙道正
扫码关注腾讯云开发者
领取腾讯云代金券
Copyright © 2013 - 2025 Tencent Cloud. All Rights Reserved. 腾讯云 版权所有
深圳市腾讯计算机系统有限公司 ICP备案/许可证号:粤B2-20090059 深公网安备号 44030502008569
腾讯云计算(北京)有限责任公司 京ICP证150476号 | 京ICP备11018762号 | 京公网安备号11010802020287
Copyright © 2013 - 2025 Tencent Cloud.
All Rights Reserved. 腾讯云 版权所有