当前位置:网站首页>Complete list of common functions of turtle module

Complete list of common functions of turtle module

2022-07-06 04:26:00 Michael. py

For the convenience of study , This article will turtle Summary of common functions and methods in the Library :

command explain

turtle.forward(distance) or

turtle.fd(distance)

Move towards the current brush distance Pixel length

turtle.backward(distance) or

turtle.bw(distance)

Move in the opposite direction of the current brush distance Pixel length
turtle.right(degree) Move clockwise degree angle
turtle.left(degree) Move counterclockwise degree angle
turtle.penup() Lift the pen and move , No graphics , For another place to draw
turtle.pendown() The paintbrush falls , Draw a picture when moving , By default, it is also drawing graphics
turtle.goto(x, y) Move the brush to the coordinates (x, y)  The location of
turtle.circle() A circle
setx() Will the current x The axis moves to the specified position
sety() Will the current y The axis moves to the specified position

setheading(angle) or

seth(angle)

Set the current orientation to angle  angle
home() Set the current brush position to the origin , Towards the East
dot() Draw a dot of a specified diameter and color
turtle.fillcolor(colorstring) The fill color of the drawing
turtle.color(color1, color2) Simultaneous setting pencolor = colorl,fillcolor=color2
turtle.filling() Returns whether or not the current filling state
turtle.begin_fill() Ready to start filling in figures
turtle.end_fill() Filling complete
turtle.hideturtle() Hide the brush  turrle shape
turtle.showturtle() Showing the brush turtle shape

turtle.mainloop() or

turtle.done()

Start event cycle one call Tkinter Of mainloop function , It must be the last statement in the turtle graphics program
turtle.mode(mode=None) Set tortoise mode (“standard” “logo” or “world”) And perform a reset , If no mode is given , Then return to the current mode
turtle.delay(delay=None) Sets or returns the plot delay in milliseconds
turtle.begin_poly() Start recording the vertices of the polygon , The current tortoise position is the first vertex of the polygon
turtle.end_poly() Stop recording polygon vertices , The current tortoise position is the last vertex of the polygon , Will be connected to the first vertex

原网站

版权声明
本文为[Michael. py]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202132227317914.html