📜  Python中的魔杖多边形()函数

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

Python中的魔杖多边形()函数

polygon()函数是 wand.drawing 模块中引入的另一个绘图函数。我们可以使用 polygon()函数绘制复杂的形状。它以多边形中的点列表作为参数。笔划线将在第一个点和最后一个点之间自动闭合。

示例 #1

wand.drawing.polygon(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.polygon(points)
    with Image(width = 200, height = 200, background = Color('lightgreen')) as image:
        draw(image)
        image.save(filename = "polygon.png")

输出 :