turtle庫(圖形繪制函數庫)絕對方向、海龜方向、setup(width,height,starx,stary)、goto(x,y)、fd(d)、bk(d)、circle(r,angle)、seth(angle)、up()、pd()、pencolor(color)、width()、done()


turtle庫是Python的標准庫之一

turtle的繪圖窗體

---turtle.setup(width,height,starx,stary) 

--------------------

turtle空間坐標體系

---turtle.goto(x,y)   絕對坐標

-------------------- 

海龜方向

 ---turtle.fd(d)  向前走 d 個單位

 ---turtle.bk(d) 向后走 d 個單位

 ---turtle.circle(r,angle) r為半徑,angle為角度

-------------------- 

絕對角度

turtle.seth(angle)  改變海龜前進方向

-------------------- 

 海龜方向

turtle.left(angle)

turtle.right(angle)

turtle的RGB色彩模式

turtle.colormode(mode)   

-1.0:   RGB小數值模式

-255:RGB整數值模式

庫引用

- import <庫名>

- from <庫名> import <函數名>  / from <庫名> import * 

- import <庫名> as <庫別名>

抬起畫筆 

- turtle.penup() /turtle.up() 

落下畫筆 

- turtle.pendown() /turtle.pd() 

畫筆寬度 

- turtle.pensize() /turtle.width() 

畫筆顏色

- turtle.pencolor(color)  

字符串:turtle.pencolor("purple") 

小數值:turtle.pencolor(0.63,0.13,0.94)

元組值:turtle.pencolor((0.63,0.13,0.94))

手動退出

turtle.done()


免責聲明!

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



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