59 Sint16 last1x, last1y, last2x, last2y, first1x, first1y, first2x, first2y, tempx,
tempy;
73 int pixel(SDL_Renderer *renderer, Sint16 x, Sint16 y)
75 return SDL_RenderDrawPoint(renderer, x, y);
88 int pixelColor(SDL_Renderer * renderer, Sint16 x, Sint16 y, Uint32 color)
90 Uint8 *c = (Uint8 *)&color;
91 return pixelRGBA(renderer, x, y, c[0], c[1], c[2], c[3]);
107 int pixelRGBA(SDL_Renderer * renderer, Sint16 x, Sint16 y, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
110 result |= SDL_SetRenderDrawBlendMode(renderer, (a == 255) ? SDL_BLENDMODE_NONE : SDL_BLENDMODE_BLEND);
111 result |= SDL_SetRenderDrawColor(renderer, r, g, b, a);
112 result |= SDL_RenderDrawPoint(renderer, x, y);
130 int pixelRGBAWeight(SDL_Renderer * renderer, Sint16 x, Sint16 y, Uint8 r, Uint8 g, Uint8 b, Uint8 a, Uint32 weight)
136 ax = ((ax * weight) >> 8);
140 a = (Uint8)(ax & 0x000000ff);
143 return pixelRGBA(renderer, x, y, r, g, b, a);
158 int hline(SDL_Renderer * renderer, Sint16 x1, Sint16 x2, Sint16 y)
160 return SDL_RenderDrawLine(renderer, x1, y, x2, y);;
175 int hlineColor(SDL_Renderer * renderer, Sint16 x1, Sint16 x2, Sint16 y, Uint32 color)
177 Uint8 *c = (Uint8 *)&color;
178 return hlineRGBA(renderer, x1, x2, y, c[0], c[1], c[2], c[3]);
195 int hlineRGBA(SDL_Renderer * renderer, Sint16 x1, Sint16 x2, Sint16 y, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
198 result |= SDL_SetRenderDrawBlendMode(renderer, (a == 255) ? SDL_BLENDMODE_NONE : SDL_BLENDMODE_BLEND);
199 result |= SDL_SetRenderDrawColor(renderer, r, g, b, a);
200 result |= SDL_RenderDrawLine(renderer, x1, y, x2, y);
216 int vline(SDL_Renderer * renderer, Sint16 x, Sint16 y1, Sint16 y2)
218 return SDL_RenderDrawLine(renderer, x, y1, x, y2);;
232 int vlineColor(SDL_Renderer * renderer, Sint16 x, Sint16 y1, Sint16 y2, Uint32 color)
234 Uint8 *c = (Uint8 *)&color;
235 return vlineRGBA(renderer, x, y1, y2, c[0], c[1], c[2], c[3]);
252 int vlineRGBA(SDL_Renderer * renderer, Sint16 x, Sint16 y1, Sint16 y2, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
255 result |= SDL_SetRenderDrawBlendMode(renderer, (a == 255) ? SDL_BLENDMODE_NONE : SDL_BLENDMODE_BLEND);
256 result |= SDL_SetRenderDrawColor(renderer, r, g, b, a);
257 result |= SDL_RenderDrawLine(renderer, x, y1, x, y2);
275 int rectangleColor(SDL_Renderer * renderer, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Uint32 color)
277 Uint8 *c = (Uint8 *)&color;
278 return rectangleRGBA(renderer, x1, y1, x2, y2, c[0], c[1], c[2], c[3]);
296 int rectangleRGBA(SDL_Renderer * renderer, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
307 return (
pixelRGBA(renderer, x1, y1, r, g, b, a));
309 return (
vlineRGBA(renderer, x1, y1, y2, r, g, b, a));
313 return (
hlineRGBA(renderer, x1, x2, y1, r, g, b, a));
347 result |= SDL_SetRenderDrawBlendMode(renderer, (a == 255) ? SDL_BLENDMODE_NONE : SDL_BLENDMODE_BLEND);
348 result |= SDL_SetRenderDrawColor(renderer, r, g, b, a);
349 result |= SDL_RenderDrawRect(renderer, &rect);
368 int roundedRectangleColor(SDL_Renderer * renderer, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Sint16 rad, Uint32 color)
370 Uint8 *c = (Uint8 *)&color;
390 int roundedRectangleRGBA(SDL_Renderer * renderer, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Sint16 rad, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
401 if (renderer == NULL)
425 return (
pixelRGBA(renderer, x1, y1, r, g, b, a));
427 return (
vlineRGBA(renderer, x1, y1, y2, r, g, b, a));
431 return (
hlineRGBA(renderer, x1, x2, y1, r, g, b, a));
478 result |=
arcRGBA(renderer, xx1, yy1, rad, 180, 270, r, g, b, a);
479 result |=
arcRGBA(renderer, xx2, yy1, rad, 270, 360, r, g, b, a);
480 result |=
arcRGBA(renderer, xx1, yy2, rad, 90, 180, r, g, b, a);
481 result |=
arcRGBA(renderer, xx2, yy2, rad, 0, 90, r, g, b, a);
487 result |=
hlineRGBA(renderer, xx1, xx2, y1, r, g, b, a);
488 result |=
hlineRGBA(renderer, xx1, xx2, y2, r, g, b, a);
491 result |=
vlineRGBA(renderer, x1, yy1, yy2, r, g, b, a);
492 result |=
vlineRGBA(renderer, x2, yy1, yy2, r, g, b, a);
513 int roundedBoxColor(SDL_Renderer * renderer, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Sint16 rad, Uint32 color)
515 Uint8 *c = (Uint8 *)&color;
516 return roundedBoxRGBA(renderer, x1, y1, x2, y2, rad, c[0], c[1], c[2], c[3]);
536 Sint16 y2, Sint16 rad, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
539 Sint16 w, h, r2, tmp;
542 Sint16 ocx = (Sint16) 0xffff;
543 Sint16 ocy = (Sint16) 0xffff;
546 Sint16 d_se = -2 * rad + 5;
547 Sint16 xpcx, xmcx, xpcy, xmcy;
548 Sint16 ypcy, ymcy, ypcx, ymcx;
554 if (renderer == NULL)
570 return boxRGBA(renderer, x1, y1, x2, y2, r, g, b, a);
578 return (
pixelRGBA(renderer, x1, y1, r, g, b, a));
580 return (
vlineRGBA(renderer, x1, y1, y2, r, g, b, a));
584 return (
hlineRGBA(renderer, x1, x2, y1, r, g, b, a));
629 dx = x2 - x1 - rad - rad;
630 dy = y2 - y1 - rad - rad;
636 result |= SDL_SetRenderDrawBlendMode(renderer, (a == 255) ? SDL_BLENDMODE_NONE : SDL_BLENDMODE_BLEND);
637 result |= SDL_SetRenderDrawColor(renderer, r, g, b, a);
651 result |=
hline(renderer, xmcx, xpcx + dx, ypcy + dy);
652 result |=
hline(renderer, xmcx, xpcx + dx, ymcy);
654 result |=
hline(renderer, xmcx, xpcx + dx, y);
663 result |=
hline(renderer, xmcy, xpcy + dx, ymcx);
664 result |=
hline(renderer, xmcy, xpcy + dx, ypcx + dy);
666 result |=
hline(renderer, xmcy, xpcy + dx, y);
689 if (dx > 0 && dy > 0) {
690 result |=
boxRGBA(renderer, x1, y1 + rad + 1, x2, y2 - rad, r, g, b, a);
710 int boxColor(SDL_Renderer * renderer, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Uint32 color)
712 Uint8 *c = (Uint8 *)&color;
713 return boxRGBA(renderer, x1, y1, x2, y2, c[0], c[1], c[2], c[3]);
731 int boxRGBA(SDL_Renderer * renderer, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
742 return (
pixelRGBA(renderer, x1, y1, r, g, b, a));
744 return (
vlineRGBA(renderer, x1, y1, y2, r, g, b, a));
748 return (
hlineRGBA(renderer, x1, x2, y1, r, g, b, a));
775 rect.w = x2 - x1 + 1;
776 rect.h = y2 - y1 + 1;
782 result |= SDL_SetRenderDrawBlendMode(renderer, (a == 255) ? SDL_BLENDMODE_NONE : SDL_BLENDMODE_BLEND);
783 result |= SDL_SetRenderDrawColor(renderer, r, g, b, a);
784 result |= SDL_RenderFillRect(renderer, &rect);
801 int line(SDL_Renderer * renderer, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2)
806 return SDL_RenderDrawLine(renderer, x1, y1, x2, y2);
821 int lineColor(SDL_Renderer * renderer, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Uint32 color)
823 Uint8 *c = (Uint8 *)&color;
824 return lineRGBA(renderer, x1, y1, x2, y2, c[0], c[1], c[2], c[3]);
842 int lineRGBA(SDL_Renderer * renderer, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
848 result |= SDL_SetRenderDrawBlendMode(renderer, (a == 255) ? SDL_BLENDMODE_NONE : SDL_BLENDMODE_BLEND);
849 result |= SDL_SetRenderDrawColor(renderer, r, g, b, a);
850 result |= SDL_RenderDrawLine(renderer, x1, y1, x2, y2);
882 int _aalineRGBA(SDL_Renderer * renderer, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Uint8 r, Uint8 g, Uint8 b, Uint8 a,
int draw_endpoint)
884 Sint32 xx0, yy0, xx1, yy1;
886 Uint32 intshift, erracc, erradj;
887 Uint32 erracctmp, wgt, wgtcompmask;
888 int dx, dy, tmp, xdir, y0p1, x0pxdir;
935 return (
vlineRGBA(renderer, x1, y1, y2, r, g, b, a));
938 return (
vlineRGBA(renderer, x1, yy0, yy0+dy, r, g, b, a));
940 return (
pixelRGBA(renderer, x1, y1, r, g, b, a));
943 }
else if (dy == 0) {
949 return (
hlineRGBA(renderer, x1, x2, y1, r, g, b, a));
952 return (
hlineRGBA(renderer, xx0, xx0+(xdir*dx), y1, r, g, b, a));
954 return (
pixelRGBA(renderer, x1, y1, r, g, b, a));
957 }
else if ((dx == dy) && (draw_endpoint)) {
961 return (
lineRGBA(renderer, x1, y1, x2, y2, r, g, b, a));
988 result |=
pixelRGBA(renderer, x1, y1, r, g, b, a);
1003 erradj = ((dx << 16) / dy) << 16;
1008 x0pxdir = xx0 + xdir;
1012 if (erracc <= erracctmp) {
1026 wgt = (erracc >> intshift) & 255;
1027 result |=
pixelRGBAWeight (renderer, xx0, yy0, r, g, b, a, 255 - wgt);
1041 erradj = ((dy << 16) / dx) << 16;
1051 if (erracc <= erracctmp) {
1064 wgt = (erracc >> intshift) & 255;
1065 result |=
pixelRGBAWeight (renderer, xx0, yy0, r, g, b, a, 255 - wgt);
1073 if (draw_endpoint) {
1078 result |=
pixelRGBA (renderer, x2, y2, r, g, b, a);
1096 int aalineColor(SDL_Renderer * renderer, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Uint32 color)
1098 Uint8 *c = (Uint8 *)&color;
1099 return _aalineRGBA(renderer, x1, y1, x2, y2, c[0], c[1], c[2], c[3], 1);
1117 int aalineRGBA(SDL_Renderer * renderer, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
1119 return _aalineRGBA(renderer, x1, y1, x2, y2, r, g, b, a, 1);
1135 int circleColor(SDL_Renderer * renderer, Sint16 x, Sint16 y, Sint16 rad, Uint32 color)
1137 Uint8 *c = (Uint8 *)&color;
1138 return ellipseRGBA(renderer, x, y, rad, rad, c[0], c[1], c[2], c[3]);
1155 int circleRGBA(SDL_Renderer * renderer, Sint16 x, Sint16 y, Sint16 rad, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
1157 return ellipseRGBA(renderer, x, y, rad, rad, r, g, b, a);
1175 int arcColor(SDL_Renderer * renderer, Sint16 x, Sint16 y, Sint16 rad, Sint16 start, Sint16 end, Uint32 color)
1177 Uint8 *c = (Uint8 *)&color;
1178 return arcRGBA(renderer, x, y, rad, start, end, c[0], c[1], c[2], c[3]);
1198 int arcRGBA(SDL_Renderer * renderer, Sint16 x, Sint16 y, Sint16 rad, Sint16 start, Sint16 end, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
1203 Sint16 df = 1 - rad;
1205 Sint16 d_se = -2 * rad + 5;
1206 Sint16 xpcx, xmcx, xpcy, xmcy;
1207 Sint16 ypcy, ymcy, ypcx, ymcx;
1209 int startoct, endoct, oct, stopval_start = 0, stopval_end = 0;
1210 double dstart, dend, temp = 0.;
1223 return (
pixelRGBA(renderer, x, y, r, g, b, a));
1252 while (start < 0) start += 360;
1253 while (end < 0) end += 360;
1258 startoct = start / 45;
1264 oct = (oct + 1) % 8;
1266 if (oct == startoct) {
1268 dstart = (double)start;
1273 temp = sin(dstart *
M_PI / 180.);
1277 temp = cos(dstart *
M_PI / 180.);
1281 temp = -cos(dstart *
M_PI / 180.);
1285 temp = -sin(dstart *
M_PI / 180.);
1289 stopval_start = (int)temp;
1297 if (oct % 2) drawoct |= (1 << oct);
1298 else drawoct &= 255 - (1 << oct);
1300 if (oct == endoct) {
1307 temp = sin(dend *
M_PI / 180);
1311 temp = cos(dend *
M_PI / 180);
1315 temp = -cos(dend *
M_PI / 180);
1319 temp = -sin(dend *
M_PI / 180);
1323 stopval_end = (int)temp;
1326 if (startoct == endoct) {
1334 drawoct &= 255 - (1 << oct);
1337 else if (oct % 2) drawoct &= 255 - (1 << oct);
1338 else drawoct |= (1 << oct);
1339 }
else if (oct != startoct) {
1340 drawoct |= (1 << oct);
1342 }
while (oct != endoct);
1350 result |= SDL_SetRenderDrawBlendMode(renderer, (a == 255) ? SDL_BLENDMODE_NONE : SDL_BLENDMODE_BLEND);
1351 result |= SDL_SetRenderDrawColor(renderer, r, g, b, a);
1364 if (drawoct & 4) result |=
pixel(renderer, xmcx, ypcy);
1365 if (drawoct & 2) result |=
pixel(renderer, xpcx, ypcy);
1366 if (drawoct & 32) result |=
pixel(renderer, xmcx, ymcy);
1367 if (drawoct & 64) result |=
pixel(renderer, xpcx, ymcy);
1369 if (drawoct & 96) result |=
pixel(renderer, x, ymcy);
1370 if (drawoct & 6) result |=
pixel(renderer, x, ypcy);
1375 if (cx > 0 && cx != cy) {
1378 if (drawoct & 8) result |=
pixel(renderer, xmcy, ypcx);
1379 if (drawoct & 1) result |=
pixel(renderer, xpcy, ypcx);
1380 if (drawoct & 16) result |=
pixel(renderer, xmcy, ymcx);
1381 if (drawoct & 128) result |=
pixel(renderer, xpcy, ymcx);
1382 }
else if (cx == 0) {
1383 if (drawoct & 24) result |=
pixel(renderer, xmcy, y);
1384 if (drawoct & 129) result |=
pixel(renderer, xpcy, y);
1390 if (stopval_start == cx) {
1393 if (drawoct & (1 << startoct)) drawoct &= 255 - (1 << startoct);
1394 else drawoct |= (1 << startoct);
1396 if (stopval_end == cx) {
1397 if (drawoct & (1 << endoct)) drawoct &= 255 - (1 << endoct);
1398 else drawoct |= (1 << endoct);
1433 int aacircleColor(SDL_Renderer * renderer, Sint16 x, Sint16 y, Sint16 rad, Uint32 color)
1435 Uint8 *c = (Uint8 *)&color;
1436 return aaellipseRGBA(renderer, x, y, rad, rad, c[0], c[1], c[2], c[3]);
1453 int aacircleRGBA(SDL_Renderer * renderer, Sint16 x, Sint16 y, Sint16 rad, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
1475 int _drawQuadrants(SDL_Renderer * renderer, Sint16 x, Sint16 y, Sint16 dx, Sint16 dy, Sint32 f)
1483 result |=
pixel(renderer, x, y);
1488 result |=
vline(renderer, x, ymdy, ypdy);
1490 result |=
pixel(renderer, x, ypdy);
1491 result |=
pixel(renderer, x, ymdy);
1500 result |=
vline(renderer, xpdx, ymdy, ypdy);
1501 result |=
vline(renderer, xmdx, ymdy, ypdy);
1503 result |=
pixel(renderer, xpdx, ypdy);
1504 result |=
pixel(renderer, xmdx, ypdy);
1505 result |=
pixel(renderer, xpdx, ymdy);
1506 result |=
pixel(renderer, xmdx, ymdy);
1529 #define DEFAULT_ELLIPSE_OVERSCAN 4 1530 int _ellipseRGBA(SDL_Renderer * renderer, Sint16 x, Sint16 y, Sint16 rx, Sint16 ry, Uint8 r, Uint8 g, Uint8 b, Uint8 a, Sint32 f)
1534 Sint32 rx2, ry2, rx22, ry22;
1536 Sint32 curX, curY, curXp1, curYm1;
1537 Sint32 scrX, scrY, oldX, oldY;
1538 Sint32 deltaX, deltaY;
1539 Sint32 ellipseOverscan;
1544 if ((rx < 0) || (ry < 0)) {
1552 result |= SDL_SetRenderDrawBlendMode(renderer, (a == 255) ? SDL_BLENDMODE_NONE : SDL_BLENDMODE_BLEND);
1553 result |= SDL_SetRenderDrawColor(renderer, r, g, b, a);
1560 return (
pixel(renderer, x, y));
1562 return (
vline(renderer, x, y - ry, y + ry));
1566 return (
hline(renderer, x - rx, x + rx, y));
1575 if (rxi >= 512 || ryi >= 512)
1579 else if (rxi >= 256 || ryi >= 256)
1596 rxi *= ellipseOverscan;
1597 ryi *= ellipseOverscan;
1605 deltaY = rx22 * curY;
1608 error = ry2 - rx2 * ryi + rx2 / 4;
1609 while (deltaX <= deltaY)
1614 error += deltaX + ry2;
1622 scrX = curX / ellipseOverscan;
1623 scrY = curY / ellipseOverscan;
1624 if ((scrX != oldX && scrY == oldY) || (scrX != oldX && scrY != oldY)) {
1636 error = ry2 * curX * curXp1 + ((ry2 + 3) / 4) + rx2 * curYm1 * curYm1 - rx2 * ry2;
1652 scrX = curX / ellipseOverscan;
1653 scrY = curY / ellipseOverscan;
1654 if ((scrX != oldX && scrY == oldY) || (scrX != oldX && scrY != oldY)) {
1656 for (;oldY >= scrY; oldY--) {
1671 for (;oldY >= 0; oldY--) {
1692 int ellipseColor(SDL_Renderer * renderer, Sint16 x, Sint16 y, Sint16 rx, Sint16 ry, Uint32 color)
1694 Uint8 *c = (Uint8 *)&color;
1695 return _ellipseRGBA(renderer, x, y, rx, ry, c[0], c[1], c[2], c[3], 0);
1713 int ellipseRGBA(SDL_Renderer * renderer, Sint16 x, Sint16 y, Sint16 rx, Sint16 ry, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
1715 return _ellipseRGBA(renderer, x, y, rx, ry, r, g, b, a, 0);
1733 Uint8 *c = (Uint8 *)&color;
1751 int filledCircleRGBA(SDL_Renderer * renderer, Sint16 x, Sint16 y, Sint16 rad, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
1753 return _ellipseRGBA(renderer, x, y, rad, rad, r, g ,b, a, 1);
1760 #if defined(_MSC_VER) 1763 #include <emmintrin.h> 1764 static __inline
long 1767 return _mm_cvtss_si32(_mm_load_ss(&f));
1769 #elif defined(_M_IX86) 1781 #elif defined(_M_ARM) 1782 #include <armintr.h> 1783 #pragma warning(push) 1784 #pragma warning(disable: 4716) 1785 __declspec(naked)
long int 1793 #pragma warning(pop) 1795 #error lrint needed for MSVC on non X86/AMD64/ARM targets. 1811 int aaellipseColor(SDL_Renderer * renderer, Sint16 x, Sint16 y, Sint16 rx, Sint16 ry, Uint32 color)
1813 Uint8 *c = (Uint8 *)&color;
1814 return aaellipseRGBA(renderer, x, y, rx, ry, c[0], c[1], c[2], c[3]);
1832 int aaellipseRGBA(SDL_Renderer * renderer, Sint16 x, Sint16 y, Sint16 rx, Sint16 ry, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
1836 int a2, b2, ds, dt, dxt, t, s, d;
1837 Sint16 xp, yp, xs, ys, dyt, od, xx, yy, xc2, yc2;
1840 Uint8 weight, iweight;
1845 if ((rx < 0) || (ry < 0)) {
1854 return (
pixelRGBA(renderer, x, y, r, g, b, a));
1856 return (
vlineRGBA(renderer, x, y - ry, y + ry, r, g, b, a));
1860 return (
hlineRGBA(renderer, x - rx, x + rx, y, r, g, b, a));
1874 sab = sqrt((
double)(a2 + b2));
1875 od = (Sint16)lrint(sab*0.01) + 1;
1876 dxt = (Sint16)lrint((
double)a2 / sab) + od;
1887 result |= SDL_SetRenderDrawBlendMode(renderer, (a == 255) ? SDL_BLENDMODE_NONE : SDL_BLENDMODE_BLEND);
1890 result |=
pixelRGBA(renderer, xp, yp, r, g, b, a);
1891 result |=
pixelRGBA(renderer, xc2 - xp, yp, r, g, b, a);
1892 result |=
pixelRGBA(renderer, xp, yc2 - yp, r, g, b, a);
1893 result |=
pixelRGBA(renderer, xc2 - xp, yc2 - yp, r, g, b, a);
1895 for (i = 1; i <= dxt; i++) {
1901 else if ((d - s - a2) > 0) {
1902 if ((2 * d - s - a2) >= 0)
1921 cp = (float) abs(d) / (float) abs(s);
1930 weight = (Uint8) (cp * 255);
1931 iweight = 255 - weight;
1952 dyt = (Sint16)lrint((
double)b2 / sab ) + od;
1954 for (i = 1; i <= dyt; i++) {
1960 else if ((d + t - b2) < 0) {
1961 if ((2 * d + t - b2) <= 0)
1980 cp = (float) abs(d) / (float) abs(t);
1989 weight = (Uint8) (cp * 255);
1990 iweight = 255 - weight;
2029 Uint8 *c = (Uint8 *)&color;
2030 return _ellipseRGBA(renderer, x, y, rx, ry, c[0], c[1], c[2], c[3], 1);
2048 int filledEllipseRGBA(SDL_Renderer * renderer, Sint16 x, Sint16 y, Sint16 rx, Sint16 ry, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
2050 return _ellipseRGBA(renderer, x, y, rx, ry, r, g, b, a, 1);
2075 int _pieRGBA(SDL_Renderer * renderer, Sint16 x, Sint16 y, Sint16 rad, Sint16 start, Sint16 end, Uint8 r, Uint8 g, Uint8 b, Uint8 a, Uint8 filled)
2078 double angle, start_angle, end_angle;
2094 start = start % 360;
2101 return (
pixelRGBA(renderer, x, y, r, g, b, a));
2108 deltaAngle = 3.0 / dr;
2109 start_angle = (double) start *(2.0 *
M_PI / 360.0);
2110 end_angle = (double) end *(2.0 *
M_PI / 360.0);
2112 end_angle += (2.0 *
M_PI);
2119 angle = start_angle;
2120 while (angle < end_angle) {
2121 angle += deltaAngle;
2126 vx = vy = (Sint16 *) malloc(2 *
sizeof(Uint16) * numpoints);
2139 angle = start_angle;
2140 vx[1] = x + (int) (dr * cos(angle));
2141 vy[1] = y + (int) (dr * sin(angle));
2145 result =
lineRGBA(renderer, vx[0], vy[0], vx[1], vy[1], r, g, b, a);
2151 angle = start_angle;
2152 while (angle < end_angle) {
2153 angle += deltaAngle;
2154 if (angle>end_angle)
2158 vx[i] = x + (int) (dr * cos(angle));
2159 vy[i] = y + (int) (dr * sin(angle));
2167 result =
polygonRGBA(renderer, vx, vy, numpoints, r, g, b, a);
2190 int pieColor(SDL_Renderer * renderer, Sint16 x, Sint16 y, Sint16 rad,
2191 Sint16 start, Sint16 end, Uint32 color)
2193 Uint8 *c = (Uint8 *)&color;
2194 return _pieRGBA(renderer, x, y, rad, start, end, c[0], c[1], c[2], c[3], 0);
2213 int pieRGBA(SDL_Renderer * renderer, Sint16 x, Sint16 y, Sint16 rad,
2214 Sint16 start, Sint16 end, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
2216 return _pieRGBA(renderer, x, y, rad, start, end, r, g, b, a, 0);
2232 int filledPieColor(SDL_Renderer * renderer, Sint16 x, Sint16 y, Sint16 rad, Sint16 start, Sint16 end, Uint32 color)
2234 Uint8 *c = (Uint8 *)&color;
2235 return _pieRGBA(renderer, x, y, rad, start, end, c[0], c[1], c[2], c[3], 1);
2255 Sint16 start, Sint16 end, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
2257 return _pieRGBA(renderer, x, y, rad, start, end, r, g, b, a, 1);
2278 int trigonColor(SDL_Renderer * renderer, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Sint16 x3, Sint16 y3, Uint32 color)
2310 int trigonRGBA(SDL_Renderer * renderer, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Sint16 x3, Sint16 y3,
2311 Uint8 r, Uint8 g, Uint8 b, Uint8 a)
2344 int aatrigonColor(SDL_Renderer * renderer, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Sint16 x3, Sint16 y3, Uint32 color)
2376 int aatrigonRGBA(SDL_Renderer * renderer, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Sint16 x3, Sint16 y3,
2377 Uint8 r, Uint8 g, Uint8 b, Uint8 a)
2410 int filledTrigonColor(SDL_Renderer * renderer, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Sint16 x3, Sint16 y3, Uint32 color)
2444 int filledTrigonRGBA(SDL_Renderer * renderer, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Sint16 x3, Sint16 y3,
2445 Uint8 r, Uint8 g, Uint8 b, Uint8 a)
2473 int polygonColor(SDL_Renderer * renderer,
const Sint16 * vx,
const Sint16 * vy,
int n, Uint32 color)
2475 Uint8 *c = (Uint8 *)&color;
2476 return polygonRGBA(renderer, vx, vy, n, c[0], c[1], c[2], c[3]);
2489 int polygon(SDL_Renderer * renderer,
const Sint16 * vx,
const Sint16 * vy,
int n)
2519 points = (SDL_Point*)malloc(
sizeof(SDL_Point) * nn);
2526 points[i].x = vx[i];
2527 points[i].y = vy[i];
2529 points[n].x = vx[0];
2530 points[n].y = vy[0];
2535 result |= SDL_RenderDrawLines(renderer, points, nn);
2555 int polygonRGBA(SDL_Renderer * renderer,
const Sint16 * vx,
const Sint16 * vy,
int n, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
2561 const Sint16 *x1, *y1, *x2, *y2;
2592 result |= SDL_SetRenderDrawBlendMode(renderer, (a == 255) ? SDL_BLENDMODE_NONE : SDL_BLENDMODE_BLEND);
2593 result |= SDL_SetRenderDrawColor(renderer, r, g, b, a);
2598 result |=
polygon(renderer, vx, vy, n);
2616 int aapolygonColor(SDL_Renderer * renderer,
const Sint16 * vx,
const Sint16 * vy,
int n, Uint32 color)
2618 Uint8 *c = (Uint8 *)&color;
2619 return aapolygonRGBA(renderer, vx, vy, n, c[0], c[1], c[2], c[3]);
2636 int aapolygonRGBA(SDL_Renderer * renderer,
const Sint16 * vx,
const Sint16 * vy,
int n, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
2640 const Sint16 *x1, *y1, *x2, *y2;
2671 for (i = 1; i < n; i++) {
2672 result |=
_aalineRGBA(renderer, *x1, *y1, *x2, *y2, r, g, b, a, 0);
2679 result |=
_aalineRGBA(renderer, *x1, *y1, *vx, *vy, r, g, b, a, 0);
2696 return (*(
const int *) a) - (*(
const int *) b);
2704 static int *gfxPrimitivesPolyIntsGlobal = NULL;
2711 static int gfxPrimitivesPolyAllocatedGlobal = 0;
2731 int filledPolygonRGBAMT(SDL_Renderer * renderer,
const Sint16 * vx,
const Sint16 * vy,
int n, Uint8 r, Uint8 g, Uint8 b, Uint8 a,
int **polyInts,
int *polyAllocated)
2741 int *gfxPrimitivesPolyInts = NULL;
2742 int *gfxPrimitivesPolyIntsNew = NULL;
2743 int gfxPrimitivesPolyAllocated = 0;
2765 if ((polyInts==NULL) || (polyAllocated==NULL)) {
2767 gfxPrimitivesPolyInts = gfxPrimitivesPolyIntsGlobal;
2768 gfxPrimitivesPolyAllocated = gfxPrimitivesPolyAllocatedGlobal;
2771 gfxPrimitivesPolyInts = *polyInts;
2772 gfxPrimitivesPolyAllocated = *polyAllocated;
2778 if (!gfxPrimitivesPolyAllocated) {
2779 gfxPrimitivesPolyInts = (
int *) malloc(
sizeof(
int) * n);
2780 gfxPrimitivesPolyAllocated = n;
2782 if (gfxPrimitivesPolyAllocated < n) {
2783 gfxPrimitivesPolyIntsNew = (
int *) realloc(gfxPrimitivesPolyInts,
sizeof(
int) * n);
2784 if (!gfxPrimitivesPolyIntsNew) {
2785 if (!gfxPrimitivesPolyInts) {
2786 free(gfxPrimitivesPolyInts);
2787 gfxPrimitivesPolyInts = NULL;
2789 gfxPrimitivesPolyAllocated = 0;
2791 gfxPrimitivesPolyInts = gfxPrimitivesPolyIntsNew;
2792 gfxPrimitivesPolyAllocated = n;
2800 if (gfxPrimitivesPolyInts==NULL) {
2801 gfxPrimitivesPolyAllocated = 0;
2807 if ((polyInts==NULL) || (polyAllocated==NULL)) {
2808 gfxPrimitivesPolyIntsGlobal = gfxPrimitivesPolyInts;
2809 gfxPrimitivesPolyAllocatedGlobal = gfxPrimitivesPolyAllocated;
2811 *polyInts = gfxPrimitivesPolyInts;
2812 *polyAllocated = gfxPrimitivesPolyAllocated;
2818 if (gfxPrimitivesPolyInts==NULL) {
2827 for (i = 1; (i < n); i++) {
2830 }
else if (vy[i] > maxy) {
2839 for (y = miny; (y <= maxy); y++) {
2841 for (i = 0; (i < n); i++) {
2854 }
else if (y1 > y2) {
2862 if ( ((y >= y1) && (y < y2)) || ((y == maxy) && (y > y1) && (y <= y2)) ) {
2863 gfxPrimitivesPolyInts[ints++] = ((65536 * (y - y1)) / (y2 - y1)) * (x2 - x1) + (65536 * x1);
2873 result |= SDL_SetRenderDrawBlendMode(renderer, (a == 255) ? SDL_BLENDMODE_NONE : SDL_BLENDMODE_BLEND);
2874 result |= SDL_SetRenderDrawColor(renderer, r, g, b, a);
2876 for (i = 0; (i < ints); i += 2) {
2877 xa = gfxPrimitivesPolyInts[i] + 1;
2878 xa = (xa >> 16) + ((xa & 32768) >> 15);
2879 xb = gfxPrimitivesPolyInts[i+1] - 1;
2880 xb = (xb >> 16) + ((xb & 32768) >> 15);
2881 result |=
hline(renderer, xa, xb, y);
2899 int filledPolygonColor(SDL_Renderer * renderer,
const Sint16 * vx,
const Sint16 * vy,
int n, Uint32 color)
2901 Uint8 *c = (Uint8 *)&color;
2919 int filledPolygonRGBA(SDL_Renderer * renderer,
const Sint16 * vx,
const Sint16 * vy,
int n, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
2941 int _HLineTextured(SDL_Renderer *renderer, Sint16 x1, Sint16 x2, Sint16 y, SDL_Texture *texture,
int texture_w,
int texture_h,
int texture_dx,
int texture_dy)
2946 int texture_x_walker;
2947 int texture_y_start;
2948 SDL_Rect source_rect,dst_rect;
2949 int pixels_written,write_width;
2968 texture_x_walker = (x1 - texture_dx) % texture_w;
2969 if (texture_x_walker < 0){
2970 texture_x_walker = texture_w + texture_x_walker ;
2973 texture_y_start = (y + texture_dy) % texture_h;
2974 if (texture_y_start < 0){
2975 texture_y_start = texture_h + texture_y_start;
2979 source_rect.y = texture_y_start;
2980 source_rect.x = texture_x_walker;
2989 if (w <= texture_w -texture_x_walker){
2991 source_rect.x = texture_x_walker;
2993 dst_rect.w = source_rect.w;
2994 result = (SDL_RenderCopy(renderer, texture, &source_rect, &dst_rect) == 0);
2998 pixels_written = texture_w - texture_x_walker;
2999 source_rect.w = pixels_written;
3000 source_rect.x = texture_x_walker;
3002 dst_rect.w = source_rect.w;
3003 result |= (SDL_RenderCopy(renderer, texture, &source_rect, &dst_rect) == 0);
3004 write_width = texture_w;
3009 while (pixels_written < w){
3010 if (write_width >= w - pixels_written) {
3011 write_width = w - pixels_written;
3013 source_rect.w = write_width;
3014 dst_rect.x = x1 + pixels_written;
3015 dst_rect.w = source_rect.w;
3016 result |= (SDL_RenderCopy(renderer, texture, &source_rect, &dst_rect) == 0);
3017 pixels_written += write_width;
3041 SDL_Surface * texture,
int texture_dx,
int texture_dy,
int **polyInts,
int *polyAllocated)
3046 int minx,maxx,miny, maxy;
3051 int *gfxPrimitivesPolyInts = NULL;
3052 int *gfxPrimitivesPolyIntsTemp = NULL;
3053 int gfxPrimitivesPolyAllocated = 0;
3054 SDL_Texture *textureAsTexture = NULL;
3066 if ((polyInts==NULL) || (polyAllocated==NULL)) {
3068 gfxPrimitivesPolyInts = gfxPrimitivesPolyIntsGlobal;
3069 gfxPrimitivesPolyAllocated = gfxPrimitivesPolyAllocatedGlobal;
3072 gfxPrimitivesPolyInts = *polyInts;
3073 gfxPrimitivesPolyAllocated = *polyAllocated;
3079 if (!gfxPrimitivesPolyAllocated) {
3080 gfxPrimitivesPolyInts = (
int *) malloc(
sizeof(
int) * n);
3081 gfxPrimitivesPolyAllocated = n;
3083 if (gfxPrimitivesPolyAllocated < n) {
3084 gfxPrimitivesPolyIntsTemp = (
int *) realloc(gfxPrimitivesPolyInts,
sizeof(
int) * n);
3085 if (gfxPrimitivesPolyIntsTemp == NULL) {
3089 gfxPrimitivesPolyInts = gfxPrimitivesPolyIntsTemp;
3090 gfxPrimitivesPolyAllocated = n;
3097 if (gfxPrimitivesPolyInts==NULL) {
3098 gfxPrimitivesPolyAllocated = 0;
3104 if ((polyInts==NULL) || (polyAllocated==NULL)) {
3105 gfxPrimitivesPolyIntsGlobal = gfxPrimitivesPolyInts;
3106 gfxPrimitivesPolyAllocatedGlobal = gfxPrimitivesPolyAllocated;
3108 *polyInts = gfxPrimitivesPolyInts;
3109 *polyAllocated = gfxPrimitivesPolyAllocated;
3115 if (gfxPrimitivesPolyInts==NULL) {
3126 for (i = 1; (i < n); i++) {
3129 }
else if (vy[i] > maxy) {
3134 }
else if (vx[i] > maxx) {
3140 textureAsTexture = SDL_CreateTextureFromSurface(renderer, texture);
3141 if (textureAsTexture == NULL)
3145 SDL_SetTextureBlendMode(textureAsTexture, SDL_BLENDMODE_BLEND);
3151 for (y = miny; (y <= maxy); y++) {
3153 for (i = 0; (i < n); i++) {
3166 }
else if (y1 > y2) {
3174 if ( ((y >= y1) && (y < y2)) || ((y == maxy) && (y > y1) && (y <= y2)) ) {
3175 gfxPrimitivesPolyInts[ints++] = ((65536 * (y - y1)) / (y2 - y1)) * (x2 - x1) + (65536 * x1);
3181 for (i = 0; (i < ints); i += 2) {
3182 xa = gfxPrimitivesPolyInts[i] + 1;
3183 xa = (xa >> 16) + ((xa & 32768) >> 15);
3184 xb = gfxPrimitivesPolyInts[i+1] - 1;
3185 xb = (xb >> 16) + ((xb & 32768) >> 15);
3186 result |=
_HLineTextured(renderer, xa, xb, y, textureAsTexture, texture->w, texture->h, texture_dx, texture_dy);
3190 SDL_RenderPresent(renderer);
3191 SDL_DestroyTexture(textureAsTexture);
3212 int texturedPolygon(SDL_Renderer *renderer,
const Sint16 * vx,
const Sint16 * vy,
int n, SDL_Surface *texture,
int texture_dx,
int texture_dy)
3217 return (
texturedPolygonMT(renderer, vx, vy, n, texture, texture_dx, texture_dy, NULL, NULL));
3225 static SDL_Texture *gfxPrimitivesFont[256];
3230 static const unsigned char *currentFontdata = gfxPrimitivesFontdata;
3235 static Uint32 charWidth = 8;
3240 static Uint32 charHeight = 8;
3245 static Uint32 charWidthLocal = 8;
3250 static Uint32 charHeightLocal = 8;
3255 static Uint32 charPitch = 1;
3260 static Uint32 charRotation = 0;
3265 static Uint32 charSize = 8;
3284 if ((fontdata) && (cw) && (ch)) {
3285 currentFontdata = (
unsigned char *)fontdata;
3289 currentFontdata = gfxPrimitivesFontdata;
3294 charPitch = (charWidth+7)/8;
3295 charSize = charPitch * charHeight;
3298 if ((charRotation==1) || (charRotation==3))
3300 charWidthLocal = charHeight;
3301 charHeightLocal = charWidth;
3305 charWidthLocal = charWidth;
3306 charHeightLocal = charHeight;
3310 for (i = 0; i < 256; i++) {
3311 if (gfxPrimitivesFont[i]) {
3312 SDL_DestroyTexture(gfxPrimitivesFont[i]);
3313 gfxPrimitivesFont[i] = NULL;
3330 rotation = rotation & 3;
3331 if (charRotation != rotation)
3334 charRotation = rotation;
3337 if ((charRotation==1) || (charRotation==3))
3339 charWidthLocal = charHeight;
3340 charHeightLocal = charWidth;
3344 charWidthLocal = charWidth;
3345 charHeightLocal = charHeight;
3349 for (i = 0; i < 256; i++) {
3350 if (gfxPrimitivesFont[i]) {
3351 SDL_DestroyTexture(gfxPrimitivesFont[i]);
3352 gfxPrimitivesFont[i] = NULL;
3372 int characterRGBA(SDL_Renderer *renderer, Sint16 x, Sint16 y,
char c, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
3378 const unsigned char *charpos;
3383 SDL_Surface *character;
3384 SDL_Surface *rotatedCharacter;
3392 srect.w = charWidthLocal;
3393 srect.h = charHeightLocal;
3400 drect.w = charWidthLocal;
3401 drect.h = charHeightLocal;
3404 ci = (
unsigned char) c;
3410 if (gfxPrimitivesFont[ci] == NULL) {
3414 character = SDL_CreateRGBSurface(SDL_SWSURFACE,
3415 charWidth, charHeight, 32,
3416 0xFF000000, 0x00FF0000, 0x0000FF00, 0x000000FF);
3417 if (character == NULL) {
3421 charpos = currentFontdata + ci * charSize;
3422 linepos = (Uint8 *)character->pixels;
3423 pitch = character->pitch;
3429 for (iy = 0; iy < charHeight; iy++) {
3432 for (ix = 0; ix < charWidth; ix++) {
3433 if (!(mask >>= 1)) {
3438 *(Uint32 *)curpos = 0xffffffff;
3440 *(Uint32 *)curpos = 0;
3451 SDL_FreeSurface(character);
3452 character = rotatedCharacter;
3456 gfxPrimitivesFont[ci] = SDL_CreateTextureFromSurface(renderer, character);
3457 SDL_FreeSurface(character);
3462 if (gfxPrimitivesFont[ci] == NULL) {
3471 result |= SDL_SetTextureColorMod(gfxPrimitivesFont[ci], r, g, b);
3472 result |= SDL_SetTextureAlphaMod(gfxPrimitivesFont[ci], a);
3477 result |= SDL_RenderCopy(renderer, gfxPrimitivesFont[ci], &srect, &drect);
3494 int characterColor(SDL_Renderer * renderer, Sint16 x, Sint16 y,
char c, Uint32 color)
3496 Uint8 *co = (Uint8 *)&color;
3497 return characterRGBA(renderer, x, y, c, co[0], co[1], co[2], co[3]);
3515 int stringColor(SDL_Renderer * renderer, Sint16 x, Sint16 y,
const char *s, Uint32 color)
3517 Uint8 *c = (Uint8 *)&color;
3518 return stringRGBA(renderer, x, y, s, c[0], c[1], c[2], c[3]);
3535 int stringRGBA(SDL_Renderer * renderer, Sint16 x, Sint16 y,
const char *s, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
3540 const char *curchar = s;
3542 while (*curchar && !result) {
3543 result |=
characterRGBA(renderer, curx, cury, *curchar, r, g, b, a);
3544 switch (charRotation)
3547 curx += charWidthLocal;
3550 curx -= charWidthLocal;
3553 cury += charHeightLocal;
3556 cury -= charHeightLocal;
3580 double blend,muk,munk;
3586 if (t>=(
double)ndata) {
3587 return(data[ndata-1]);
3597 munk = pow(1-mu,(
double)n);
3598 for (k=0;k<=n;k++) {
3609 blend /= (double)kn;
3613 blend /= (double)nkn;
3617 result += data[k] * blend;
3635 int bezierColor(SDL_Renderer * renderer,
const Sint16 * vx,
const Sint16 * vy,
int n,
int s, Uint32 color)
3637 Uint8 *c = (Uint8 *)&color;
3638 return bezierRGBA(renderer, vx, vy, n, s, c[0], c[1], c[2], c[3]);
3656 int bezierRGBA(SDL_Renderer * renderer,
const Sint16 * vx,
const Sint16 * vy,
int n,
int s, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
3660 double *x, *y, t, stepsize;
3661 Sint16 x1, y1, x2, y2;
3676 stepsize=(double)1.0/(
double)s;
3679 if ((x=(
double *)malloc(
sizeof(
double)*(n+1)))==NULL) {
3682 if ((y=(
double *)malloc(
sizeof(
double)*(n+1)))==NULL) {
3686 for (i=0; i<n; i++) {
3697 result |= SDL_SetRenderDrawBlendMode(renderer, (a == 255) ? SDL_BLENDMODE_NONE : SDL_BLENDMODE_BLEND);
3698 result |= SDL_SetRenderDrawColor(renderer, r, g, b, a);
3706 for (i = 0; i <= (n*s); i++) {
3710 result |=
line(renderer, x1, y1, x2, y2);
3736 int thickLineColor(SDL_Renderer *renderer, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Uint8 width, Uint32 color)
3738 Uint8 *c = (Uint8 *)&color;
3739 return thickLineRGBA(renderer, x1, y1, x2, y2, width, c[0], c[1], c[2], c[3]);
3758 int thickLineRGBA(SDL_Renderer *renderer, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Uint8 width, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
3761 double dx, dy, dx1, dy1, dx2, dy2;
3762 double l, wl2, nx, ny, ang, adj;
3763 Sint16 px[4], py[4];
3765 if (renderer == NULL) {
3774 if ((x1 == x2) && (y1 == y2)) {
3776 return boxRGBA(renderer, x1 - wh, y1 - wh, x2 + width, y2 + width, r, g, b, a);
3781 return lineRGBA(renderer, x1, y1, x2, y2, r, g, b, a);
3785 dx = (double)(x2 - x1);
3786 dy = (double)(y2 - y1);
3787 l = SDL_sqrt(dx*dx + dy*dy);
3788 ang = SDL_atan2(dx, dy);
3789 adj = 0.1 + 0.9 * SDL_fabs(SDL_cos(2.0 * ang));
3790 wl2 = ((double)width - adj)/(2.0 * l);
3799 px[0] = (Sint16)(dx1 + ny);
3800 px[1] = (Sint16)(dx1 - ny);
3801 px[2] = (Sint16)(dx2 - ny);
3802 px[3] = (Sint16)(dx2 + ny);
3803 py[0] = (Sint16)(dy1 - nx);
3804 py[1] = (Sint16)(dy1 + nx);
3805 py[2] = (Sint16)(dy2 + nx);
3806 py[3] = (Sint16)(dy2 - nx);
int polygonColor(SDL_Renderer *renderer, const Sint16 *vx, const Sint16 *vy, int n, Uint32 color)
Draw polygon with alpha blending.
int filledPieColor(SDL_Renderer *renderer, Sint16 x, Sint16 y, Sint16 rad, Sint16 start, Sint16 end, Uint32 color)
Draw filled pie with alpha blending.
int line(SDL_Renderer *renderer, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2)
Draw line with alpha blending using the currently set color.
int _drawQuadrants(SDL_Renderer *renderer, Sint16 x, Sint16 y, Sint16 dx, Sint16 dy, Sint32 f)
Internal function to draw pixels or lines in 4 quadrants.
int filledPolygonRGBAMT(SDL_Renderer *renderer, const Sint16 *vx, const Sint16 *vy, int n, Uint8 r, Uint8 g, Uint8 b, Uint8 a, int **polyInts, int *polyAllocated)
Draw filled polygon with alpha blending (multi-threaded capable).
int roundedBoxRGBA(SDL_Renderer *renderer, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Sint16 rad, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
Draw rounded-corner box (filled rectangle) with blending.
int boxColor(SDL_Renderer *renderer, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Uint32 color)
Draw box (filled rectangle) with blending.
int pixelColor(SDL_Renderer *renderer, Sint16 x, Sint16 y, Uint32 color)
Draw pixel with blending enabled if a<255.
The structure passed to the internal Murphy iterator.
int ellipseRGBA(SDL_Renderer *renderer, Sint16 x, Sint16 y, Sint16 rx, Sint16 ry, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
Draw ellipse with blending.
int filledEllipseRGBA(SDL_Renderer *renderer, Sint16 x, Sint16 y, Sint16 rx, Sint16 ry, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
Draw filled ellipse with blending.
int trigonRGBA(SDL_Renderer *renderer, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Sint16 x3, Sint16 y3, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
Draw trigon (triangle outline) with alpha blending.
The structure passed to the internal Bresenham iterator.
int arcColor(SDL_Renderer *renderer, Sint16 x, Sint16 y, Sint16 rad, Sint16 start, Sint16 end, Uint32 color)
Arc with blending.
int aatrigonColor(SDL_Renderer *renderer, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Sint16 x3, Sint16 y3, Uint32 color)
Draw anti-aliased trigon (triangle outline) with alpha blending.
int filledPolygonColor(SDL_Renderer *renderer, const Sint16 *vx, const Sint16 *vy, int n, Uint32 color)
Draw filled polygon with alpha blending.
void gfxPrimitivesSetFont(const void *fontdata, Uint32 cw, Uint32 ch)
Sets or resets the current global font data.
int pixelRGBA(SDL_Renderer *renderer, Sint16 x, Sint16 y, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
Draw pixel with blending enabled if a<255.
int ellipseColor(SDL_Renderer *renderer, Sint16 x, Sint16 y, Sint16 rx, Sint16 ry, Uint32 color)
Draw ellipse with blending.
int roundedRectangleColor(SDL_Renderer *renderer, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Sint16 rad, Uint32 color)
Draw rounded-corner rectangle with blending.
int boxRGBA(SDL_Renderer *renderer, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
Draw box (filled rectangle) with blending.
int roundedRectangleRGBA(SDL_Renderer *renderer, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Sint16 rad, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
Draw rounded-corner rectangle with blending.
int polygon(SDL_Renderer *renderer, const Sint16 *vx, const Sint16 *vy, int n)
Draw polygon with the currently set color and blend mode.
int circleColor(SDL_Renderer *renderer, Sint16 x, Sint16 y, Sint16 rad, Uint32 color)
Draw circle with blending.
int hlineRGBA(SDL_Renderer *renderer, Sint16 x1, Sint16 x2, Sint16 y, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
Draw horizontal line with blending.
int rectangleColor(SDL_Renderer *renderer, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Uint32 color)
Draw rectangle with blending.
int texturedPolygon(SDL_Renderer *renderer, const Sint16 *vx, const Sint16 *vy, int n, SDL_Surface *texture, int texture_dx, int texture_dy)
Draws a polygon filled with the given texture.
int stringRGBA(SDL_Renderer *renderer, Sint16 x, Sint16 y, const char *s, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
Draw a string in the currently set font.
int aapolygonColor(SDL_Renderer *renderer, const Sint16 *vx, const Sint16 *vy, int n, Uint32 color)
Draw anti-aliased polygon with alpha blending.
int pixelRGBAWeight(SDL_Renderer *renderer, Sint16 x, Sint16 y, Uint8 r, Uint8 g, Uint8 b, Uint8 a, Uint32 weight)
Draw pixel with blending enabled and using alpha weight on color.
int pixel(SDL_Renderer *renderer, Sint16 x, Sint16 y)
Draw pixel in currently set color.
int aacircleColor(SDL_Renderer *renderer, Sint16 x, Sint16 y, Sint16 rad, Uint32 color)
Draw anti-aliased circle with blending.
int filledCircleColor(SDL_Renderer *renderer, Sint16 x, Sint16 y, Sint16 rad, Uint32 color)
Draw filled circle with blending.
int lineRGBA(SDL_Renderer *renderer, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
Draw line with alpha blending.
int aaellipseRGBA(SDL_Renderer *renderer, Sint16 x, Sint16 y, Sint16 rx, Sint16 ry, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
Draw anti-aliased ellipse with blending.
int filledTrigonRGBA(SDL_Renderer *renderer, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Sint16 x3, Sint16 y3, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
Draw filled trigon (triangle) with alpha blending.
int _HLineTextured(SDL_Renderer *renderer, Sint16 x1, Sint16 x2, Sint16 y, SDL_Texture *texture, int texture_w, int texture_h, int texture_dx, int texture_dy)
Internal function to draw a textured horizontal line.
double _evaluateBezier(double *data, int ndata, double t)
Internal function to calculate bezier interpolator of data array with ndata values at position 't'...
int aalineColor(SDL_Renderer *renderer, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Uint32 color)
Draw anti-aliased line with alpha blending.
void gfxPrimitivesSetFontRotation(Uint32 rotation)
Sets current global font character rotation steps.
int bezierRGBA(SDL_Renderer *renderer, const Sint16 *vx, const Sint16 *vy, int n, int s, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
Draw a bezier curve with alpha blending.
int lineColor(SDL_Renderer *renderer, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Uint32 color)
Draw line with alpha blending.
int thickLineRGBA(SDL_Renderer *renderer, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Uint8 width, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
Draw a thick line with alpha blending.
int circleRGBA(SDL_Renderer *renderer, Sint16 x, Sint16 y, Sint16 rad, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
Draw circle with blending.
int _gfxPrimitivesCompareInt(const void *a, const void *b)
Internal helper qsort callback functions used in filled polygon drawing.
int _ellipseRGBA(SDL_Renderer *renderer, Sint16 x, Sint16 y, Sint16 rx, Sint16 ry, Uint8 r, Uint8 g, Uint8 b, Uint8 a, Sint32 f)
int hlineColor(SDL_Renderer *renderer, Sint16 x1, Sint16 x2, Sint16 y, Uint32 color)
Draw horizontal line with blending.
int stringColor(SDL_Renderer *renderer, Sint16 x, Sint16 y, const char *s, Uint32 color)
Draw a string in the currently set font.
int rectangleRGBA(SDL_Renderer *renderer, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
Draw rectangle with blending.
int polygonRGBA(SDL_Renderer *renderer, const Sint16 *vx, const Sint16 *vy, int n, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
Draw polygon with alpha blending.
int vline(SDL_Renderer *renderer, Sint16 x, Sint16 y1, Sint16 y2)
Draw vertical line in currently set color.
int aacircleRGBA(SDL_Renderer *renderer, Sint16 x, Sint16 y, Sint16 rad, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
Draw anti-aliased circle with blending.
int filledCircleRGBA(SDL_Renderer *renderer, Sint16 x, Sint16 y, Sint16 rad, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
Draw filled circle with blending.
int filledTrigonColor(SDL_Renderer *renderer, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Sint16 x3, Sint16 y3, Uint32 color)
Draw filled trigon (triangle) with alpha blending.
int characterRGBA(SDL_Renderer *renderer, Sint16 x, Sint16 y, char c, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
Draw a character of the currently set font.
int aapolygonRGBA(SDL_Renderer *renderer, const Sint16 *vx, const Sint16 *vy, int n, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
Draw anti-aliased polygon with alpha blending.
int _aalineRGBA(SDL_Renderer *renderer, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Uint8 r, Uint8 g, Uint8 b, Uint8 a, int draw_endpoint)
Internal function to draw anti-aliased line with alpha blending and endpoint control.
int trigonColor(SDL_Renderer *renderer, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Sint16 x3, Sint16 y3, Uint32 color)
Draw trigon (triangle outline) with alpha blending.
int aatrigonRGBA(SDL_Renderer *renderer, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Sint16 x3, Sint16 y3, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
Draw anti-aliased trigon (triangle outline) with alpha blending.
int thickLineColor(SDL_Renderer *renderer, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Uint8 width, Uint32 color)
Draw a thick line with alpha blending.
int texturedPolygonMT(SDL_Renderer *renderer, const Sint16 *vx, const Sint16 *vy, int n, SDL_Surface *texture, int texture_dx, int texture_dy, int **polyInts, int *polyAllocated)
Draws a polygon filled with the given texture (Multi-Threading Capable).
int characterColor(SDL_Renderer *renderer, Sint16 x, Sint16 y, char c, Uint32 color)
Draw a character of the currently set font.
int bezierColor(SDL_Renderer *renderer, const Sint16 *vx, const Sint16 *vy, int n, int s, Uint32 color)
Draw a bezier curve with alpha blending.
int _pieRGBA(SDL_Renderer *renderer, Sint16 x, Sint16 y, Sint16 rad, Sint16 start, Sint16 end, Uint8 r, Uint8 g, Uint8 b, Uint8 a, Uint8 filled)
Internal float (low-speed) pie-calc implementation by drawing polygons.
int filledEllipseColor(SDL_Renderer *renderer, Sint16 x, Sint16 y, Sint16 rx, Sint16 ry, Uint32 color)
Draw filled ellipse with blending.
int hline(SDL_Renderer *renderer, Sint16 x1, Sint16 x2, Sint16 y)
Draw horizontal line in currently set color.
int filledPolygonRGBA(SDL_Renderer *renderer, const Sint16 *vx, const Sint16 *vy, int n, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
Draw filled polygon with alpha blending.
int pieColor(SDL_Renderer *renderer, Sint16 x, Sint16 y, Sint16 rad, Sint16 start, Sint16 end, Uint32 color)
Draw pie (outline) with alpha blending.
int filledPieRGBA(SDL_Renderer *renderer, Sint16 x, Sint16 y, Sint16 rad, Sint16 start, Sint16 end, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
Draw filled pie with alpha blending.
int vlineRGBA(SDL_Renderer *renderer, Sint16 x, Sint16 y1, Sint16 y2, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
Draw vertical line with blending.
int aalineRGBA(SDL_Renderer *renderer, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
Draw anti-aliased line with alpha blending.
int roundedBoxColor(SDL_Renderer *renderer, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Sint16 rad, Uint32 color)
Draw rounded-corner box (filled rectangle) with blending.
int pieRGBA(SDL_Renderer *renderer, Sint16 x, Sint16 y, Sint16 rad, Sint16 start, Sint16 end, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
Draw pie (outline) with alpha blending.
int aaellipseColor(SDL_Renderer *renderer, Sint16 x, Sint16 y, Sint16 rx, Sint16 ry, Uint32 color)
Draw anti-aliased ellipse with blending.
int vlineColor(SDL_Renderer *renderer, Sint16 x, Sint16 y1, Sint16 y2, Uint32 color)
Draw vertical line with blending.
int arcRGBA(SDL_Renderer *renderer, Sint16 x, Sint16 y, Sint16 rad, Sint16 start, Sint16 end, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
Arc with blending.
SDL_Surface * rotateSurface90Degrees(SDL_Surface *src, int numClockwiseTurns)
Rotates a 8/16/24/32 bit surface in increments of 90 degrees.
#define DEFAULT_ELLIPSE_OVERSCAN
Internal function to draw ellipse or filled ellipse with blending.