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);
217 int vlineColor(SDL_Renderer * renderer, Sint16 x, Sint16 y1, Sint16 y2, Uint32 color)
219 Uint8 *c = (Uint8 *)&color;
220 return vlineRGBA(renderer, x, y1, y2, c[0], c[1], c[2], c[3]);
237 int vlineRGBA(SDL_Renderer * renderer, Sint16 x, Sint16 y1, Sint16 y2, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
240 result |= SDL_SetRenderDrawBlendMode(renderer, (a == 255) ? SDL_BLENDMODE_NONE : SDL_BLENDMODE_BLEND);
241 result |= SDL_SetRenderDrawColor(renderer, r, g, b, a);
242 result |= SDL_RenderDrawLine(renderer, x, y1, x, y2);
260 int rectangleColor(SDL_Renderer * renderer, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Uint32 color)
262 Uint8 *c = (Uint8 *)&color;
263 return rectangleRGBA(renderer, x1, y1, x2, y2, c[0], c[1], c[2], c[3]);
281 int rectangleRGBA(SDL_Renderer * renderer, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
292 return (
pixelRGBA(renderer, x1, y1, r, g, b, a));
294 return (
vlineRGBA(renderer, x1, y1, y2, r, g, b, a));
298 return (
hlineRGBA(renderer, x1, x2, y1, r, g, b, a));
332 result |= SDL_SetRenderDrawBlendMode(renderer, (a == 255) ? SDL_BLENDMODE_NONE : SDL_BLENDMODE_BLEND);
333 result |= SDL_SetRenderDrawColor(renderer, r, g, b, a);
334 result |= SDL_RenderDrawRect(renderer, &rect);
353 int roundedRectangleColor(SDL_Renderer * renderer, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Sint16 rad, Uint32 color)
355 Uint8 *c = (Uint8 *)&color;
375 int roundedRectangleRGBA(SDL_Renderer * renderer, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Sint16 rad, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
386 if (renderer == NULL)
410 return (
pixelRGBA(renderer, x1, y1, r, g, b, a));
412 return (
vlineRGBA(renderer, x1, y1, y2, r, g, b, a));
416 return (
hlineRGBA(renderer, x1, x2, y1, r, g, b, a));
463 result |=
arcRGBA(renderer, xx1, yy1, rad, 180, 270, r, g, b, a);
464 result |=
arcRGBA(renderer, xx2, yy1, rad, 270, 360, r, g, b, a);
465 result |=
arcRGBA(renderer, xx1, yy2, rad, 90, 180, r, g, b, a);
466 result |=
arcRGBA(renderer, xx2, yy2, rad, 0, 90, r, g, b, a);
472 result |=
hlineRGBA(renderer, xx1, xx2, y1, r, g, b, a);
473 result |=
hlineRGBA(renderer, xx1, xx2, y2, r, g, b, a);
476 result |=
vlineRGBA(renderer, x1, yy1, yy2, r, g, b, a);
477 result |=
vlineRGBA(renderer, x2, yy1, yy2, r, g, b, a);
498 int roundedBoxColor(SDL_Renderer * renderer, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Sint16 rad, Uint32 color)
500 Uint8 *c = (Uint8 *)&color;
501 return roundedBoxRGBA(renderer, x1, y1, x2, y2, rad, c[0], c[1], c[2], c[3]);
521 Sint16 y2, Sint16 rad, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
524 Sint16 w, h, r2, tmp;
527 Sint16 ocx = (Sint16) 0xffff;
528 Sint16 ocy = (Sint16) 0xffff;
531 Sint16 d_se = -2 * rad + 5;
532 Sint16 xpcx, xmcx, xpcy, xmcy;
533 Sint16 ypcy, ymcy, ypcx, ymcx;
539 if (renderer == NULL)
563 return (
pixelRGBA(renderer, x1, y1, r, g, b, a));
565 return (
vlineRGBA(renderer, x1, y1, y2, r, g, b, a));
569 return (
hlineRGBA(renderer, x1, x2, y1, r, g, b, a));
614 dx = x2 - x1 - rad - rad;
615 dy = y2 - y1 - rad - rad;
621 result |= SDL_SetRenderDrawBlendMode(renderer, (a == 255) ? SDL_BLENDMODE_NONE : SDL_BLENDMODE_BLEND);
622 result |= SDL_SetRenderDrawColor(renderer, r, g, b, a);
636 result |=
hline(renderer, xmcx, xpcx + dx, ypcy + dy);
637 result |=
hline(renderer, xmcx, xpcx + dx, ymcy);
639 result |=
hline(renderer, xmcx, xpcx + dx, y);
648 result |=
hline(renderer, xmcy, xpcy + dx, ymcx);
649 result |=
hline(renderer, xmcy, xpcy + dx, ypcx + dy);
651 result |=
hline(renderer, xmcy, xpcy + dx, y);
674 if (dx > 0 && dy > 0) {
675 result |=
boxRGBA(renderer, x1, y1 + rad + 1, x2, y2 - rad, r, g, b, a);
695 int boxColor(SDL_Renderer * renderer, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Uint32 color)
697 Uint8 *c = (Uint8 *)&color;
698 return boxRGBA(renderer, x1, y1, x2, y2, c[0], c[1], c[2], c[3]);
716 int boxRGBA(SDL_Renderer * renderer, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
727 return (
pixelRGBA(renderer, x1, y1, r, g, b, a));
729 return (
vlineRGBA(renderer, x1, y1, y2, r, g, b, a));
733 return (
hlineRGBA(renderer, x1, x2, y1, r, g, b, a));
760 rect.w = x2 - x1 + 1;
761 rect.h = y2 - y1 + 1;
767 result |= SDL_SetRenderDrawBlendMode(renderer, (a == 255) ? SDL_BLENDMODE_NONE : SDL_BLENDMODE_BLEND);
768 result |= SDL_SetRenderDrawColor(renderer, r, g, b, a);
769 result |= SDL_RenderFillRect(renderer, &rect);
786 int line(SDL_Renderer * renderer, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2)
791 return SDL_RenderDrawLine(renderer, x1, y1, x2, y2);
806 int lineColor(SDL_Renderer * renderer, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Uint32 color)
808 Uint8 *c = (Uint8 *)&color;
809 return lineRGBA(renderer, x1, y1, x2, y2, c[0], c[1], c[2], c[3]);
827 int lineRGBA(SDL_Renderer * renderer, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
833 result |= SDL_SetRenderDrawBlendMode(renderer, (a == 255) ? SDL_BLENDMODE_NONE : SDL_BLENDMODE_BLEND);
834 result |= SDL_SetRenderDrawColor(renderer, r, g, b, a);
835 result |= SDL_RenderDrawLine(renderer, x1, y1, x2, y2);
867 int _aalineRGBA(SDL_Renderer * renderer, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Uint8 r, Uint8 g, Uint8 b, Uint8 a,
int draw_endpoint)
869 Sint32 xx0, yy0, xx1, yy1;
871 Uint32 intshift, erracc, erradj;
872 Uint32 erracctmp, wgt, wgtcompmask;
873 int dx, dy, tmp, xdir, y0p1, x0pxdir;
920 return (
vlineRGBA(renderer, x1, y1, y2, r, g, b, a));
923 return (
vlineRGBA(renderer, x1, yy0, yy0+dy, r, g, b, a));
925 return (
pixelRGBA(renderer, x1, y1, r, g, b, a));
928 }
else if (dy == 0) {
934 return (
hlineRGBA(renderer, x1, x2, y1, r, g, b, a));
937 return (
hlineRGBA(renderer, xx0, xx0+dx, y1, r, g, b, a));
939 return (
pixelRGBA(renderer, x1, y1, r, g, b, a));
942 }
else if ((dx == dy) && (draw_endpoint)) {
946 return (
lineRGBA(renderer, x1, y1, x2, y2, r, g, b, a));
973 result |=
pixelRGBA(renderer, x1, y1, r, g, b, a);
988 erradj = ((dx << 16) / dy) << 16;
993 x0pxdir = xx0 + xdir;
997 if (erracc <= erracctmp) {
1011 wgt = (erracc >> intshift) & 255;
1012 result |=
pixelRGBAWeight (renderer, xx0, yy0, r, g, b, a, 255 - wgt);
1026 erradj = ((dy << 16) / dx) << 16;
1036 if (erracc <= erracctmp) {
1049 wgt = (erracc >> intshift) & 255;
1050 result |=
pixelRGBAWeight (renderer, xx0, yy0, r, g, b, a, 255 - wgt);
1058 if (draw_endpoint) {
1063 result |=
pixelRGBA (renderer, x2, y2, r, g, b, a);
1081 int aalineColor(SDL_Renderer * renderer, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Uint32 color)
1083 Uint8 *c = (Uint8 *)&color;
1084 return _aalineRGBA(renderer, x1, y1, x2, y2, c[0], c[1], c[2], c[3], 1);
1102 int aalineRGBA(SDL_Renderer * renderer, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
1104 return _aalineRGBA(renderer, x1, y1, x2, y2, r, g, b, a, 1);
1120 int circleColor(SDL_Renderer * renderer, Sint16 x, Sint16 y, Sint16 rad, Uint32 color)
1122 Uint8 *c = (Uint8 *)&color;
1123 return ellipseRGBA(renderer, x, y, rad, rad, c[0], c[1], c[2], c[3]);
1140 int circleRGBA(SDL_Renderer * renderer, Sint16 x, Sint16 y, Sint16 rad, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
1142 return ellipseRGBA(renderer, x, y, rad, rad, r, g, b, a);
1160 int arcColor(SDL_Renderer * renderer, Sint16 x, Sint16 y, Sint16 rad, Sint16 start, Sint16 end, Uint32 color)
1162 Uint8 *c = (Uint8 *)&color;
1163 return arcRGBA(renderer, x, y, rad, start, end, c[0], c[1], c[2], c[3]);
1183 int arcRGBA(SDL_Renderer * renderer, Sint16 x, Sint16 y, Sint16 rad, Sint16 start, Sint16 end, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
1188 Sint16 df = 1 - rad;
1190 Sint16 d_se = -2 * rad + 5;
1191 Sint16 xpcx, xmcx, xpcy, xmcy;
1192 Sint16 ypcy, ymcy, ypcx, ymcx;
1194 int startoct, endoct, oct, stopval_start = 0, stopval_end = 0;
1195 double dstart, dend, temp = 0.;
1208 return (
pixelRGBA(renderer, x, y, r, g, b, a));
1235 while (start < 0) start += 360;
1236 while (end < 0) end += 360;
1241 startoct = start / 45;
1248 oct = (oct + 1) % 8;
1250 if (oct == startoct) {
1252 dstart = (double)start;
1257 temp = sin(dstart *
M_PI / 180.);
1261 temp = cos(dstart *
M_PI / 180.);
1265 temp = -cos(dstart *
M_PI / 180.);
1269 temp = -sin(dstart *
M_PI / 180.);
1273 stopval_start = (int)temp;
1280 if (oct % 2) drawoct |= (1 << oct);
1281 else drawoct &= 255 - (1 << oct);
1283 if (oct == endoct) {
1290 temp = sin(dend *
M_PI / 180);
1294 temp = cos(dend *
M_PI / 180);
1298 temp = -cos(dend *
M_PI / 180);
1302 temp = -sin(dend *
M_PI / 180);
1306 stopval_end = (int)temp;
1309 if (startoct == endoct) {
1317 drawoct &= 255 - (1 << oct);
1320 else if (oct % 2) drawoct &= 255 - (1 << oct);
1321 else drawoct |= (1 << oct);
1322 }
else if (oct != startoct) {
1323 drawoct |= (1 << oct);
1325 }
while (oct != endoct);
1333 result |= SDL_SetRenderDrawBlendMode(renderer, (a == 255) ? SDL_BLENDMODE_NONE : SDL_BLENDMODE_BLEND);
1334 result |= SDL_SetRenderDrawColor(renderer, r, g, b, a);
1347 if (drawoct & 4) result |=
pixel(renderer, xmcx, ypcy);
1348 if (drawoct & 2) result |=
pixel(renderer, xpcx, ypcy);
1349 if (drawoct & 32) result |=
pixel(renderer, xmcx, ymcy);
1350 if (drawoct & 64) result |=
pixel(renderer, xpcx, ymcy);
1352 if (drawoct & 96) result |=
pixel(renderer, x, ymcy);
1353 if (drawoct & 6) result |=
pixel(renderer, x, ypcy);
1358 if (cx > 0 && cx != cy) {
1361 if (drawoct & 8) result |=
pixel(renderer, xmcy, ypcx);
1362 if (drawoct & 1) result |=
pixel(renderer, xpcy, ypcx);
1363 if (drawoct & 16) result |=
pixel(renderer, xmcy, ymcx);
1364 if (drawoct & 128) result |=
pixel(renderer, xpcy, ymcx);
1365 }
else if (cx == 0) {
1366 if (drawoct & 24) result |=
pixel(renderer, xmcy, y);
1367 if (drawoct & 129) result |=
pixel(renderer, xpcy, y);
1373 if (stopval_start == cx) {
1376 if (drawoct & (1 << startoct)) drawoct &= 255 - (1 << startoct);
1377 else drawoct |= (1 << startoct);
1379 if (stopval_end == cx) {
1380 if (drawoct & (1 << endoct)) drawoct &= 255 - (1 << endoct);
1381 else drawoct |= (1 << endoct);
1416 int aacircleColor(SDL_Renderer * renderer, Sint16 x, Sint16 y, Sint16 rad, Uint32 color)
1418 Uint8 *c = (Uint8 *)&color;
1419 return aaellipseRGBA(renderer, x, y, rad, rad, c[0], c[1], c[2], c[3]);
1436 int aacircleRGBA(SDL_Renderer * renderer, Sint16 x, Sint16 y, Sint16 rad, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
1459 Uint8 *c = (Uint8 *)&color;
1477 int filledCircleRGBA(SDL_Renderer * renderer, Sint16 x, Sint16 y, Sint16 rad, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
1482 Sint16 ocx = (Sint16) 0xffff;
1483 Sint16 ocy = (Sint16) 0xffff;
1484 Sint16 df = 1 - rad;
1486 Sint16 d_se = -2 * rad + 5;
1487 Sint16 xpcx, xmcx, xpcy, xmcy;
1488 Sint16 ypcy, ymcy, ypcx, ymcx;
1501 return (
pixelRGBA(renderer, x, y, r, g, b, a));
1508 result |= SDL_SetRenderDrawBlendMode(renderer, (a == 255) ? SDL_BLENDMODE_NONE : SDL_BLENDMODE_BLEND);
1509 result |= SDL_SetRenderDrawColor(renderer, r, g, b, a);
1523 result |=
hline(renderer, xmcx, xpcx, ypcy);
1524 result |=
hline(renderer, xmcx, xpcx, ymcy);
1526 result |=
hline(renderer, xmcx, xpcx, y);
1535 result |=
hline(renderer, xmcy, xpcy, ymcx);
1536 result |=
hline(renderer, xmcy, xpcy, ypcx);
1538 result |=
hline(renderer, xmcy, xpcy, y);
1577 int ellipseColor(SDL_Renderer * renderer, Sint16 x, Sint16 y, Sint16 rx, Sint16 ry, Uint32 color)
1579 Uint8 *c = (Uint8 *)&color;
1580 return ellipseRGBA(renderer, x, y, rx, ry, c[0], c[1], c[2], c[3]);
1598 int ellipseRGBA(SDL_Renderer * renderer, Sint16 x, Sint16 y, Sint16 rx, Sint16 ry, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
1604 int xmh, xph, ypk, ymk;
1605 int xmi, xpi, ymj, ypj;
1606 int xmj, xpj, ymi, ypi;
1607 int xmk, xpk, ymh, yph;
1612 if ((rx < 0) || (ry < 0)) {
1620 return (
vlineRGBA(renderer, x, y - ry, y + ry, r, g, b, a));
1626 return (
hlineRGBA(renderer, x - rx, x + rx, y, r, g, b, a));
1633 result |= SDL_SetRenderDrawBlendMode(renderer, (a == 255) ? SDL_BLENDMODE_NONE : SDL_BLENDMODE_BLEND);
1634 result |= SDL_SetRenderDrawColor(renderer, r, g, b, a);
1639 oh = oi = oj = ok = 0xFFFF;
1654 if (((ok != k) && (oj != k)) || ((oj != j) && (ok != j)) || (k != j)) {
1660 result |=
pixel(renderer, xmh, ypk);
1661 result |=
pixel(renderer, xph, ypk);
1662 result |=
pixel(renderer, xmh, ymk);
1663 result |=
pixel(renderer, xph, ymk);
1665 result |=
pixel(renderer, xmh, y);
1666 result |=
pixel(renderer, xph, y);
1674 result |=
pixel(renderer, xmi, ypj);
1675 result |=
pixel(renderer, xpi, ypj);
1676 result |=
pixel(renderer, xmi, ymj);
1677 result |=
pixel(renderer, xpi, ymj);
1679 result |=
pixel(renderer, xmi, y);
1680 result |=
pixel(renderer, xpi, y);
1699 if (((oi != i) && (oh != i)) || ((oh != h) && (oi != h) && (i != h))) {
1705 result |=
pixel(renderer, xmj, ypi);
1706 result |=
pixel(renderer, xpj, ypi);
1707 result |=
pixel(renderer, xmj, ymi);
1708 result |=
pixel(renderer, xpj, ymi);
1710 result |=
pixel(renderer, xmj, y);
1711 result |=
pixel(renderer, xpj, y);
1719 result |=
pixel(renderer, xmk, yph);
1720 result |=
pixel(renderer, xpk, yph);
1721 result |=
pixel(renderer, xmk, ymh);
1722 result |=
pixel(renderer, xpk, ymh);
1724 result |=
pixel(renderer, xmk, y);
1725 result |=
pixel(renderer, xpk, y);
1742 #if defined(_MSC_VER) 1745 #include <emmintrin.h> 1746 static __inline
long 1749 return _mm_cvtss_si32(_mm_load_ss(&f));
1751 #elif defined(_M_IX86) 1763 #elif defined(_M_ARM) 1764 #include <armintr.h> 1765 #pragma warning(push) 1766 #pragma warning(disable: 4716) 1767 __declspec(naked)
long int 1775 #pragma warning(pop) 1777 #error lrint needed for MSVC on non X86/AMD64/ARM targets. 1793 int aaellipseColor(SDL_Renderer * renderer, Sint16 x, Sint16 y, Sint16 rx, Sint16 ry, Uint32 color)
1795 Uint8 *c = (Uint8 *)&color;
1796 return aaellipseRGBA(renderer, x, y, rx, ry, c[0], c[1], c[2], c[3]);
1814 int aaellipseRGBA(SDL_Renderer * renderer, Sint16 x, Sint16 y, Sint16 rx, Sint16 ry, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
1818 int a2, b2, ds, dt, dxt, t, s, d;
1819 Sint16 xp, yp, xs, ys, dyt, od, xx, yy, xc2, yc2;
1822 Uint8 weight, iweight;
1827 if ((rx < 0) || (ry < 0)) {
1835 return (
vlineRGBA(renderer, x, y - ry, y + ry, r, g, b, a));
1841 return (
hlineRGBA(renderer, x - rx, x + rx, y, r, g, b, a));
1854 sab = sqrt((
double)(a2 + b2));
1855 od = (Sint16)lrint(sab*0.01) + 1;
1856 dxt = (Sint16)lrint((
double)a2 / sab) + od;
1867 result |= SDL_SetRenderDrawBlendMode(renderer, (a == 255) ? SDL_BLENDMODE_NONE : SDL_BLENDMODE_BLEND);
1870 result |=
pixelRGBA(renderer, xp, yp, r, g, b, a);
1871 result |=
pixelRGBA(renderer, xc2 - xp, yp, r, g, b, a);
1872 result |=
pixelRGBA(renderer, xp, yc2 - yp, r, g, b, a);
1873 result |=
pixelRGBA(renderer, xc2 - xp, yc2 - yp, r, g, b, a);
1875 for (i = 1; i <= dxt; i++) {
1881 else if ((d - s - a2) > 0) {
1882 if ((2 * d - s - a2) >= 0)
1901 cp = (float) abs(d) / (float) abs(s);
1910 weight = (Uint8) (cp * 255);
1911 iweight = 255 - weight;
1932 dyt = (Sint16)lrint((
double)b2 / sab ) + od;
1934 for (i = 1; i <= dyt; i++) {
1940 else if ((d + t - b2) < 0) {
1941 if ((2 * d + t - b2) <= 0)
1960 cp = (float) abs(d) / (float) abs(t);
1969 weight = (Uint8) (cp * 255);
1970 iweight = 255 - weight;
2009 Uint8 *c = (Uint8 *)&color;
2028 int filledEllipseRGBA(SDL_Renderer * renderer, Sint16 x, Sint16 y, Sint16 rx, Sint16 ry, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
2042 if ((rx < 0) || (ry < 0)) {
2050 return (
vlineRGBA(renderer, x, y - ry, y + ry, r, g, b, a));
2056 return (
hlineRGBA(renderer, x - rx, x + rx, y, r, g, b, a));
2063 result |= SDL_SetRenderDrawBlendMode(renderer, (a == 255) ? SDL_BLENDMODE_NONE : SDL_BLENDMODE_BLEND);
2064 result |= SDL_SetRenderDrawColor(renderer, r, g, b, a);
2069 oh = oi = oj = ok = 0xFFFF;
2084 if ((ok != k) && (oj != k)) {
2088 result |=
hline(renderer, xmh, xph, y + k);
2089 result |=
hline(renderer, xmh, xph, y - k);
2091 result |=
hline(renderer, xmh, xph, y);
2095 if ((oj != j) && (ok != j) && (k != j)) {
2099 result |=
hline(renderer, xmi, xpi, y + j);
2100 result |=
hline(renderer, xmi, xpi, y - j);
2102 result |=
hline(renderer, xmi, xpi, y);
2121 if ((oi != i) && (oh != i)) {
2125 result |=
hline(renderer, xmj, xpj, y + i);
2126 result |=
hline(renderer, xmj, xpj, y - i);
2128 result |=
hline(renderer, xmj, xpj, y);
2132 if ((oh != h) && (oi != h) && (i != h)) {
2136 result |=
hline(renderer, xmk, xpk, y + h);
2137 result |=
hline(renderer, xmk, xpk, y - h);
2139 result |=
hline(renderer, xmk, xpk, y);
2175 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)
2178 double angle, start_angle, end_angle;
2194 start = start % 360;
2201 return (
pixelRGBA(renderer, x, y, r, g, b, a));
2208 deltaAngle = 3.0 / dr;
2209 start_angle = (double) start *(2.0 *
M_PI / 360.0);
2210 end_angle = (double) end *(2.0 *
M_PI / 360.0);
2212 end_angle += (2.0 *
M_PI);
2219 angle = start_angle;
2220 while (angle < end_angle) {
2221 angle += deltaAngle;
2226 vx = vy = (Sint16 *) malloc(2 *
sizeof(Uint16) * numpoints);
2239 angle = start_angle;
2240 vx[1] = x + (int) (dr * cos(angle));
2241 vy[1] = y + (int) (dr * sin(angle));
2245 result =
lineRGBA(renderer, vx[0], vy[0], vx[1], vy[1], r, g, b, a);
2251 angle = start_angle;
2252 while (angle < end_angle) {
2253 angle += deltaAngle;
2254 if (angle>end_angle)
2258 vx[i] = x + (int) (dr * cos(angle));
2259 vy[i] = y + (int) (dr * sin(angle));
2267 result =
polygonRGBA(renderer, vx, vy, numpoints, r, g, b, a);
2290 int pieColor(SDL_Renderer * renderer, Sint16 x, Sint16 y, Sint16 rad,
2291 Sint16 start, Sint16 end, Uint32 color)
2293 Uint8 *c = (Uint8 *)&color;
2294 return _pieRGBA(renderer, x, y, rad, start, end, c[0], c[1], c[2], c[3], 0);
2313 int pieRGBA(SDL_Renderer * renderer, Sint16 x, Sint16 y, Sint16 rad,
2314 Sint16 start, Sint16 end, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
2316 return _pieRGBA(renderer, x, y, rad, start, end, r, g, b, a, 0);
2332 int filledPieColor(SDL_Renderer * renderer, Sint16 x, Sint16 y, Sint16 rad, Sint16 start, Sint16 end, Uint32 color)
2334 Uint8 *c = (Uint8 *)&color;
2335 return _pieRGBA(renderer, x, y, rad, start, end, c[0], c[1], c[2], c[3], 1);
2355 Sint16 start, Sint16 end, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
2357 return _pieRGBA(renderer, x, y, rad, start, end, r, g, b, a, 1);
2378 int trigonColor(SDL_Renderer * renderer, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Sint16 x3, Sint16 y3, Uint32 color)
2410 int trigonRGBA(SDL_Renderer * renderer, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Sint16 x3, Sint16 y3,
2411 Uint8 r, Uint8 g, Uint8 b, Uint8 a)
2444 int aatrigonColor(SDL_Renderer * renderer, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Sint16 x3, Sint16 y3, Uint32 color)
2476 int aatrigonRGBA(SDL_Renderer * renderer, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Sint16 x3, Sint16 y3,
2477 Uint8 r, Uint8 g, Uint8 b, Uint8 a)
2510 int filledTrigonColor(SDL_Renderer * renderer, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Sint16 x3, Sint16 y3, Uint32 color)
2544 int filledTrigonRGBA(SDL_Renderer * renderer, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Sint16 x3, Sint16 y3,
2545 Uint8 r, Uint8 g, Uint8 b, Uint8 a)
2573 int polygonColor(SDL_Renderer * renderer,
const Sint16 * vx,
const Sint16 * vy,
int n, Uint32 color)
2575 Uint8 *c = (Uint8 *)&color;
2576 return polygonRGBA(renderer, vx, vy, n, c[0], c[1], c[2], c[3]);
2589 int polygon(SDL_Renderer * renderer,
const Sint16 * vx,
const Sint16 * vy,
int n)
2619 points = (SDL_Point*)malloc(
sizeof(SDL_Point) * nn);
2626 points[i].x = vx[i];
2627 points[i].y = vy[i];
2629 points[n].x = vx[0];
2630 points[n].y = vy[0];
2635 result |= SDL_RenderDrawLines(renderer, points, nn);
2655 int polygonRGBA(SDL_Renderer * renderer,
const Sint16 * vx,
const Sint16 * vy,
int n, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
2661 const Sint16 *x1, *y1, *x2, *y2;
2692 result |= SDL_SetRenderDrawBlendMode(renderer, (a == 255) ? SDL_BLENDMODE_NONE : SDL_BLENDMODE_BLEND);
2693 result |= SDL_SetRenderDrawColor(renderer, r, g, b, a);
2698 result |=
polygon(renderer, vx, vy, n);
2716 int aapolygonColor(SDL_Renderer * renderer,
const Sint16 * vx,
const Sint16 * vy,
int n, Uint32 color)
2718 Uint8 *c = (Uint8 *)&color;
2719 return aapolygonRGBA(renderer, vx, vy, n, c[0], c[1], c[2], c[3]);
2736 int aapolygonRGBA(SDL_Renderer * renderer,
const Sint16 * vx,
const Sint16 * vy,
int n, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
2740 const Sint16 *x1, *y1, *x2, *y2;
2771 for (i = 1; i < n; i++) {
2772 result |=
_aalineRGBA(renderer, *x1, *y1, *x2, *y2, r, g, b, a, 0);
2779 result |=
_aalineRGBA(renderer, *x1, *y1, *vx, *vy, r, g, b, a, 0);
2796 return (*(
const int *) a) - (*(
const int *) b);
2804 static int *gfxPrimitivesPolyIntsGlobal = NULL;
2811 static int gfxPrimitivesPolyAllocatedGlobal = 0;
2831 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)
2841 int *gfxPrimitivesPolyInts = NULL;
2842 int *gfxPrimitivesPolyIntsNew = NULL;
2843 int gfxPrimitivesPolyAllocated = 0;
2865 if ((polyInts==NULL) || (polyAllocated==NULL)) {
2867 gfxPrimitivesPolyInts = gfxPrimitivesPolyIntsGlobal;
2868 gfxPrimitivesPolyAllocated = gfxPrimitivesPolyAllocatedGlobal;
2871 gfxPrimitivesPolyInts = *polyInts;
2872 gfxPrimitivesPolyAllocated = *polyAllocated;
2878 if (!gfxPrimitivesPolyAllocated) {
2879 gfxPrimitivesPolyInts = (
int *) malloc(
sizeof(
int) * n);
2880 gfxPrimitivesPolyAllocated = n;
2882 if (gfxPrimitivesPolyAllocated < n) {
2883 gfxPrimitivesPolyIntsNew = (
int *) realloc(gfxPrimitivesPolyInts,
sizeof(
int) * n);
2884 if (!gfxPrimitivesPolyIntsNew) {
2885 if (!gfxPrimitivesPolyInts) {
2886 free(gfxPrimitivesPolyInts);
2887 gfxPrimitivesPolyInts = NULL;
2889 gfxPrimitivesPolyAllocated = 0;
2891 gfxPrimitivesPolyInts = gfxPrimitivesPolyIntsNew;
2892 gfxPrimitivesPolyAllocated = n;
2900 if (gfxPrimitivesPolyInts==NULL) {
2901 gfxPrimitivesPolyAllocated = 0;
2907 if ((polyInts==NULL) || (polyAllocated==NULL)) {
2908 gfxPrimitivesPolyIntsGlobal = gfxPrimitivesPolyInts;
2909 gfxPrimitivesPolyAllocatedGlobal = gfxPrimitivesPolyAllocated;
2911 *polyInts = gfxPrimitivesPolyInts;
2912 *polyAllocated = gfxPrimitivesPolyAllocated;
2918 if (gfxPrimitivesPolyInts==NULL) {
2927 for (i = 1; (i < n); i++) {
2930 }
else if (vy[i] > maxy) {
2939 for (y = miny; (y <= maxy); y++) {
2941 for (i = 0; (i < n); i++) {
2954 }
else if (y1 > y2) {
2962 if ( ((y >= y1) && (y < y2)) || ((y == maxy) && (y > y1) && (y <= y2)) ) {
2963 gfxPrimitivesPolyInts[ints++] = ((65536 * (y - y1)) / (y2 - y1)) * (x2 - x1) + (65536 * x1);
2973 result |= SDL_SetRenderDrawBlendMode(renderer, (a == 255) ? SDL_BLENDMODE_NONE : SDL_BLENDMODE_BLEND);
2974 result |= SDL_SetRenderDrawColor(renderer, r, g, b, a);
2976 for (i = 0; (i < ints); i += 2) {
2977 xa = gfxPrimitivesPolyInts[i] + 1;
2978 xa = (xa >> 16) + ((xa & 32768) >> 15);
2979 xb = gfxPrimitivesPolyInts[i+1] - 1;
2980 xb = (xb >> 16) + ((xb & 32768) >> 15);
2981 result |=
hline(renderer, xa, xb, y);
2999 int filledPolygonColor(SDL_Renderer * renderer,
const Sint16 * vx,
const Sint16 * vy,
int n, Uint32 color)
3001 Uint8 *c = (Uint8 *)&color;
3019 int filledPolygonRGBA(SDL_Renderer * renderer,
const Sint16 * vx,
const Sint16 * vy,
int n, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
3041 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)
3046 int texture_x_walker;
3047 int texture_y_start;
3048 SDL_Rect source_rect,dst_rect;
3049 int pixels_written,write_width;
3068 texture_x_walker = (x1 - texture_dx) % texture_w;
3069 if (texture_x_walker < 0){
3070 texture_x_walker = texture_w + texture_x_walker ;
3073 texture_y_start = (y + texture_dy) % texture_h;
3074 if (texture_y_start < 0){
3075 texture_y_start = texture_h + texture_y_start;
3079 source_rect.y = texture_y_start;
3080 source_rect.x = texture_x_walker;
3089 if (w <= texture_w -texture_x_walker){
3091 source_rect.x = texture_x_walker;
3093 dst_rect.w = source_rect.w;
3094 result = (SDL_RenderCopy(renderer, texture, &source_rect, &dst_rect) == 0);
3098 pixels_written = texture_w - texture_x_walker;
3099 source_rect.w = pixels_written;
3100 source_rect.x = texture_x_walker;
3102 dst_rect.w = source_rect.w;
3103 result |= (SDL_RenderCopy(renderer, texture, &source_rect, &dst_rect) == 0);
3104 write_width = texture_w;
3109 while (pixels_written < w){
3110 if (write_width >= w - pixels_written) {
3111 write_width = w - pixels_written;
3113 source_rect.w = write_width;
3114 dst_rect.x = x1 + pixels_written;
3115 dst_rect.w = source_rect.w;
3116 result |= (SDL_RenderCopy(renderer, texture, &source_rect, &dst_rect) == 0);
3117 pixels_written += write_width;
3141 SDL_Surface * texture,
int texture_dx,
int texture_dy,
int **polyInts,
int *polyAllocated)
3146 int minx,maxx,miny, maxy;
3151 int *gfxPrimitivesPolyInts = NULL;
3152 int gfxPrimitivesPolyAllocated = 0;
3153 SDL_Texture *textureAsTexture = NULL;
3165 if ((polyInts==NULL) || (polyAllocated==NULL)) {
3167 gfxPrimitivesPolyInts = gfxPrimitivesPolyIntsGlobal;
3168 gfxPrimitivesPolyAllocated = gfxPrimitivesPolyAllocatedGlobal;
3171 gfxPrimitivesPolyInts = *polyInts;
3172 gfxPrimitivesPolyAllocated = *polyAllocated;
3178 if (!gfxPrimitivesPolyAllocated) {
3179 gfxPrimitivesPolyInts = (
int *) malloc(
sizeof(
int) * n);
3180 gfxPrimitivesPolyAllocated = n;
3182 if (gfxPrimitivesPolyAllocated < n) {
3183 gfxPrimitivesPolyInts = (
int *) realloc(gfxPrimitivesPolyInts,
sizeof(
int) * n);
3184 gfxPrimitivesPolyAllocated = n;
3191 if (gfxPrimitivesPolyInts==NULL) {
3192 gfxPrimitivesPolyAllocated = 0;
3198 if ((polyInts==NULL) || (polyAllocated==NULL)) {
3199 gfxPrimitivesPolyIntsGlobal = gfxPrimitivesPolyInts;
3200 gfxPrimitivesPolyAllocatedGlobal = gfxPrimitivesPolyAllocated;
3202 *polyInts = gfxPrimitivesPolyInts;
3203 *polyAllocated = gfxPrimitivesPolyAllocated;
3209 if (gfxPrimitivesPolyInts==NULL) {
3220 for (i = 1; (i < n); i++) {
3223 }
else if (vy[i] > maxy) {
3228 }
else if (vx[i] > maxx) {
3234 textureAsTexture = SDL_CreateTextureFromSurface(renderer, texture);
3235 if (textureAsTexture == NULL)
3239 SDL_SetTextureBlendMode(textureAsTexture, SDL_BLENDMODE_BLEND);
3245 for (y = miny; (y <= maxy); y++) {
3247 for (i = 0; (i < n); i++) {
3260 }
else if (y1 > y2) {
3268 if ( ((y >= y1) && (y < y2)) || ((y == maxy) && (y > y1) && (y <= y2)) ) {
3269 gfxPrimitivesPolyInts[ints++] = ((65536 * (y - y1)) / (y2 - y1)) * (x2 - x1) + (65536 * x1);
3275 for (i = 0; (i < ints); i += 2) {
3276 xa = gfxPrimitivesPolyInts[i] + 1;
3277 xa = (xa >> 16) + ((xa & 32768) >> 15);
3278 xb = gfxPrimitivesPolyInts[i+1] - 1;
3279 xb = (xb >> 16) + ((xb & 32768) >> 15);
3280 result |=
_HLineTextured(renderer, xa, xb, y, textureAsTexture, texture->w, texture->h, texture_dx, texture_dy);
3284 SDL_RenderPresent(renderer);
3285 SDL_DestroyTexture(textureAsTexture);
3306 int texturedPolygon(SDL_Renderer *renderer,
const Sint16 * vx,
const Sint16 * vy,
int n, SDL_Surface *texture,
int texture_dx,
int texture_dy)
3311 return (
texturedPolygonMT(renderer, vx, vy, n, texture, texture_dx, texture_dy, NULL, NULL));
3319 static SDL_Texture *gfxPrimitivesFont[256];
3324 static const unsigned char *currentFontdata = gfxPrimitivesFontdata;
3329 static Uint32 charWidth = 8;
3334 static Uint32 charHeight = 8;
3339 static Uint32 charWidthLocal = 8;
3344 static Uint32 charHeightLocal = 8;
3349 static Uint32 charPitch = 1;
3354 static Uint32 charRotation = 0;
3359 static Uint32 charSize = 8;
3378 if ((fontdata) && (cw) && (ch)) {
3379 currentFontdata = (
unsigned char *)fontdata;
3383 currentFontdata = gfxPrimitivesFontdata;
3388 charPitch = (charWidth+7)/8;
3389 charSize = charPitch * charHeight;
3392 if ((charRotation==1) || (charRotation==3))
3394 charWidthLocal = charHeight;
3395 charHeightLocal = charWidth;
3399 charWidthLocal = charWidth;
3400 charHeightLocal = charHeight;
3404 for (i = 0; i < 256; i++) {
3405 if (gfxPrimitivesFont[i]) {
3406 SDL_DestroyTexture(gfxPrimitivesFont[i]);
3407 gfxPrimitivesFont[i] = NULL;
3424 rotation = rotation & 3;
3425 if (charRotation != rotation)
3428 charRotation = rotation;
3431 if ((charRotation==1) || (charRotation==3))
3433 charWidthLocal = charHeight;
3434 charHeightLocal = charWidth;
3438 charWidthLocal = charWidth;
3439 charHeightLocal = charHeight;
3443 for (i = 0; i < 256; i++) {
3444 if (gfxPrimitivesFont[i]) {
3445 SDL_DestroyTexture(gfxPrimitivesFont[i]);
3446 gfxPrimitivesFont[i] = NULL;
3466 int characterRGBA(SDL_Renderer *renderer, Sint16 x, Sint16 y,
char c, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
3472 const unsigned char *charpos;
3477 SDL_Surface *character;
3478 SDL_Surface *rotatedCharacter;
3486 srect.w = charWidthLocal;
3487 srect.h = charHeightLocal;
3494 drect.w = charWidthLocal;
3495 drect.h = charHeightLocal;
3498 ci = (
unsigned char) c;
3504 if (gfxPrimitivesFont[ci] == NULL) {
3508 character = SDL_CreateRGBSurface(SDL_SWSURFACE,
3509 charWidth, charHeight, 32,
3510 0xFF000000, 0x00FF0000, 0x0000FF00, 0x000000FF);
3511 if (character == NULL) {
3515 charpos = currentFontdata + ci * charSize;
3516 linepos = (Uint8 *)character->pixels;
3517 pitch = character->pitch;
3523 for (iy = 0; iy < charHeight; iy++) {
3526 for (ix = 0; ix < charWidth; ix++) {
3527 if (!(mask >>= 1)) {
3532 *(Uint32 *)curpos = 0xffffffff;
3534 *(Uint32 *)curpos = 0;
3545 SDL_FreeSurface(character);
3546 character = rotatedCharacter;
3550 gfxPrimitivesFont[ci] = SDL_CreateTextureFromSurface(renderer, character);
3551 SDL_FreeSurface(character);
3556 if (gfxPrimitivesFont[ci] == NULL) {
3565 result |= SDL_SetTextureColorMod(gfxPrimitivesFont[ci], r, g, b);
3566 result |= SDL_SetTextureAlphaMod(gfxPrimitivesFont[ci], a);
3571 result |= SDL_RenderCopy(renderer, gfxPrimitivesFont[ci], &srect, &drect);
3588 int characterColor(SDL_Renderer * renderer, Sint16 x, Sint16 y,
char c, Uint32 color)
3590 Uint8 *co = (Uint8 *)&color;
3591 return characterRGBA(renderer, x, y, c, co[0], co[1], co[2], co[3]);
3609 int stringColor(SDL_Renderer * renderer, Sint16 x, Sint16 y,
const char *s, Uint32 color)
3611 Uint8 *c = (Uint8 *)&color;
3612 return stringRGBA(renderer, x, y, s, c[0], c[1], c[2], c[3]);
3629 int stringRGBA(SDL_Renderer * renderer, Sint16 x, Sint16 y,
const char *s, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
3634 const char *curchar = s;
3636 while (*curchar && !result) {
3637 result |=
characterRGBA(renderer, curx, cury, *curchar, r, g, b, a);
3638 switch (charRotation)
3641 curx += charWidthLocal;
3644 curx -= charWidthLocal;
3647 cury += charHeightLocal;
3650 cury -= charHeightLocal;
3674 double blend,muk,munk;
3680 if (t>=(
double)ndata) {
3681 return(data[ndata-1]);
3691 munk = pow(1-mu,(
double)n);
3692 for (k=0;k<=n;k++) {
3703 blend /= (double)kn;
3707 blend /= (double)nkn;
3711 result += data[k] * blend;
3729 int bezierColor(SDL_Renderer * renderer,
const Sint16 * vx,
const Sint16 * vy,
int n,
int s, Uint32 color)
3731 Uint8 *c = (Uint8 *)&color;
3732 return bezierRGBA(renderer, vx, vy, n, s, c[0], c[1], c[2], c[3]);
3750 int bezierRGBA(SDL_Renderer * renderer,
const Sint16 * vx,
const Sint16 * vy,
int n,
int s, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
3754 double *x, *y, t, stepsize;
3755 Sint16 x1, y1, x2, y2;
3770 stepsize=(double)1.0/(
double)s;
3773 if ((x=(
double *)malloc(
sizeof(
double)*(n+1)))==NULL) {
3776 if ((y=(
double *)malloc(
sizeof(
double)*(n+1)))==NULL) {
3780 for (i=0; i<n; i++) {
3791 result |= SDL_SetRenderDrawBlendMode(renderer, (a == 255) ? SDL_BLENDMODE_NONE : SDL_BLENDMODE_BLEND);
3792 result |= SDL_SetRenderDrawColor(renderer, r, g, b, a);
3800 for (i = 0; i <= (n*s); i++) {
3804 result |=
line(renderer, x1, y1, x2, y2);
3849 if ((b->
dx = x2 - x1) != 0) {
3861 if ((b->
dy = y2 - y1) != 0) {
3872 if (b->
dy > b->
dx) {
3881 b->
count = (b->
dx<0) ? 0 : (
unsigned int)b->
dx;
3910 while (b->
error >= 0) {
3930 return ((b->
count) ? 0 : 1);
3947 for (p = 0; p <= m->
u; p++) {
3955 if (m->
quad4 == 0) {
3964 if (m->
quad4 == 0) {
3993 Uint16 ml1bx, Uint16 ml1by, Uint16 ml2bx, Uint16 ml2by,
3994 Uint16 ml1x, Uint16 ml1y, Uint16 ml2x, Uint16 ml2y)
3998 Uint16 m1x, m1y, m2x, m2y;
3999 Uint16 fix, fiy, lax, lay, curx, cury;
4000 Sint16 px[4], py[4];
4009 curx = (ml1x + ml2x) / 2;
4010 cury = (ml1y + ml2y) / 2;
4012 atemp1 = (fix - curx);
4013 atemp2 = (fiy - cury);
4014 ftmp1 = atemp1 * atemp1 + atemp2 * atemp2;
4015 atemp1 = (lax - curx);
4016 atemp2 = (lay - cury);
4017 ftmp2 = atemp1 * atemp1 + atemp2 * atemp2;
4019 if (ftmp1 <= ftmp2) {
4031 atemp1 = (m2x - ml2x);
4032 atemp2 = (m2y - ml2y);
4033 ftmp1 = atemp1 * atemp1 + atemp2 * atemp2;
4034 atemp1 = (m2x - ml2bx);
4035 atemp2 = (m2y - ml2by);
4036 ftmp2 = atemp1 * atemp1 + atemp2 * atemp2;
4038 if (ftmp2 >= ftmp1) {
4099 #define HYPOT(x,y) sqrt((double)(x)*(double)(x)+(double)(y)*(double)(y)) 4117 float offset = (float)width / 2.f;
4120 Sint16 ptx, pty, ptxx, ptxy, ml1x, ml1y, ml2x, ml2y, ml1bx, ml1by, ml2bx, ml2by;
4163 m->
ku = m->
u + m->
u;
4164 m->
kv = m->
v + m->
v;
4166 m->
kt = m->
u - m->
kv;
4172 ang = atan((
double) m->
v / (
double) m->
u);
4177 ptx = x1 + (Sint16)lrint(offset * sang);
4178 if (m->
quad4 == 0) {
4179 pty = y1 - (Sint16)lrint(offset * cang);
4181 pty = y1 + (Sint16)lrint(offset * cang);
4184 ptx = x1 - (Sint16)lrint(offset * cang);
4185 if (m->
quad4 == 0) {
4186 pty = y1 + (Sint16)lrint(offset * sang);
4188 pty = y1 - (Sint16)lrint(offset * sang);
4193 tk = (int) (4. *
HYPOT(ptx - x1, pty - y1) *
HYPOT(m->
u, m->
v));
4208 for (q = 0; dd <= tk; q++) {
4224 if (m->
quad4 == 0) {
4238 if (m->
quad4 == 0) {
4245 if (m->
quad4 == 0) {
4256 if (m->
quad4 == 0) {
4264 _murphyIteration(m, miter, ml1bx, ml1by, ml2bx, ml2by, ml1x, ml1y, ml2x, ml2y);
4269 if (m->
quad4 == 0) {
4284 _murphyIteration(m, miter, ml1bx, ml1by, ml2bx, ml2by, ml1x, ml1y, ml2x, ml2y);
4301 int thickLineColor(SDL_Renderer *renderer, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Uint8 width, Uint32 color)
4303 Uint8 *c = (Uint8 *)&color;
4304 return thickLineRGBA(renderer, x1, y1, x2, y2, width, c[0], c[1], c[2], c[3]);
4323 int thickLineRGBA(SDL_Renderer *renderer, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Uint8 width, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
4329 if (renderer == NULL) {
4337 if ((x1 == x2) && (y1 == y2)) {
4339 return boxRGBA(renderer, x1 - wh, y1 - wh, x2 + width, y2 + width, r, g, b, a);
4346 result |= SDL_SetRenderDrawBlendMode(renderer, (a == 255) ? SDL_BLENDMODE_NONE : SDL_BLENDMODE_BLEND);
4347 result |= SDL_SetRenderDrawColor(renderer, r, g, b, a);
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.
void _murphyWideline(SDL2_gfxMurphyIterator *m, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Uint8 width, Uint8 miter)
Internal function to to draw wide lines with Murphy algorithm.
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 _bresenhamInitialize(SDL2_gfxBresenhamIterator *b, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2)
Internal function to initialize the Bresenham line iterator.
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.
void _murphyParaline(SDL2_gfxMurphyIterator *m, Sint16 x, Sint16 y, int d1)
Internal function to to draw parallel lines with Murphy algorithm.
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.
void _murphyIteration(SDL2_gfxMurphyIterator *m, Uint8 miter, Uint16 ml1bx, Uint16 ml1by, Uint16 ml2bx, Uint16 ml2by, Uint16 ml1x, Uint16 ml1y, Uint16 ml2x, Uint16 ml2y)
Internal function to to draw one iteration of the Murphy algorithm.
int _bresenhamIterate(SDL2_gfxBresenhamIterator *b)
Internal function to move Bresenham line iterator to the next position.
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 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 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.