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


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


棒中路径的另一个重要函数是python_finish()。当python_start()初始化路径并且终止路径也很重要时,path_finish()函数将处理当前路径的终止。

用法: 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")

输出图像:




相关用法


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