summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuillaume Seguin <guillaume@segu.in>2007-12-06 23:05:32 +0100
committerGuillaume Seguin <guillaume@segu.in>2007-12-06 23:05:32 +0100
commitd5a3ad3fa9ea4254d20484ab7187bdcb02477f52 (patch)
treed4e044d2499d35961516fb2491c3f73bb1a66958
parent4b4e85a8e7cf5b685960166bd057aa1bf1c0c11c (diff)
downloadgmathlib-d5a3ad3fa9ea4254d20484ab7187bdcb02477f52.tar.gz
gmathlib-d5a3ad3fa9ea4254d20484ab7187bdcb02477f52.tar.bz2
* Add custom Cairo drawing function for integrals
-rw-r--r--cairo/gmathcairo_custom.c32
-rw-r--r--cairo/gmathcairo_custom.h3
2 files changed, 35 insertions, 0 deletions
diff --git a/cairo/gmathcairo_custom.c b/cairo/gmathcairo_custom.c
index b299ceb..c3c7f19 100644
--- a/cairo/gmathcairo_custom.c
+++ b/cairo/gmathcairo_custom.c
@@ -172,3 +172,35 @@ draw_intersect (int width, int height)
return surface;
}
+
+/* Draw an integral symbol */
+cairo_surface_t*
+draw_integral (int width, int height)
+{
+ cairo_surface_t *surface;
+ cairo_t *cr;
+ int x0, y0, x1, y1;
+
+ if (width <= 0 || height <= 0)
+ return NULL;
+
+ surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, width, height);
+ cr = cairo_create (surface);
+ cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
+
+ x0 = (float) width / 8.0;
+ y0 = (float) height / 12.0;
+
+ x1 = width - x0;
+ y1 = height - y0;
+
+ cairo_set_source_rgb (cr, 0, 0, 0);
+ cairo_move_to (cr, x1, y0);
+ cairo_curve_to (cr, x0, y0,
+ x1, y1,
+ x0, y1);
+ cairo_stroke (cr);
+
+ cairo_destroy (cr);
+ return surface;
+}
diff --git a/cairo/gmathcairo_custom.h b/cairo/gmathcairo_custom.h
index 84b6fd4..12c2c57 100644
--- a/cairo/gmathcairo_custom.h
+++ b/cairo/gmathcairo_custom.h
@@ -39,4 +39,7 @@ draw_union (int width, int height);
cairo_surface_t*
draw_intersect (int width, int height);
+cairo_surface_t*
+draw_integral (int width, int height);
+
#endif