當前位置: 首頁>>編程示例 >>用法及示例精選 >>正文


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。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。