changeset 99:4aa1c9673363

Arc in path pass the test in example svg2code_ex.
author Thinker K.F. Li <thinker@branda.to>
date Tue, 09 Sep 2008 22:17:17 +0800
parents 688f76b8e71c
children 1a1dda98730c
files examples/svg2code_ex/svg2code_ex.svg src/shape_path.c
diffstat 2 files changed, 29 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/examples/svg2code_ex/svg2code_ex.svg	Tue Sep 09 18:11:37 2008 +0800
+++ b/examples/svg2code_ex/svg2code_ex.svg	Tue Sep 09 22:17:17 2008 +0800
@@ -2,7 +2,7 @@
 <!-- Created with Inkscape (http://www.inkscape.org/) -->
 <svg
    xmlns:dc="http://purl.org/dc/elements/1.1/"
-   xmlns:cc="http://web.resource.org/cc/"
+   xmlns:cc="http://creativecommons.org/ns#"
    xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
    xmlns:svg="http://www.w3.org/2000/svg"
    xmlns="http://www.w3.org/2000/svg"
@@ -13,13 +13,20 @@
    height="600"
    id="svg2"
    sodipodi:version="0.32"
-   inkscape:version="0.45.1"
+   inkscape:version="0.46"
    version="1.0"
    sodipodi:docbase="/usr/home/thinker/progm/MadButterfly/examples/svg2code_ex"
    sodipodi:docname="svg2code_ex.svg"
    inkscape:output_extension="org.inkscape.output.svg.inkscape">
   <defs
      id="defs4">
+    <inkscape:perspective
+       sodipodi:type="inkscape:persp3d"
+       inkscape:vp_x="0 : 300 : 1"
+       inkscape:vp_y="0 : 1000 : 0"
+       inkscape:vp_z="800 : 300 : 1"
+       inkscape:persp3d-origin="400 : 200 : 1"
+       id="perspective78" />
     <linearGradient
        inkscape:collect="always"
        id="linearGradient8083">
@@ -315,14 +322,14 @@
      inkscape:pageshadow="2"
      inkscape:zoom="0.63166667"
      inkscape:cx="400"
-     inkscape:cy="302.75296"
+     inkscape:cy="176.10388"
      inkscape:document-units="px"
      inkscape:current-layer="layer1"
      width="800px"
      height="600px"
      showgrid="true"
      inkscape:window-width="822"
-     inkscape:window-height="609"
+     inkscape:window-height="695"
      inkscape:window-x="130"
      inkscape:window-y="120" />
   <metadata
@@ -439,5 +446,17 @@
            x="52.16227"
            sodipodi:role="line">test</tspan></text>
     </g>
+    <path
+       sodipodi:type="arc"
+       style="opacity:1;fill:none;fill-opacity:1;stroke:#000000;stroke-width:2.39700006999999982;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
+       id="path2451"
+       sodipodi:cx="648.28497"
+       sodipodi:cy="541.4248"
+       sodipodi:rx="98.944588"
+       sodipodi:ry="47.493404"
+       d="M 747.22956,541.4248 A 98.944588,47.493404 0 0 1 549.36227,542.42361"
+       sodipodi:start="0"
+       sodipodi:end="3.1205606"
+       sodipodi:open="true" />
   </g>
 </svg>
--- a/src/shape_path.c	Tue Sep 09 18:11:37 2008 +0800
+++ b/src/shape_path.c	Tue Sep 09 22:17:17 2008 +0800
@@ -172,7 +172,7 @@
 	SKIP_NUM(p);
 	if(p == old)
 	    break;
-	TAKE_NUM(rx);
+	rx = atof(old);
 
 	TAKE_NUM(ry);
 	TAKE_NUM(x_rotate);
@@ -243,11 +243,11 @@
     sweep = *fix_args++;
 
     dx = x - cx;
-    dy = y = cy;
+    dy = y - cy;
     dx0 = x0 - cx;
     dy0 = y0 - cy;
     dxx = xx - cx;
-    dxy = xy = cy;
+    dxy = xy - cy;
 
     rx2 = dxx * dxx + dxy * dxy;
     rx = sqrtf(rx2);
@@ -264,15 +264,15 @@
     if(xyratio < 0)
 	xyratio = -xyratio;
 
-    angle0 = acos(inner / rx2);
+    angle0 = acos(inner0 / rx2);
     if(cross0 < 0)
-	angle0 += PI;		/* 3rd, 4th Quadrant */
+	angle0 = PI * 2 - angle0; /* 3rd, 4th Quadrant */
 
     inner = INNER(dx, dy, dxx, dxy);
     cross = CROSS(dx, dy, dxx, dxy);
     angle = acos(inner / rx2);
     if(cross < 0)
-	angle += PI;		/* 3rd, 4th Quadrant */
+	angle = PI * 2 - angle; /* 3rd, 4th Quadrant */
 
     /* Make a path for arc */
     rotate = acos(dxx / rx);