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


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


我們也可以在wand.drawing模塊。每個路徑方法都期望有一個目標點,並且將從當前點繪製到新點。目的點將成為下一個應用路徑方法的新當前點。筆杆中的路徑包含一些其他方法來在路徑中繪製不同的圖形。
在本文中,我們將學習path_start()函數。使用path_start函數啟動路徑。

用法: wand.drawing.path_start()

範例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 =(100, 100)) 
    draw.path_horizontal_line(1) 
      
    # Close first & last points 
    draw.path_close() 
    draw.path_finish() 
    with Image(width = 200,  
               height = 200, 
               background = Color('green')) as image:
          
        draw(image) 
        image.save(filename = "pathstart.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.path_start() 
      
    # Start middle-left 
    draw.path_move(to=(100, 100)) 
      
    # draw a vertical line from path initial point 
    draw.path_vertical_line(1) 
      
    # Close first & last points 
    draw.path_close() 
    draw.path_finish() 
    with Image(width=200, 
               height=200, 
               background=Color('green')) as image:
        draw(image) 
        image.save(filename = "pathstart.png")

輸出:




相關用法


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