views:

251

answers:

2

It appears to me that the DC's only support for curves of any sort is with splines. Are there any libraries that add bezier functionality, or is there a way to convert a bezier curve into a spline?

+2  A: 

Given 4 control points, the formula for the associated cubic Bezier curve is not hard to compute. Once you calculate a set of points on the curve, you could use DC.DrawLines to draw it.

There is a python implementation for calculating points on generalized Bezier curves (shameless plug) here. It's generalized in the sense that it can accept an arbitrary number of control points (>2) as input to make_bezier. If you want only the 4-control point version, you can cut out pascal_row entirely and replace

combinations=pascal_row(n-1)

with

combinations=(1,3,3,1)
unutbu
+1  A: 

After a little googling, I think I'll go with wx.GraphicsContext, which supports wx.GraphicsPath. It appears to have exactly what I need, in addition to anti-aliasing (according to this page)

Bibendum
Good idea. It's the new way to draw in wxpython.
DrBloodmoney