|
|
@@ -49,6 +49,10 @@ POSSIBILITY OF SUCH DAMAGE.
|
|
|
#define min(a,b) (((a) < (b)) ? (a) : (b))
|
|
|
#endif
|
|
|
|
|
|
+#ifndef _swap_int16_t
|
|
|
+#define _swap_int16_t(a, b) { int16_t t = a; a = b; b = t; }
|
|
|
+#endif
|
|
|
+
|
|
|
Adafruit_GFX::Adafruit_GFX(int16_t w, int16_t h):
|
|
|
WIDTH(w), HEIGHT(h)
|
|
|
{
|
|
|
@@ -176,13 +180,13 @@ void Adafruit_GFX::drawLine(int16_t x0, int16_t y0, int16_t x1, int16_t y1,
|
|
|
uint16_t color) {
|
|
|
int16_t steep = abs(y1 - y0) > abs(x1 - x0);
|
|
|
if (steep) {
|
|
|
- adagfxswap(x0, y0);
|
|
|
- adagfxswap(x1, y1);
|
|
|
+ _swap_int16_t(x0, y0);
|
|
|
+ _swap_int16_t(x1, y1);
|
|
|
}
|
|
|
|
|
|
if (x0 > x1) {
|
|
|
- adagfxswap(x0, x1);
|
|
|
- adagfxswap(y0, y1);
|
|
|
+ _swap_int16_t(x0, x1);
|
|
|
+ _swap_int16_t(y0, y1);
|
|
|
}
|
|
|
|
|
|
int16_t dx, dy;
|
|
|
@@ -287,13 +291,13 @@ void Adafruit_GFX::fillTriangle(int16_t x0, int16_t y0,
|
|
|
|
|
|
// Sort coordinates by Y order (y2 >= y1 >= y0)
|
|
|
if (y0 > y1) {
|
|
|
- adagfxswap(y0, y1); adagfxswap(x0, x1);
|
|
|
+ _swap_int16_t(y0, y1); _swap_int16_t(x0, x1);
|
|
|
}
|
|
|
if (y1 > y2) {
|
|
|
- adagfxswap(y2, y1); adagfxswap(x2, x1);
|
|
|
+ _swap_int16_t(y2, y1); _swap_int16_t(x2, x1);
|
|
|
}
|
|
|
if (y0 > y1) {
|
|
|
- adagfxswap(y0, y1); adagfxswap(x0, x1);
|
|
|
+ _swap_int16_t(y0, y1); _swap_int16_t(x0, x1);
|
|
|
}
|
|
|
|
|
|
if(y0 == y2) { // Handle awkward all-on-same-line case as its own thing
|
|
|
@@ -335,7 +339,7 @@ void Adafruit_GFX::fillTriangle(int16_t x0, int16_t y0,
|
|
|
a = x0 + (x1 - x0) * (y - y0) / (y1 - y0);
|
|
|
b = x0 + (x2 - x0) * (y - y0) / (y2 - y0);
|
|
|
*/
|
|
|
- if(a > b) adagfxswap(a,b);
|
|
|
+ if(a > b) _swap_int16_t(a,b);
|
|
|
drawFastHLine(a, y, b-a+1, color);
|
|
|
}
|
|
|
|
|
|
@@ -352,7 +356,7 @@ void Adafruit_GFX::fillTriangle(int16_t x0, int16_t y0,
|
|
|
a = x1 + (x2 - x1) * (y - y1) / (y2 - y1);
|
|
|
b = x0 + (x2 - x0) * (y - y0) / (y2 - y0);
|
|
|
*/
|
|
|
- if(a > b) adagfxswap(a,b);
|
|
|
+ if(a > b) _swap_int16_t(a,b);
|
|
|
drawFastHLine(a, y, b-a+1, color);
|
|
|
}
|
|
|
}
|