| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| #include "cairo-test.h" |
| |
| #define LINE_WIDTH 10. |
| #define SIZE (5 * LINE_WIDTH) |
| #define PAD (2 * LINE_WIDTH) |
| |
| static void |
| make_path (cairo_t *cr) |
| { |
| cairo_move_to (cr, 0., 0.); |
| cairo_rel_line_to (cr, 0., SIZE); |
| cairo_rel_line_to (cr, SIZE, 0.); |
| cairo_close_path (cr); |
| |
| cairo_move_to (cr, 5 * LINE_WIDTH, 3 * LINE_WIDTH); |
| cairo_rel_line_to (cr, 0., -3 * LINE_WIDTH); |
| cairo_rel_line_to (cr, -3 * LINE_WIDTH, 0.); |
| } |
| |
| static void |
| draw_caps_joins (cairo_t *cr) |
| { |
| cairo_save (cr); |
| |
| cairo_translate (cr, PAD, PAD); |
| |
| make_path (cr); |
| cairo_set_line_cap (cr, CAIRO_LINE_CAP_BUTT); |
| cairo_set_line_join (cr, CAIRO_LINE_JOIN_BEVEL); |
| cairo_stroke (cr); |
| |
| cairo_translate (cr, SIZE + PAD, 0.); |
| |
| make_path (cr); |
| cairo_set_line_cap (cr, CAIRO_LINE_CAP_ROUND); |
| cairo_set_line_join (cr, CAIRO_LINE_JOIN_ROUND); |
| cairo_stroke (cr); |
| |
| cairo_translate (cr, SIZE + PAD, 0.); |
| |
| make_path (cr); |
| cairo_set_line_cap (cr, CAIRO_LINE_CAP_SQUARE); |
| cairo_set_line_join (cr, CAIRO_LINE_JOIN_MITER); |
| cairo_stroke (cr); |
| |
| cairo_restore (cr); |
| } |
| |
| static cairo_test_status_t |
| draw (cairo_t *cr, float line_width) |
| { |
| |
| cairo_save (cr); |
| cairo_set_source_rgb (cr, 1.0, 1.0, 1.0); |
| cairo_paint (cr); |
| cairo_restore (cr); |
| |
| cairo_set_line_width (cr, line_width); |
| |
| draw_caps_joins (cr); |
| |
| |
| cairo_translate (cr, 0, 2 * (PAD + SIZE) + PAD); |
| cairo_scale (cr, 1, -1); |
| |
| draw_caps_joins (cr); |
| |
| return CAIRO_TEST_SUCCESS; |
| } |
| |
| static cairo_test_status_t |
| draw_10 (cairo_t *cr, int width, int height) |
| { |
| return draw (cr, LINE_WIDTH); |
| } |
| |
| static cairo_test_status_t |
| draw_2 (cairo_t *cr, int width, int height) |
| { |
| return draw (cr, 2.0); |
| } |
| |
| static cairo_test_status_t |
| draw_1 (cairo_t *cr, int width, int height) |
| { |
| return draw (cr, 1.0); |
| } |
| |
| static cairo_test_status_t |
| draw_05 (cairo_t *cr, int width, int height) |
| { |
| return draw (cr, 0.5); |
| } |
| |
| CAIRO_TEST (caps_joins, |
| "Test caps and joins", |
| "stroke", |
| NULL, |
| 3 * (PAD + SIZE) + PAD, |
| 2 * (PAD + SIZE) + PAD, |
| NULL, draw_10) |
| |
| CAIRO_TEST (caps_joins_2, |
| "Test caps and joins with default line width", |
| "stroke", |
| NULL, |
| 3 * (PAD + SIZE) + PAD, |
| 2 * (PAD + SIZE) + PAD, |
| NULL, draw_2) |
| |
| CAIRO_TEST (caps_joins_1, |
| "Test caps and joins with hairlines", |
| "stroke", |
| NULL, |
| 3 * (PAD + SIZE) + PAD, |
| 2 * (PAD + SIZE) + PAD, |
| NULL, draw_1) |
| |
| CAIRO_TEST (caps_joins_05, |
| "Test caps and joins with fine lines", |
| "stroke", |
| NULL, |
| 3 * (PAD + SIZE) + PAD, |
| 2 * (PAD + SIZE) + PAD, |
| NULL, draw_05) |