summaryrefslogtreecommitdiff
path: root/apps/plugins/lib
diff options
context:
space:
mode:
authorFranklin Wei <frankhwei536@gmail.com>2015-04-08 14:15:20 -0400
committerFranklin Wei <frankhwei536@gmail.com>2016-11-20 15:13:13 -0500
commit29648f817677b84c03c2bcfe89eb8cf53653e7db (patch)
tree412e785801b00f1e832c65eaf12803fae1fefd7b /apps/plugins/lib
parent05733649bce2623acfad7b163501c6fdefea985a (diff)
downloadrockbox-29648f817677b84c03c2bcfe89eb8cf53653e7db.zip
rockbox-29648f817677b84c03c2bcfe89eb8cf53653e7db.tar.gz
rockbox-29648f817677b84c03c2bcfe89eb8cf53653e7db.tar.bz2
rockbox-29648f817677b84c03c2bcfe89eb8cf53653e7db.tar.xz
Add circle drawing/filling to xlcd
Change-Id: I5d28ade42145d9d82babcf62c0db7948927cafec
Diffstat (limited to 'apps/plugins/lib')
-rw-r--r--apps/plugins/lib/xlcd.h5
-rw-r--r--apps/plugins/lib/xlcd_draw.c100
2 files changed, 105 insertions, 0 deletions
diff --git a/apps/plugins/lib/xlcd.h b/apps/plugins/lib/xlcd.h
index b6d0867..abd5cff 100644
--- a/apps/plugins/lib/xlcd.h
+++ b/apps/plugins/lib/xlcd.h
@@ -31,6 +31,11 @@
void xlcd_filltriangle(int x1, int y1, int x2, int y2, int x3, int y3);
void xlcd_filltriangle_screen(struct screen* display,
int x1, int y1, int x2, int y2, int x3, int y3);
+void xlcd_fillcircle(int cx, int cy, int radius);
+void xlcd_fillcircle_screen(struct screen* display, int cx, int cy, int radius);
+void xlcd_drawcircle(int cx, int cy, int radius);
+void xlcd_drawcircle_screen(struct screen* display, int cx, int cy, int radius);
+
#if LCD_DEPTH >= 8
void xlcd_gray_bitmap_part(const unsigned char *src, int src_x, int src_y,
int stride, int x, int y, int width, int height);
diff --git a/apps/plugins/lib/xlcd_draw.c b/apps/plugins/lib/xlcd_draw.c
index 83ddf68..311782c 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,
xlcd_filltriangle_vertical(display, x1, y1, x2, y2, x3, y3);
}
+static void xlcd_fillcircle_horizontal(struct screen* display,
+ int cx, int cy, int radius)
+{
+ int d = 3 - (radius * 2);
+ int x = 0;
+ int y = radius;
+ while(x <= y)
+ {
+ display->hline(cx - x, cx + x, cy + y);
+ display->hline(cx - x, cx + x, cy - y);
+ display->hline(cx - y, cx + y, cy + x);
+ display->hline(cx - y, cx + y, cy - x);
+ if(d < 0)
+ {
+ d += (x * 4) + 6;
+ }
+ else
+ {
+ d += ((x - y) * 4) + 10;
+ --y;
+ }
+ ++x;
+ }
+}
+
+static void xlcd_fillcircle_vertical(struct screen* display,
+ int cx, int cy, int radius)
+{
+ int d = 3 - (radius * 2);
+ int x = 0;
+ int y = radius;
+ while(x <= y)
+ {
+ display->vline(cx + x, cy + y, cy - y);
+ display->vline(cx - x, cy + y, cy - y);
+ display->vline(cy + x, cx + y, cx - y);
+ display->vline(cy - x, cx + y, cx - y);
+ if(d < 0)
+ {
+ d += (x * 4) + 6;
+ }
+ else
+ {
+ d += ((x - y) * 4) + 10;
+ --y;
+ }
+ ++x;
+ }
+}
+
+void xlcd_fillcircle_screen(struct screen* display,
+ int cx, int cy, int radius)
+{
+ if(display->pixel_format == HORIZONTAL_PACKING || display->depth >= 8)
+ xlcd_fillcircle_horizontal(display, cx, cy, radius);
+ else
+ xlcd_fillcircle_vertical(display, cx, cy, radius);
+}
+
+void xlcd_fillcircle(int cx, int cy, int radius)
+{
+ xlcd_fillcircle_screen(rb->screens[SCREEN_MAIN], cx, cy, radius);
+}
+
+void xlcd_drawcircle_screen(struct screen* display,
+ int cx, int cy, int radius)
+{
+ int d = 3 - (radius * 2);
+ int x = 0;
+ int y = radius;
+ while(x <= y)
+ {
+ display->drawpixel(cx + x, cy + y);
+ display->drawpixel(cx - x, cy + y);
+ display->drawpixel(cx + x, cy - y);
+ display->drawpixel(cx - x, cy - y);
+ display->drawpixel(cx + y, cy + x);
+ display->drawpixel(cx - y, cy + x);
+ display->drawpixel(cx + y, cy - x);
+ display->drawpixel(cx - y, cy - x);
+ if(d < 0)
+ {
+ d += (x * 4) + 6;
+ }
+ else
+ {
+ d += ((x - y) * 4) + 10;
+ --y;
+ }
+ ++x;
+ }
+}
+
+void xlcd_drawcircle(int cx, int cy, int radius)
+{
+ /* default is main screen */
+ xlcd_drawcircle_screen(rb->screens[SCREEN_MAIN], cx, cy, radius);
+}
+
+
#if LCD_DEPTH >= 8 && LCD_DEPTH <= 16
#ifdef HAVE_LCD_COLOR