comparison src/shape_path.c @ 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
comparison
equal deleted inserted replaced
98:688f76b8e71c 99:4aa1c9673363
170 SKIP_SPACE(p); 170 SKIP_SPACE(p);
171 old = p; 171 old = p;
172 SKIP_NUM(p); 172 SKIP_NUM(p);
173 if(p == old) 173 if(p == old)
174 break; 174 break;
175 TAKE_NUM(rx); 175 rx = atof(old);
176 176
177 TAKE_NUM(ry); 177 TAKE_NUM(ry);
178 TAKE_NUM(x_rotate); 178 TAKE_NUM(x_rotate);
179 TAKE_NUM(large); 179 TAKE_NUM(large);
180 TAKE_NUM(sweep); 180 TAKE_NUM(sweep);
241 x = *args++; 241 x = *args++;
242 y = *args++; 242 y = *args++;
243 sweep = *fix_args++; 243 sweep = *fix_args++;
244 244
245 dx = x - cx; 245 dx = x - cx;
246 dy = y = cy; 246 dy = y - cy;
247 dx0 = x0 - cx; 247 dx0 = x0 - cx;
248 dy0 = y0 - cy; 248 dy0 = y0 - cy;
249 dxx = xx - cx; 249 dxx = xx - cx;
250 dxy = xy = cy; 250 dxy = xy - cy;
251 251
252 rx2 = dxx * dxx + dxy * dxy; 252 rx2 = dxx * dxx + dxy * dxy;
253 rx = sqrtf(rx2); 253 rx = sqrtf(rx2);
254 254
255 /*! \note Why we calculate these numbers there? 255 /*! \note Why we calculate these numbers there?
262 circle_h0 = sqrtf(rx2 - inner0 * inner0 / rx2); 262 circle_h0 = sqrtf(rx2 - inner0 * inner0 / rx2);
263 xyratio = cross0 / rx / circle_h0; 263 xyratio = cross0 / rx / circle_h0;
264 if(xyratio < 0) 264 if(xyratio < 0)
265 xyratio = -xyratio; 265 xyratio = -xyratio;
266 266
267 angle0 = acos(inner / rx2); 267 angle0 = acos(inner0 / rx2);
268 if(cross0 < 0) 268 if(cross0 < 0)
269 angle0 += PI; /* 3rd, 4th Quadrant */ 269 angle0 = PI * 2 - angle0; /* 3rd, 4th Quadrant */
270 270
271 inner = INNER(dx, dy, dxx, dxy); 271 inner = INNER(dx, dy, dxx, dxy);
272 cross = CROSS(dx, dy, dxx, dxy); 272 cross = CROSS(dx, dy, dxx, dxy);
273 angle = acos(inner / rx2); 273 angle = acos(inner / rx2);
274 if(cross < 0) 274 if(cross < 0)
275 angle += PI; /* 3rd, 4th Quadrant */ 275 angle = PI * 2 - angle; /* 3rd, 4th Quadrant */
276 276
277 /* Make a path for arc */ 277 /* Make a path for arc */
278 rotate = acos(dxx / rx); 278 rotate = acos(dxx / rx);
279 cairo_save(cr); 279 cairo_save(cr);
280 cairo_translate(cr, cx, cy); 280 cairo_translate(cr, cx, cy);