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


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


path_curve()是专门为路径引入的函数。 path_curve()在控制点的帮助下从图像的目标点到特定点(x,y)绘制三次贝塞尔曲线。

用法:
wand.drawing.path_curve(to, controls, smooth, relative)

参数:

参数 输入类型 描述
to 序列或(数字。实数,数字。实数) 代表要绘制到的坐标的一对。
controls collections.abc.sequence或(numbers.Real,numbers.Real) 用于影响曲线的坐标
smooth bool 假设最后定义的控制坐标
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() 
    # 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) 
    draw.path_finish() 
    with Image(width = 200, height = 200, background = Color('lightgreen')) as image:
        draw(image) 
        image.save(filename ="pathcurve.png")

输出:




相关用法


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