comparison src/shape_path.c @ 460:115e7a936c94

Remove old sh_path_arc_path() code. - sh_path_arc_path() are replaced by the new code.
author Thinker K.F. Li <thinker@branda.to>
date Thu, 10 Sep 2009 22:24:02 +0800
parents 8b155b77fa14
children e95598916dfb
comparison
equal deleted inserted replaced
459:8b155b77fa14 460:115e7a936c94
370 370
371 *pnts_p = pnts; 371 *pnts_p = pnts;
372 *float_args_p = float_args; 372 *float_args_p = float_args;
373 } 373 }
374 374
375 #if 0
376 void __sh_path_arc_path(mbe_t *cr, const co_aix **args_p,
377 const int **fix_args_p) {
378 co_aix cx, cy, x0, y0, x, y;
379 co_aix dx, dy, dx0, dy0;
380 co_aix udxx, udxy;
381 co_aix xyratio;
382 co_aix rx;
383 co_aix rx2;
384 co_aix dra45x, dra45y, udra45x, udra45y;
385 co_aix rra45, rra45_2;
386 co_aix inner0, cross0;
387 co_aix inner, cross;
388 co_aix angle, angle0;
389 co_aix rotate;
390 co_aix _sqrt2;
391 const co_aix *args = *args_p;
392 const int *fix_args = *fix_args_p;
393 int sweep;
394
395 _sqrt2 = sqrtf(2);
396
397 x0 = *(args - 2);
398 y0 = *(args - 1);
399 cx = *args++;
400 cy = *args++;
401 ra45x = *args++;
402 ra45y = *args++;
403 x = *args++;
404 y = *args++;
405 sweep = *fix_args++;
406
407 dx = x - cx;
408 dy = y - cy;
409 dx0 = x0 - cx;
410 dy0 = y0 - cy;
411 dra45x = ra45x - cx;
412 dra45y = ra45y - cy;
413
414 rra45_2 = dra45x * dra45x + dra45y * dra45y;
415 rra45 = sqrtf(rra45_2);
416 udra45x = dra45x / rra45;
417 udra45y = dra45y / rra45;
418
419 udxx = (udra45x + udra45y) * _sqrt2;
420 udxy = (-udra45x + udra45y) * _sqrt2;
421
422 /*! \note Why we calculate these numbers there?
423 * If we compute it when filling arguments, _sh_path_arc_cmd_arg_fill(),
424 * we can avoid to recompute it for every drawing. But, transforming of
425 * coordinate can effect value of the numbers.
426 */
427 rotate = acos(udxx);
428 if(udxy < 0)
429 rotate = 2 * PI - rotate;
430
431 angle0 = angle_diff(udxx, udxy, dx0, dy0);
432 angle = angle_diff(udxx, udxy, dx, dy);
433
434 ASSERT(rx != 0);
435 xyratio = udra45y / udra45x;
436 if(xyratio < 0)
437 xyratio = -xyratio;
438
439 /* Make a path for arc */
440 mbe_save(cr);
441 mbe_translate(cr, cx, cy);
442 mbe_rotate(cr, rotate);
443 mbe_scale(cr, 1.0, xyratio);
444 if(sweep)
445 mbe_arc(cr, 0, 0, rx, angle0, angle);
446 else
447 mbe_arc_negative(cr, 0, 0, rx, angle0, angle);
448 mbe_restore(cr);
449
450 *args_p = args;
451 *fix_args_p = fix_args;
452 }
453 #endif
454
455 /* ============================================================ */ 375 /* ============================================================ */
456 376
457 static void sh_path_free(shape_t *shape) { 377 static void sh_path_free(shape_t *shape) {
458 sh_path_t *path = (sh_path_t *)shape; 378 sh_path_t *path = (sh_path_t *)shape;
459 if(path->user_data) 379 if(path->user_data)