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


Python Wand path_move()用法及代碼示例

path_move()是用於路徑的wand中引入的另一個函數。 path_move()函數的主要目的是為新的sub_path設置新的起點。通過設置相對標誌,可以給參數以相對或絕對值。

用法:
wand.drawing.path_move(to, relative)

參數:

參數 輸入類型 描述
to 序列或(數字。實數,數字。實數) 代表要繪製到的坐標的一對。
relative bool 將給定的坐標視為相對於當前點。

範例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') 
    draw.path_start() 
    # set starting point for first sub-path 
    draw.path_move(to =(10, 10)) 
    # Drawing vertical line from start 
    draw.path_vertical_line(100, 
                            relative = True) 
    # set starting point for second sub-path 
    draw.path_move(to =(190, 10)) 
    # Drawing vertical line from start 
    draw.path_vertical_line(100, 
                            relative = True) 
    draw.path_finish() 
    with Image(width = 200, height = 200, background = Color('lightgreen')) as image:
        draw(image) 
        image.save(filename ="pathmove.png")

輸出:

相關用法


注:本文由純淨天空篩選整理自RahulSabharwal大神的英文原創作品 Wand path_move() function in Python。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。