Python中的魔杖path_finish()函数
wand 中路径的另一个重要函数是python_finish() 。由于 python_start() 启动路径并且终止路径也非常重要,因此path_finish()函数处理当前路径的终止。
Syntax: wand.drawing.path_finish()
示例 1:
from wand.image import Image
from wand.drawing import Drawing
from wand.color import Color
with Drawing() as draw:
draw.stroke_width = 2
draw.stroke_color = Color('black')
draw.path_start()
# Start middle-left
draw.path_move(to=(10, 10))
draw.path_horizontal_line(100)
# finishes the current path
draw.path_finish()
with Image(width=200,
height=200,
background=Color('lightgreen')) as image:
draw(image)
image.save(filename = "pathfinish.png")
输出图像:
示例 2:
from wand.image import Image
from wand.drawing import Drawing
from wand.color import Color
with Drawing() as draw:
draw.stroke_width = 2
draw.stroke_color = Color('black')
draw.fill_color = Color('white')
draw.path_start()
# Start middle-left
draw.path_move(to=(10, 10))
draw.path_vertical_line(50)
draw.path_horizontal_line(50)
draw.path_vertical_line(100)
draw.path_horizontal_line(100)
# finishes the current path
draw.path_finish()
with Image(width=200,
height=200,
background=Color('lightgreen')) as image:
draw(image)
image.save(filename = "pathfinish.png")
输出图像: