vg: missing quadratic and cubic path elements
Created by: ktye
Is there a way to use quadratic and cubic bezier elements in vg? From looking at the source, it seems that vg.Path does not provide these primitives. As they are elementary to 2d vector graphics, I think they should be present.
I propose to add the constant:
const (
MoveComp = iota
LineComp
ArcComp
CurveComp // This is new
CloseComp
)
And the methods
// QuadTo adds a quadratic curve element to the path defined by the control point p1 and the endpoint pt.
func (p *Path) QuadTo(p1, pt Point){...}
// CubeTo adds a cubic curve element to the path defined by the control points p1 and p2 and the endpoint pt.
func (p *Path) CubeTo(p1, p2, pt Point){...}
All backends should be able to handle the primitives:
- eps: curveto which is like CubeTo. QuadTo can be implemented by setting p1=p2
- https://www.math.ubc.ca/~cass/graphics/manual/pdf/ch6.pdf (page 2, sec 6.2)
- img: draw2d has QuadCurveTo and CubicCurveTo
- pdf: gopdf has CurveTo and CurveBezierCubicTo
- svg: svgo has Qbez and Bezier
- tex: pgf has control points, which I hope are compatible
Did I miss anything?
What do you think?