python中的Turtle模塊


一:筆繪制圖形狀態的方法

turtle.pendown()  移動的時候繪制

turtle.penup()      移動的時候不繪制

turtle.pensize()    將線的粗細設定為指定寬度

二:Turtle運動的方向

turtle.forward(d)    移動方向前移指定距離

turtle.backward(d) 移動方向反向移動指定距離

turtle.left(angle)     左轉指定角度

turtle.right(angle)   右轉指定角度

turrle.goto(x,y)       移動到一個絕對位置

turtle.setx(x)          將x坐標移動到指定位置

turtle.sety(y)           將y坐標移動到指定位置

turtle.setheading(angle)    將移動方向設置指定角度(0-東,90-北,180-西,270-南)

turtle.home()                    移動到起點(0,0)向東

turtle.circle(r,ext,step)       指定半徑,范圍和階數的圓

turtle.dot(diameter,color)    繪制一個指定直徑和顏色的圓

turtle.undo()                      取消最后一個操作

turtle.speed(s)                   設置turtle的移動速度


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM