亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

Python turtle庫的畫筆控制說明

 更新時(shí)間:2020年06月28日 09:09:22   作者:瘋子源  
這篇文章主要介紹了Python turtle庫的畫筆控制說明,具有很好的參考價(jià)值,希望對大家有所幫助。一起跟隨小編過來看看吧

turtle.penup() 別名 turtle.pu() :抬起畫筆海龜在飛行

turtle.pendown() 別名 turtle.pd():畫筆落下,海龜在爬行

turtle.pensize(width) 別名 turtle.width(width) :設(shè)置畫筆的寬度,海龜?shù)难鼑?/p>

turtle.pencolor(color) color為顏色字符串或r,g,b值 :

顏色字符串:turtle.pencolor("red")

RGB的小數(shù)值:turtle.pencolor(0.63,0.13,0.94)

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

運(yùn)動控制函數(shù):

turtle.forward(d) 別名: turtle.fd(d)

向前直行,海龜走直線 d:行進(jìn)距離可以為負(fù)數(shù)

turtle.circle(r,extent=None)

根據(jù)半徑 r 繪制 extent角度的弧形

r:默認(rèn)圓心在海龜左側(cè)r距離的位置

extent:繪制角度,默認(rèn)是360度整圓

turtle.seth(angle)

控制海龜?shù)牡姆较?

補(bǔ)充知識:Python turtle繪圖庫調(diào)用、基本命令簡介-----以蟒蛇繪制為例

下面的代碼為 python 蟒蛇繪制舉例,其中的注釋行對 turtle 繪圖庫的調(diào)用和其中的基本命令進(jìn)行了簡介

import turtle  
## 引入一個(gè)繪圖庫
    # 方法一
# import <庫名>
# 使用:庫名.函數(shù)名(函數(shù)參數(shù))
    # 方法二
# from <庫名> import <函數(shù)名>
# from <庫名> import *
# 使用:<函數(shù)名>(函數(shù)參數(shù))
# 可能會重復(fù)
    # 方法三
# import <庫名> as <庫別名>
# 使用:庫別名.函數(shù)名(函數(shù)參數(shù))
 
## 設(shè)置turtle畫布參數(shù)
turtle.setup(650,350,200,200) ##(寬,高,x,y)
## 讓海龜不畫圖飛到某一個(gè)位置
turtle.penup()
turtle.fd(-250)
turtle.pendown()
## 設(shè)置畫筆粗細(xì)和顏色
turtle.pensize(25) #turtle.width(25)
turtle.pencolor('purple')
### 轉(zhuǎn)型函數(shù)控制轉(zhuǎn)向,海龜只轉(zhuǎn)向,不行動 ###
## 絕對角度的轉(zhuǎn)向
turtle.seth(-40) # turtle.setheading(angle) 
## 海龜角度的轉(zhuǎn)向
# turtle.left(angle)
# turtle.right(angle)
for i in range(4):
  turtle.circle(40,80)
  turtle.circle(-40,80)
turtle.circle(40,80/2) #turtle.circle(r,entent = None) 根據(jù)半徑r繪制entent角度的弧形,圓心默認(rèn)在海龜左邊r的位置上
turtle.fd(40) #turtle.forward(40)
turtle.circle(16,180)
turtle.fd(40*2/3)
turtle.done() #結(jié)束畫圖,但不關(guān)閉窗口

以上這篇Python turtle庫的畫筆控制說明就是小編分享給大家的全部內(nèi)容了,希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。

相關(guān)文章

最新評論