Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of SPI_TFT_ILI9341 by
Revision 3:3d7298360e45, committed 2013-10-18
- Comitter:
- mazgch
- Date:
- Fri Oct 18 08:10:41 2013 +0000
- Parent:
- 2:0a16083193a4
- Child:
- 4:f018e272220b
- Commit message:
- better circle functions
Changed in this revision
| SPI_TFT_ILI9341.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/SPI_TFT_ILI9341.cpp Sun Jul 21 11:57:06 2013 +0000
+++ b/SPI_TFT_ILI9341.cpp Fri Oct 18 08:10:41 2013 +0000
@@ -320,7 +320,7 @@
void SPI_TFT_ILI9341::circle(int x0, int y0, int r, int color)
{
-
+#if 0
int draw_x0, draw_y0;
int draw_x1, draw_y1;
int draw_x2, draw_y2;
@@ -424,17 +424,45 @@
}
}
return;
+#else
+ int x = -r, y = 0, err = 2-2*r, e2;
+ do {
+ pixel(x0-x, y0+y,color);
+ pixel(x0+x, y0+y,color);
+ pixel(x0+x, y0-y,color);
+ pixel(x0-x, y0-y,color);
+ e2 = err;
+ if (e2 <= y) {
+ err += ++y*2+1;
+ if (-x == y && e2 <= x) e2 = 0;
+ }
+ if (e2 > x) err += ++x*2+1;
+ } while (x <= 0);
+#endif
}
-void SPI_TFT_ILI9341::fillcircle(int x, int y, int r, int color)
+void SPI_TFT_ILI9341::fillcircle(int x0, int y0, int r, int color)
{
+#if 0
int i;
for (i = 0; i <= r; i++)
- circle(x,y,i,color);
+ circle(x0,y0,i,color);
+#else
+ int x = -r, y = 0, err = 2-2*r, e2;
+ do {
+ vline(x0-x, y0-y, y0+y, color);
+ vline(x0+x, y0-y, y0+y, color);
+ e2 = err;
+ if (e2 <= y) {
+ err += ++y*2+1;
+ if (-x == y && e2 <= x) e2 = 0;
+ }
+ if (e2 > x) err += ++x*2+1;
+ } while (x <= 0);
+#endif
}
-
void SPI_TFT_ILI9341::hline(int x0, int x1, int y, int color)
{
int w;
