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


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。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。