Python中的魔杖弧()函数
arc()是 wand.drawing 模块中的一个函数。 arc()函数在图像中绘制弧线。您需要定义三对 (x, y) 坐标。第一和第二对坐标将是最小边界矩形,最后一对定义开始和结束度数。
Syntax :
Parameters :
Parameter Input Type Description start sequence or (numbers.Real, numbers.Real) pair which represents starting x and y of the arc. end sequence or (numbers.Real, numbers.Real) pair which represents ending x and y of the arc. degree sequence or (numbers.Real, numbers.Real) pair which represents starting degree, and ending degree
示例 #1:
Python3
wand.drawing.arc(start, end, degree)
Python3
# 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:
源图像:
Python3
# 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), # Starting 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')
输出: