From 222879ada2e127fd4e6ae0f3d4fc439a8c296cff Mon Sep 17 00:00:00 2001 From: Nicola Fontana Date: Tue, 3 Feb 2009 23:33:10 +0100 Subject: [PATCH] [demo] Added cpml_vector_at_curve() test case Every 0.1 time on the sample curves, a line normal to the curve is generated. This allows to test the cpml_vector_at_curve() API and the quality of the offset curve. --- demo/cpml-test.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/demo/cpml-test.c b/demo/cpml-test.c index 9293f39a..83ef463d 100644 --- a/demo/cpml-test.c +++ b/demo/cpml-test.c @@ -83,6 +83,7 @@ path_constructor(AdgEntity *entity, cairo_t *cr, gpointer user_data) cairo_path_t *path; CpmlSegment segment; CpmlPair pair; + CpmlVector vector; double t; n = GPOINTER_TO_INT(user_data); @@ -103,12 +104,18 @@ path_constructor(AdgEntity *entity, cairo_t *cr, gpointer user_data) cairo_append_path(cr, path); cairo_path_destroy(path); - /* Checking cpml_pair_at_curve */ + /* Checking cpml_pair_at_curve and cpml_vector_at_curve */ for (t = 0; t < 1; t += 0.1) { cpml_pair_at_curve(&pair, &bezier->p1, &bezier->p2, &bezier->p3, &bezier->p4, t); + cpml_vector_at_curve(&vector, &bezier->p1, &bezier->p2, + &bezier->p3, &bezier->p4, t, 20); + cpml_vector_normal(&vector); + cairo_new_sub_path(cr); - cairo_arc(cr, pair.x, pair.y, 5, 0, M_PI*2); + cairo_arc(cr, pair.x, pair.y, 2.5, 0, M_PI*2); + cairo_move_to(cr, pair.x, pair.y); + cairo_line_to(cr, pair.x + vector.x, pair.y + vector.y); } } -- 2.11.4.GIT