Mercurial > MadButterfly
diff src/shape_path.c @ 269:c96f38ad4bb6
Fix mis-behavior of translate_path_data() on arc.
- Arc in a path in svg2code_ex is not showed.
- translate_path_data() in svg2code.py was modified for calling
binary version new method for path shape.
- rdman_shape_path_new_from_binary()
- Code to translate path data does not handle arc in a right way.
- Copy calc_center_and_x_aix() from shape_path.c to svg2code.py and
change name _calc_ellipse_of_arc()
- _calc_ellipse_of_arc() handle arc data for translate_path_data()
author | Thinker K.F. Li <thinker@branda.to> |
---|---|
date | Sun, 25 Jan 2009 00:20:34 +0800 |
parents | 65cabbdd5284 |
children | cd6af7da32c9 |
line wrap: on
line diff
--- a/src/shape_path.c Sat Jan 24 18:19:02 2009 +0800 +++ b/src/shape_path.c Sun Jan 25 00:20:34 2009 +0800 @@ -53,11 +53,16 @@ #include <math.h> /*! \brief Calculate center of the ellipse of an arc. * + * Origin of our coordination is left-top corner, and y-axis are grown + * to down-side. + * + * Space of the arc is transformed to space that correspondent + * ellipse containing the arc is mapped into an unit circle. * - ux0 = x0 / rx * - uy0 = y0 / ry * - ux = x / rx - * - uy = y / rx - * ux0, uy0, ux, yu are got by transforming (x0, y0) and (x, y) into points + * - uy = y / ry + * ux0, uy0, ux, uy are got by transforming (x0, y0) and (x, y) into points * on the unit circle. The center of unit circle are (ucx, ucy): * - umx = (ux0 + ux) / 2 * - umy = (uy0 + uy) / 2 @@ -68,7 +73,9 @@ * * - udx * udcx + udy * udcy = 0 * - * - udl2 = udx ** 2 + udy ** 2; + * - udl2 = udx ** 2 + udy ** 2 + * + * For drawing small arc in clockwise * - udx * udcy - udy * udcx = sqrt((1 - udl2) * udl2) * * - udcy = -udcx * udx / udy @@ -118,9 +125,11 @@ udl2 = udx2 + udy2; if(udy != 0) { + /* center is at left-side of arc */ udcx = -sqrtf((1 - udl2) * udl2) / (udy + udx2 / udy); udcy = -udcx * udx / udy; } else { + /* center is at down-side of arc */ udcx = 0; udcy = sqrtf((1 - udl2) * udl2) / udx; }