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


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


path_move()是包含在路径棒中的另一函数。此函数的主要目的是将路径中的最后一个目标点连接到第一个点。它只是在当前路径中添加一个路径元素,通过绘制一条从当前点到当前子路径的最新起点的直线来关闭当前子路径。

用法: draw.path_close()

参数:此函数中没有参数。

码:

# importing wand 
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, 100)) 
    # Curve accross top-left to center 
    draw.path_curve(to =(80, 0), 
                    controls =[(20, -80), (60, -80)], 
                    relative = True) 
    # Continue curve accross bottom-right 
    draw.path_curve(to =(80, 0), 
                    controls =(60, 80), 
                    smooth = True, 
                    relative = True) 
    # Join the last destination ppoint to the first point 
    draw.path_close() 
    draw.path_finish() 
    with Image(width = 200, height = 200, background = Color('lightgreen')) as image:
        draw(image) 
        image.save(filename = "pathclose.png")

输出:




相关用法


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