elippse()函數用於在圖像上繪製橢圓。就像繪圖圓一樣,ellipse()函數需要兩對點,即原點和一對(x,y)橢圓半徑。要繪製局部橢圓,請提供一對開始和結束度作為第三個參數。
用法:
wand.drawing.ellipse(origin, radius, rotation)
參數:
參數 | 輸入類型 | 描述 |
---|---|---|
origin | (collections.abc.Sequence)-(numbers.Real,numbers.Real) | 對,代表橢圓的原點x和y。 |
radius | (collections.abc.Sequence)-(numbers.Real,numbers.Real) | 表示橢圓的半徑x和y的對 |
rotation | (collections.abc.Sequence)-(numbers.Real,numbers.Real) | 對,代表橢圓的開始和結束。默認值(0,360) |
範例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')
origin = (100, 100)
perimeter = (50, 100)
# draw circle using circle() function
draw.ellipse(origin, perimeter)
with Image(width = 200,
height = 200,
background = Color('green')) as img:
# draw shape on image using draw() function
draw.draw(img)
img.save(filename ='ellipse.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')
origin = (100, 100)
perimeter = (100, 50)
rotation = (0, 270)
# draw circle using circle() function
draw.ellipse(origin, perimeter, rotation)
with Image(width = 200,
height = 200,
background = Color('green')) as img:
# draw shape on image using draw() function
draw.draw(img)
img.save(filename ='ellipsepartial.png')
輸出:
相關用法
- Python Wand function()用法及代碼示例
- Python Wand gaussian_blur()用法及代碼示例
- Python Wand transform()用法及代碼示例
- Python Wand crop()用法及代碼示例
- Python Wand rotational_blur()用法及代碼示例
- Python Wand Image()用法及代碼示例
- Python Wand shade()用法及代碼示例
- Python Wand sharpen()用法及代碼示例
- Python Wand adaptive_sharpen()用法及代碼示例
- Python Wand noise()用法及代碼示例
- Python Wand blue_shift()用法及代碼示例
- Python Wand color_matrix()用法及代碼示例
- Python Wand unsharp_mask()用法及代碼示例
- Python Wand colorize()用法及代碼示例
- Python Wand fx()用法及代碼示例
注:本文由純淨天空篩選整理自RahulSabharwal大神的英文原創作品 Wand ellipse() function in Python。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。