Mercurial > MadButterfly
comparison src/graph_engine_cairo.c @ 480:e813ac222f48 Android_Skia
Merge add colors into constructor of gradient pattern.
Since we also define color stops for gradient pattern and rear change
it, mbe_pattern_add_color_stop_rgba() is merged into
mb_pattern_create_radial() and mb_pattern_create_linear(). It also
makes porting to graphic engines easier.
author | Thinker K.F. Li <thinker@branda.to> |
---|---|
date | Sun, 15 Nov 2009 16:21:09 +0800 |
parents | 4dc0be6c044a |
children | b42d69ab8857 586e50f82c1f |
comparison
equal
deleted
inserted
replaced
479:9a867333018b | 480:e813ac222f48 |
---|---|
1 #include <fontconfig/fontconfig.h> | 1 #include <fontconfig/fontconfig.h> |
2 #include <cairo-ft.h> | |
2 #include "mb_graph_engine_cairo.h" | 3 #include "mb_graph_engine_cairo.h" |
3 #include "mb_shapes.h" | 4 #include "mb_shapes.h" |
4 | 5 |
5 #ifndef ASSERT | 6 #ifndef ASSERT |
6 #define ASSERT(x) | 7 #define ASSERT(x) |
106 ASSERT(face == NULL); | 107 ASSERT(face == NULL); |
107 | 108 |
108 mbe_font_face_destroy(face); | 109 mbe_font_face_destroy(face); |
109 } | 110 } |
110 | 111 |
112 mbe_pattern_t * | |
113 mbe_pattern_create_radial(co_aix cx0, co_aix cy0, co_aix radius0, | |
114 co_aix cx1, co_aix cy1, co_aix radius1, | |
115 grad_stop_t *stops, int stop_cnt) { | |
116 cairo_pattern_t *ptn; | |
117 grad_stop_t *stop; | |
118 int i; | |
119 | |
120 ptn = cairo_pattern_create_radial(cx0, cy0, radius0, | |
121 cx1, cy1, radius1); | |
122 if(ptn == NULL) | |
123 return NULL; | |
124 | |
125 stop = stops; | |
126 for(i = 0; i < stop_cnt; i++) { | |
127 cairo_pattern_add_color_stop_rgba(ptn, stop->offset, | |
128 stop->r, stop->g, stop->b, stop->a); | |
129 stop++; | |
130 } | |
131 | |
132 return ptn; | |
133 } | |
134 | |
135 mbe_pattern_t * | |
136 mbe_pattern_create_linear(co_aix x0, co_aix y0, co_aix x1, co_aix y1, | |
137 grad_stop_t *stops, int stop_cnt) { | |
138 cairo_pattern_t *ptn; | |
139 grad_stop_t *stop; | |
140 int i; | |
141 | |
142 ptn = cairo_pattern_create_linear(x0, y0, x1, y1); | |
143 if(ptn == NULL) | |
144 return NULL; | |
145 | |
146 stop = stops; | |
147 for(i = 0; i < stop_cnt; i++) { | |
148 cairo_pattern_add_color_stop_rgba(ptn, stop->offset, | |
149 stop->r, stop->g, stop->b, stop->a); | |
150 stop++; | |
151 } | |
152 | |
153 return ptn; | |
154 } |