📜  Python – Wand 中的 path_curve_to_quadratic_bezier()函数

📅  最后修改于: 2022-05-13 01:55:42.250000             🧑  作者: Mango

Python – Wand 中的 path_curve_to_quadratic_bezier()函数

path_curve_to_quadratic_bezier()绘制从当前点到给定坐标的二次贝塞尔曲线。如果 smooth 为 True,则假定控制点是上一个命令上控制点的反射,否则必须给出一对控制坐标。

示例 #1:

Python3
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()
    # points list to determine curve
    points = [(40, 10), # Start point
              (20, 50), # First control
              (90, 10), # Second control
              (70, 40)] # End point
    # Start middle-left
    draw.path_move(to =(10, 100))
    # Curve across top-left to center
    draw.path_curve_to_quadratic_bezier(to =(100, 0),
                    control = points,
                    smooth = True,
                    relative = True)
    draw.path_finish()
    with Image(width = 200,
               height = 200,
               background = Color('lightgreen')) as image:
        draw(image)
        image.save(filename ="pathbcurve.png")


Python3
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=(100, 100))
    # Curve across top-left to center
    draw.path_curve_to_quadratic_bezier(to=(100, 0),
                                        control=[(20,50),(90,10)],
                                        smooth=True,relative=True)
     
    draw.path_finish()
    with Image(width=200, height=200, background=Color('lightgreen')) as image:
        draw(image)
        image.save(filename="pathbcurve.png")


输出 :

示例 #2:

Python3

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=(100, 100))
    # Curve across top-left to center
    draw.path_curve_to_quadratic_bezier(to=(100, 0),
                                        control=[(20,50),(90,10)],
                                        smooth=True,relative=True)
     
    draw.path_finish()
    with Image(width=200, height=200, background=Color('lightgreen')) as image:
        draw(image)
        image.save(filename="pathbcurve.png")

输出 :