绘制奥运五环主要涉及到Python中的turtle绘图库运用:
turtle.forward(distance)
向当前画笔方向移动distance像素长度
turtle.backward(distance)
向当前画笔相反方向移动distance像素长度
turtle.right(degree)
顺时针移动degree°
turtle.left(degree)
逆时针移动degree°
turtle.pendown()
移动时绘制图形,缺省时也为绘制
turtle.goto(x,y)
将画笔移动到坐标为x,y的位置
turtle.penup()
提起笔移动,不绘制图形,用于另起一个地方绘制
turtle.circle()
画圆,半径为正(负),表示圆心在画笔的左边(右边)画圆
setx( )
将当前x轴移动到指定位置
sety( )
将当前y轴移动到指定位置
setheading(angle)
设置当前朝向为angle角度
home()
设置当前画笔位置为原点,朝向东。
dot(r)
绘制一个指定直径和颜色的圆点
程序源代码为:
```
import turtle
turtle.width(10)
turtle.color('black')
turtle.circle(50)
turtle.penup()
turtle.goto(120,0)
turtle.pendown()
turtle.color('red')
turtle.circle(50)
turtle.penup()
turtle.goto(240,0)
turtle.pendown()
turtle.color('blue')
turtle.circle(50)
turtle.penup()
turtle.goto(60,-50)
turtle.pendown()
turtle.color('yellow')
turtle.circle(50)
turtle.penup()
turtle.goto(180,-50)
turtle.pendown()
turtle.color('pink')
turtle.circle(50)
#Python绘制奥运五环
```
运行后,结果为:
更多推荐
奥运五环的python制作代码大全_Python绘制奥运五环
发布评论