diff include/mb_graph_engine.h @ 458:bb4f651090bf

Use cairo to transform and draw arc. - We move some values into float_args. - fix_args is removed. - args is rename to pnts. - We still need to add corner points to pnts at sh_path_arc_cmd_arg_fill().
author Thinker K.F. Li <thinker@branda.to>
date Thu, 10 Sep 2009 17:36:45 +0800
parents 5c9e2a8a4bd8
children aa2b388fba4e
line wrap: on
line diff
--- a/include/mb_graph_engine.h	Thu Aug 06 15:38:08 2009 +0800
+++ b/include/mb_graph_engine.h	Thu Sep 10 17:36:45 2009 +0800
@@ -47,7 +47,6 @@
 #define mbe_fill_preserve cairo_fill_preserve
 #define mbe_set_operator cairo_set_operator
 #define mbe_get_operator cairo_get_operator
-#define mbe_arc_negative cairo_arc_negative
 #define mbe_set_source cairo_set_source
 #define mbe_reset_clip cairo_reset_clip
 #define mbe_get_target cairo_get_target
@@ -72,7 +71,6 @@
 #define mbe_save cairo_save
 #define mbe_fill cairo_fill
 #define mbe_clip cairo_clip
-#define mbe_arc cairo_arc
 
 typedef cairo_text_extents_t mbe_text_extents_t;
 typedef cairo_font_options_t mbe_font_options_t;
@@ -84,6 +82,7 @@
 typedef cairo_status_t mbe_status_t;
 typedef cairo_matrix_t mbe_matrix_t;
 typedef cairo_t mbe_t;
+typedef float co_aix;
 
 static mbe_surface_t *
 mbe_image_surface_create_for_data(unsigned char *data,
@@ -163,6 +162,29 @@
     return cairo_image_surface_create(_fmt, width, height);
 }
 
+static void
+mbe_transform(mbe_t *mbe, const co_aix matrix[6]) {
+    cairo_matrix_t cmtx;
+
+    cmtx.xx = matrix[0];
+    cmtx.xy = matrix[1];
+    cmtx.x0 = matrix[2];
+    cmtx.yx = matrix[3];
+    cmtx.yy = matrix[4];
+    cmtx.y0 = matrix[5];
+
+    cairo_transform(mbe, &cmtx);
+}
+
+static void
+mbe_arc(mbe_t *mbe, co_aix x, co_aix y, co_aix radius,
+	co_aix angle_start, co_aix angle_stop) {
+    if(angle_start <= angle_stop)
+	cairo_arc(mbe, x, y, radius, angle_start, angle_stop);
+    else
+	cairo_arc_negative(mbe, x, y, radius, angle_start, angle_stop);
+}
+
 /* @} */
 
 #endif /* __MBE_H_ */