当前位置: 首页>>代码示例 >>用法及示例精选 >>正文


Python Wand polyline()用法及代码示例


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

用法:
wand.drawing.polyline(points)

参数:

参数 输入类型 描述
points list x,y元组的列表。

例子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') 
  
    # 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")

输出:



范例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, 150), (50, 50), (150, 50), (175, 150)] 
  
    # draw polygon using polygon() function 
    draw.polyline(points) 
    with Image(width = 200, height = 200, background = Color('lightgreen')) as image:
        draw(image) 
        image.save(filename = "polyline2.png")

输出:




相关用法


注:本文由纯净天空筛选整理自RahulSabharwal大神的英文原创作品 Wand polyline() function in Python。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。