From 70c7d5de65c643fe6e8baf7cdd7ff7e073d4712a Mon Sep 17 00:00:00 2001 From: Bryce Harrington Date: Thu, 29 May 2014 18:31:36 -0700 Subject: shapes: Add lines and curves --- src/cairo-shapes.cpp | 36 +++++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) (limited to 'src/cairo-shapes.cpp') diff --git a/src/cairo-shapes.cpp b/src/cairo-shapes.cpp index 3cb8b4b..3a17193 100644 --- a/src/cairo-shapes.cpp +++ b/src/cairo-shapes.cpp @@ -71,7 +71,41 @@ cairoRandomizeColor(caskbench_context_t *ctx) cairo_set_source_rgba (ctx->cairo_cr, red, green, blue, alpha); } -void cairoDrawCircle(caskbench_context_t *ctx, shapes_t *args) +void +cairoDrawLine(caskbench_context_t *ctx, shapes_t *args) +{ + cairo_move_to (ctx->cairo_cr, args->x, args->y); + cairo_rel_line_to (ctx->cairo_cr, args->width, args->height); +} + +void +cairoDrawQuadraticCurve(caskbench_context_t *ctx, shapes_t *args) +{ + double qx1 = args->dx1 * 2.0 / 3.0; + double qy1 = args->dy1 * 2.0 / 3.0; + + double qx2 = args->width - args->dx1 * 2.0 / 3.0; + double qy2 = args->height - args->dy1 * 2.0 / 3.0; + + cairo_move_to (ctx->cairo_cr, args->x, args->y); + cairo_rel_curve_to (ctx->cairo_cr, + qx1, qy1, + qx2, qy2, + args->width, args->height); +} + +void +cairoDrawCubicCurve(caskbench_context_t *ctx, shapes_t *args) +{ + cairo_move_to (ctx->cairo_cr, args->x, args->y); + cairo_rel_curve_to (ctx->cairo_cr, + args->dx1, args->dy1, + args->dx2, args->dy2, + args->width, args->height); +} + +void +cairoDrawCircle(caskbench_context_t *ctx, shapes_t *args) { cairo_arc (ctx->cairo_cr, args->x + args->radius, -- cgit v1.3.1-4-g156e