diff options
Diffstat (limited to 'apps/plugins/lib/xlcd_draw.c')
-rw-r--r-- | apps/plugins/lib/xlcd_draw.c | 100 |
1 files changed, 100 insertions, 0 deletions
diff --git a/apps/plugins/lib/xlcd_draw.c b/apps/plugins/lib/xlcd_draw.c index 83ddf68e5c..311782c21f 100644 --- a/apps/plugins/lib/xlcd_draw.c +++ b/apps/plugins/lib/xlcd_draw.c | |||
@@ -170,6 +170,106 @@ void xlcd_filltriangle_screen(struct screen* display, | |||
170 | xlcd_filltriangle_vertical(display, x1, y1, x2, y2, x3, y3); | 170 | xlcd_filltriangle_vertical(display, x1, y1, x2, y2, x3, y3); |
171 | } | 171 | } |
172 | 172 | ||
173 | static void xlcd_fillcircle_horizontal(struct screen* display, | ||
174 | int cx, int cy, int radius) | ||
175 | { | ||
176 | int d = 3 - (radius * 2); | ||
177 | int x = 0; | ||
178 | int y = radius; | ||
179 | while(x <= y) | ||
180 | { | ||
181 | display->hline(cx - x, cx + x, cy + y); | ||
182 | display->hline(cx - x, cx + x, cy - y); | ||
183 | display->hline(cx - y, cx + y, cy + x); | ||
184 | display->hline(cx - y, cx + y, cy - x); | ||
185 | if(d < 0) | ||
186 | { | ||
187 | d += (x * 4) + 6; | ||
188 | } | ||
189 | else | ||
190 | { | ||
191 | d += ((x - y) * 4) + 10; | ||
192 | --y; | ||
193 | } | ||
194 | ++x; | ||
195 | } | ||
196 | } | ||
197 | |||
198 | static void xlcd_fillcircle_vertical(struct screen* display, | ||
199 | int cx, int cy, int radius) | ||
200 | { | ||
201 | int d = 3 - (radius * 2); | ||
202 | int x = 0; | ||
203 | int y = radius; | ||
204 | while(x <= y) | ||
205 | { | ||
206 | display->vline(cx + x, cy + y, cy - y); | ||
207 | display->vline(cx - x, cy + y, cy - y); | ||
208 | display->vline(cy + x, cx + y, cx - y); | ||
209 | display->vline(cy - x, cx + y, cx - y); | ||
210 | if(d < 0) | ||
211 | { | ||
212 | d += (x * 4) + 6; | ||
213 | } | ||
214 | else | ||
215 | { | ||
216 | d += ((x - y) * 4) + 10; | ||
217 | --y; | ||
218 | } | ||
219 | ++x; | ||
220 | } | ||
221 | } | ||
222 | |||
223 | void xlcd_fillcircle_screen(struct screen* display, | ||
224 | int cx, int cy, int radius) | ||
225 | { | ||
226 | if(display->pixel_format == HORIZONTAL_PACKING || display->depth >= 8) | ||
227 | xlcd_fillcircle_horizontal(display, cx, cy, radius); | ||
228 | else | ||
229 | xlcd_fillcircle_vertical(display, cx, cy, radius); | ||
230 | } | ||
231 | |||
232 | void xlcd_fillcircle(int cx, int cy, int radius) | ||
233 | { | ||
234 | xlcd_fillcircle_screen(rb->screens[SCREEN_MAIN], cx, cy, radius); | ||
235 | } | ||
236 | |||
237 | void xlcd_drawcircle_screen(struct screen* display, | ||
238 | int cx, int cy, int radius) | ||
239 | { | ||
240 | int d = 3 - (radius * 2); | ||
241 | int x = 0; | ||
242 | int y = radius; | ||
243 | while(x <= y) | ||
244 | { | ||
245 | display->drawpixel(cx + x, cy + y); | ||
246 | display->drawpixel(cx - x, cy + y); | ||
247 | display->drawpixel(cx + x, cy - y); | ||
248 | display->drawpixel(cx - x, cy - y); | ||
249 | display->drawpixel(cx + y, cy + x); | ||
250 | display->drawpixel(cx - y, cy + x); | ||
251 | display->drawpixel(cx + y, cy - x); | ||
252 | display->drawpixel(cx - y, cy - x); | ||
253 | if(d < 0) | ||
254 | { | ||
255 | d += (x * 4) + 6; | ||
256 | } | ||
257 | else | ||
258 | { | ||
259 | d += ((x - y) * 4) + 10; | ||
260 | --y; | ||
261 | } | ||
262 | ++x; | ||
263 | } | ||
264 | } | ||
265 | |||
266 | void xlcd_drawcircle(int cx, int cy, int radius) | ||
267 | { | ||
268 | /* default is main screen */ | ||
269 | xlcd_drawcircle_screen(rb->screens[SCREEN_MAIN], cx, cy, radius); | ||
270 | } | ||
271 | |||
272 | |||
173 | #if LCD_DEPTH >= 8 && LCD_DEPTH <= 16 | 273 | #if LCD_DEPTH >= 8 && LCD_DEPTH <= 16 |
174 | 274 | ||
175 | #ifdef HAVE_LCD_COLOR | 275 | #ifdef HAVE_LCD_COLOR |