📜  Python中的魔杖折线()函数

📅  最后修改于: 2022-05-13 01:54:57.203000             🧑  作者: Mango

Python中的魔杖折线()函数

polyline()是 Wand 的 wand.drawing 模块中的另一个绘图函数。 polyline() 类似于 polygon()函数,唯一的区别是,它不会关闭笔划线 b/w 第一个和最后一个点。与 polygon() 类似,它也将点元组列表作为参数。

示例 #1

wand.drawing.polyline(points)

输出:

示例 #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')
  
    # points list for polygon
    points = [(25, 25), (175, 100), (25, 175)]
  
    # draw polygon using polygon() function
    draw.polyline(points)
    with Image(width = 200, height = 200, background = Color('lightgreen')) as image:
        draw(image)
        image.save(filename = "polygon.png")

输出: