Open In App

Python – path_curve_to_quadratic_bezier() function in Wand

Last Updated : 06 Jun, 2021
Improve
Improve
Like Article
Like
Save
Share
Report

The path_curve_to_quadratic_bezier() draws a quadratic Bezier curve from the current point to given to coordinate. The control point is assumed to be the reflection of the control point on the previous command if smooth is True, else a pair of control coordinates must be given.
 

Syntax : wand.drawing.path_curve_to_quadratic_bezier(to, controls, smooth, relative)

 

Parameter Input Type Description
to sequence or (numbers.Real, numbers.Real) pair which represents coordinates to drawn to.
control collections.abc.sequence or (numbers.Real, numbers.Real) coordinate to used to influence curve
smooth bool assume last defined control coordinate
relative bool treat given coordinates as relative to current point.

Example #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")


Output : 
 

Example #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")


Output : 
 

 



Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads