diff options
author | Carl Worth <cworth@cworth.org> | 2008-01-21 14:56:21 -0800 |
---|---|---|
committer | Carl Worth <cworth@cworth.org> | 2008-01-21 14:56:21 -0800 |
commit | c480eedbb58dd03dd4b9b87b3985758ffbce7113 (patch) | |
tree | ea1cc9d304bd390f15fc855a23ee7022b971ca54 /test/get-path-extents.c | |
parent | 55e0dddf0408046ea0ded419ebe45099a4eb563e (diff) |
Test and document extents of degenerate "dots"
It's a common idiom to stroke degenerate sub-paths made with
cairo_move_to(x,y);cairo_rel_line_to(0,0) to draw dots. Test
that we get the desired extents from cairo_fill_extents,
cairo_stroke_extents, and cairo_path_extents for these cases.
Also document that the cairo_path_extents result is equivalent
to the limit of stroking with CAIRO_LINE_CAP_ROUND, (so that
these "dot" points are included), as the line width
approaches 0.0 .
Diffstat (limited to 'test/get-path-extents.c')
-rw-r--r-- | test/get-path-extents.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/test/get-path-extents.c b/test/get-path-extents.c index 0be57a70..5e82c1ea 100644 --- a/test/get-path-extents.c +++ b/test/get-path-extents.c @@ -166,6 +166,34 @@ draw (cairo_t *cr, int width, int height) cairo_new_path (cr2); cairo_restore (cr2); + /* Test that with CAIRO_LINE_CAP_ROUND, we get "dots" from + * cairo_move_to; cairo_rel_line_to(0,0) */ + cairo_save (cr2); + + cairo_set_line_cap (cr2, CAIRO_LINE_CAP_ROUND); + cairo_set_line_width (cr2, 20); + + cairo_move_to (cr2, 200, 400); + cairo_rel_line_to (cr2, 0, 0); + phase = "Single 'dot'"; + if (!check_extents (phase, cr2, FILL, EQUALS, 0, 0, 0, 0) || + !check_extents (phase, cr2, STROKE, EQUALS, 190, 390, 20, 20) || + !check_extents (phase, cr2, PATH, EQUALS, 200, 400, 0, 0)) + ret = CAIRO_TEST_FAILURE; + + /* Add another dot without starting a new path */ + cairo_move_to (cr2, 100, 500); + cairo_rel_line_to (cr2, 0, 0); + phase = "Multiple 'dots'"; + if (!check_extents (phase, cr2, FILL, EQUALS, 0, 0, 0, 0) || + !check_extents (phase, cr2, STROKE, EQUALS, 90, 390, 120, 120) || + !check_extents (phase, cr2, PATH, EQUALS, 100, 400, 100, 100)) + ret = CAIRO_TEST_FAILURE; + + cairo_new_path (cr2); + + cairo_restore (cr2); + /* http://bugs.freedesktop.org/show_bug.cgi?id=7965 */ phase = "A vertical, open path"; cairo_save (cr2); |