Bezier: handle curve based on bezier path

Bezier: handle curve based on bezier path

A bezier path can be constructed like this

path = BezierPath()
# start the path
path.path_begin(x, y)
# add a point with x1/y1, x2/y2 as control point
path.path_curve_to(x1, y1, x2, y2, x, y)
# repeat this multiple time... until
# path.path_curve_to(...)
# close the path
path.path_close()
# and draw !
path.draw()

You can also provide a point list, and directly create a path

points = (startx, starty,
          controlx1, controly1, controlx2, controly2, pointx1, pointx2,
          # ... repeat
)

path = BezierPath(path=points)
path.draw()
class pymt.graphx.bezier.BezierPath(**kwargs)

Bases: object

Create a line based on bezier equation, or a shape using GLU tess.

Parameters :
filled : boolean, default to False

Create a filled bezier shape

path : list, default to None

Create a path directly from points. See up description for more information about the format used in path.

calculate_from_bezier_path(points)

Create a new path from a list of control points

draw()

Draw the path on screen (filled or line)

filled_path

Return the filled shape in format ((gl style, (x,y,x,y...)),...)

path

Return the calculated path in format (x,y,x,y...)

path_begin(x, y)

Start a new bezier path

path_curve_to(x1, y1, x2, y2, x, y)

Add a control point into bezier path

path_end()

End the current bezier path

reset()

Reset the display list cache

Previous topic

Graphx: package to simplify drawing in OpenGL

Next topic

Colors: manipulate colors

This Page