當前位置: 首頁>>代碼示例 >>用法及示例精選 >>正文


Python Wand arc()用法及代碼示例


arc()是wand.drawing模塊中存在的函數。 arc()函數在圖像中繪製圓弧。您需要定義三對(x,y)坐標。第一對和第二對坐標將是最小邊界矩形,最後一對將定義開始和結束度。

用法:
wand.drawing.arc(start, end, degree)

參數:

參數 輸入類型 描述
start 序列或(數字。實數,數字。實數) 表示弧的x和y的起點。
end 序列或(數字。實數,數字。實數) 表示圓弧的x和y的終點。
degree 序列或(數字。實數,數字。實數) 代表開始程度和結束程度的對

範例1:

# Import required objects from wand modules 
from wand.image import Image 
from wand.drawing import Drawing 
from wand.color import Color 
  
# generate object for wand.drawing 
with Drawing() as draw:
    # set stroke color 
    draw.stroke_color = Color('black') 
    # set width for stroke 
    draw.stroke_width = 1
    # fill white color in arc 
    draw.fill_color = Color('white') 
    draw.arc(( 50, 50),  # Stating point 
             ( 150, 150),  # Ending point 
             (135, -45))  # From bottom left around to top right 
    with Image(width = 100, 
               height = 100, 
               background = Color('green')) as img:
        # draw shape on image using draw() function 
        draw.draw(img) 
        img.save(filename ='arc.png')

輸出:



範例2:

源圖像:

# Import required objects from wand modules 
from wand.image import Image 
from wand.drawing import Drawing 
from wand.color import Color 
  
# generate object for wand.drawing 
with Drawing() as draw:' 
    # set stroke color 
    draw.stroke_color = Color('black') 
    # set width for stroke 
    draw.stroke_width = 1
    # fill white color in arc 
    draw.fill_color = Color('white') 
    draw.arc(( 50, 50),  # Stating point 
             ( 150, 150),  # Ending point 
             (135, -45))  # From bottom left around to top right 
    with Image(filename ="gog.png") as img:
        # draw shape on image using draw() function 
        draw.draw(img) 
        img.save(filename ='arc.png')

輸出:




相關用法


注:本文由純淨天空篩選整理自RahulSabharwal大神的英文原創作品 Wand arc() function in Python。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。