Python中的 Wand path_horizontal_line()函数
path_horizontal_line()是路径的另一个函数。 path_horizontal_line()函数生成从目标点到特定 x 点的水平线。它仅将参数中的 x 作为绘制线的点。
Syntax: wand.drawing.path_horizontal_line(to, relative)
Parameters:
Parameter | Input Type | Description |
---|---|---|
x | Real | x-axis point to draw to. |
relative | bool | treat given coordinates as relative to current point. |
示例 #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.fill_color = Color('white')
draw.path_start()
# Start middle-left
draw.path_move(to=(10, 50))
# horizontal line to x=100
draw.path_horizontal_line(100)
draw.path_finish()
with Image(width=200,
height=200,
background=Color('lightgreen')) as image:
draw(image)
image.save(filename="pathhline.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=(100, 50))
# horizontal line to x=50
draw.path_horizontal_line(50)
draw.path_finish()
with Image(width=200,
height=200,
background=Color('lightgreen')) as image:
draw(image)
image.save(filename="pathhline.png")
输出: