Extra math for implementing SVG on top of Kiva.
angle(x1, y1, x2, y2)¶
The angle in degrees between two vectors.
bezier_arc(x1, y1, x2, y2, start_angle=0, extent=90)¶
Compute a cubic Bezier approximation of an elliptical arc.
(x1, y1) and (x2, y2) are the corners of the enclosing rectangle. The coordinate system has coordinates that increase to the right and down. Angles, measured in degress, start with 0 to the right (the positive X axis) and increase counter-clockwise. The arc extends from start_angle to start_angle+extent. I.e. start_angle=0 and extent=180 yields an openside-down semi-circle.
The resulting coordinates are of the form (x1,y1, x2,y2, x3,y3, x4,y4) such that the curve goes from (x1, y1) to (x4, y4) with (x2, y2) and (x3, y3) as their respective Bezier control points.
elliptical_arc_to(path, rx, ry, phi, large_arc_flag, sweep_flag, x1, y1, x2, y2)¶
Add an elliptical arc to the kiva CompiledPath by approximating it with Bezier curves or a line segment.
- Algorithm taken from the SVG 1.1 Implementation Notes:
transform_from_local(xp, yp, cphi, sphi, mx, my)¶
Transform from the local frame to absolute space.