comparison 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
comparison
equal deleted inserted replaced
457:ea09fdab333a 458:bb4f651090bf
45 #define mbe_set_line_width cairo_set_line_width 45 #define mbe_set_line_width cairo_set_line_width
46 #define mbe_get_font_face cairo_get_font_face 46 #define mbe_get_font_face cairo_get_font_face
47 #define mbe_fill_preserve cairo_fill_preserve 47 #define mbe_fill_preserve cairo_fill_preserve
48 #define mbe_set_operator cairo_set_operator 48 #define mbe_set_operator cairo_set_operator
49 #define mbe_get_operator cairo_get_operator 49 #define mbe_get_operator cairo_get_operator
50 #define mbe_arc_negative cairo_arc_negative
51 #define mbe_set_source cairo_set_source 50 #define mbe_set_source cairo_set_source
52 #define mbe_reset_clip cairo_reset_clip 51 #define mbe_reset_clip cairo_reset_clip
53 #define mbe_get_target cairo_get_target 52 #define mbe_get_target cairo_get_target
54 #define mbe_close_path cairo_close_path 53 #define mbe_close_path cairo_close_path
55 #define mbe_translate cairo_translate 54 #define mbe_translate cairo_translate
70 #define mbe_scale cairo_scale 69 #define mbe_scale cairo_scale
71 #define mbe_paint cairo_paint 70 #define mbe_paint cairo_paint
72 #define mbe_save cairo_save 71 #define mbe_save cairo_save
73 #define mbe_fill cairo_fill 72 #define mbe_fill cairo_fill
74 #define mbe_clip cairo_clip 73 #define mbe_clip cairo_clip
75 #define mbe_arc cairo_arc
76 74
77 typedef cairo_text_extents_t mbe_text_extents_t; 75 typedef cairo_text_extents_t mbe_text_extents_t;
78 typedef cairo_font_options_t mbe_font_options_t; 76 typedef cairo_font_options_t mbe_font_options_t;
79 typedef cairo_scaled_font_t mbe_scaled_font_t; 77 typedef cairo_scaled_font_t mbe_scaled_font_t;
80 typedef cairo_font_face_t mbe_font_face_t; 78 typedef cairo_font_face_t mbe_font_face_t;
82 typedef cairo_surface_t mbe_surface_t; 80 typedef cairo_surface_t mbe_surface_t;
83 typedef cairo_pattern_t mbe_pattern_t; 81 typedef cairo_pattern_t mbe_pattern_t;
84 typedef cairo_status_t mbe_status_t; 82 typedef cairo_status_t mbe_status_t;
85 typedef cairo_matrix_t mbe_matrix_t; 83 typedef cairo_matrix_t mbe_matrix_t;
86 typedef cairo_t mbe_t; 84 typedef cairo_t mbe_t;
85 typedef float co_aix;
87 86
88 static mbe_surface_t * 87 static mbe_surface_t *
89 mbe_image_surface_create_for_data(unsigned char *data, 88 mbe_image_surface_create_for_data(unsigned char *data,
90 mb_img_fmt_t fmt, 89 mb_img_fmt_t fmt,
91 int width, int height, 90 int width, int height,
161 } 160 }
162 161
163 return cairo_image_surface_create(_fmt, width, height); 162 return cairo_image_surface_create(_fmt, width, height);
164 } 163 }
165 164
165 static void
166 mbe_transform(mbe_t *mbe, const co_aix matrix[6]) {
167 cairo_matrix_t cmtx;
168
169 cmtx.xx = matrix[0];
170 cmtx.xy = matrix[1];
171 cmtx.x0 = matrix[2];
172 cmtx.yx = matrix[3];
173 cmtx.yy = matrix[4];
174 cmtx.y0 = matrix[5];
175
176 cairo_transform(mbe, &cmtx);
177 }
178
179 static void
180 mbe_arc(mbe_t *mbe, co_aix x, co_aix y, co_aix radius,
181 co_aix angle_start, co_aix angle_stop) {
182 if(angle_start <= angle_stop)
183 cairo_arc(mbe, x, y, radius, angle_start, angle_stop);
184 else
185 cairo_arc_negative(mbe, x, y, radius, angle_start, angle_stop);
186 }
187
166 /* @} */ 188 /* @} */
167 189
168 #endif /* __MBE_H_ */ 190 #endif /* __MBE_H_ */