Turtle Graphics绘图模块

2018-12-05  本文已影响0人  Kevin_Run

import turtle

'''

forward(d)  向前移动d长度

backward(d)  向后移动d长度

right(d)      向右转动多少度

left(d)      向左转动多少度

goto(x,y)    移动到坐标(x,y)的位置

speed(speed)  笔画绘制的速度,在[1,10]之间

up() 笔画抬起,移动的时候不会绘图

down()    笔画落下,移动会进行绘图

setheading(d) 改变海龟的宽度

pensize(d)    笔画的宽度

pencolor(colorstr)  笔画的颜色

reset()    恢复所有设置,清空窗口,重置turtle

clear()  清空窗口,不会重置turtle

circle(r,steps=d) 画一个圆,当steps设置时为画多边形

begin_fill()

fillcolor(colorstr) 填充颜色,结合begin_fill()和end_fill()一起使用

end_fill()

done() 程序继续执行

undo() 撤销上一次动作

hideturtle()  隐藏海龟

showturtle()  显示海龟

'''

turtle.forward(100)

#turtle.backward(200)

turtle.right(45)

turtle.forward(100)

turtle.up()

turtle.goto(-100,200)

turtle.down()

#turtle.pensize(10)

turtle.pencolor("red")

turtle.circle(50)

turtle.forward(30)

turtle.setheading(50)

turtle.goto(100,50)

turtle.begin_fill()

turtle.fillcolor("blue")

turtle.circle(50,steps=5)

turtle.end_fill()

turtle.done()

上一篇下一篇

猜你喜欢

热点阅读