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)
525 Sint16 xx1, xx2, yy1, yy2;
530 if (renderer == NULL)
554 return (
pixelRGBA(renderer, x1, y1, r, g, b, a));
556 return (
vlineRGBA(renderer, x1, y1, y2, r, g, b, a));
560 return (
hlineRGBA(renderer, x1, x2, y1, r, g, b, a));
607 result |=
filledPieRGBA(renderer, xx1, yy1, rad, 180, 270, r, g, b, a);
608 result |=
filledPieRGBA(renderer, xx2, yy1, rad, 270, 360, r, g, b, a);
609 result |=
filledPieRGBA(renderer, xx1, yy2, rad, 90, 180, r, g, b, a);
610 result |=
filledPieRGBA(renderer, xx2, yy2, rad, 0, 90, r, g, b, a);
620 result |=
boxRGBA(renderer, xx1, y1, xx2, y2, r, g, b, a);
623 result |=
boxRGBA(renderer, x1, yy1, xx1-1, yy2, r, g, b, a);
624 result |=
boxRGBA(renderer, xx2+1, yy1, x2, yy2, r, g, b, a);
644 int boxColor(SDL_Renderer * renderer, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Uint32 color)
646 Uint8 *c = (Uint8 *)&color;
647 return boxRGBA(renderer, x1, y1, x2, y2, c[0], c[1], c[2], c[3]);
665 int boxRGBA(SDL_Renderer * renderer, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
676 return (
pixelRGBA(renderer, x1, y1, r, g, b, a));
678 return (
vlineRGBA(renderer, x1, y1, y2, r, g, b, a));
682 return (
hlineRGBA(renderer, x1, x2, y1, r, g, b, a));
716 result |= SDL_SetRenderDrawBlendMode(renderer, (a == 255) ? SDL_BLENDMODE_NONE : SDL_BLENDMODE_BLEND);
717 result |= SDL_SetRenderDrawColor(renderer, r, g, b, a);
718 result |= SDL_RenderFillRect(renderer, &rect);
735 int line(SDL_Renderer * renderer, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2)
740 return SDL_RenderDrawLine(renderer, x1, y1, x2, y2);
755 int lineColor(SDL_Renderer * renderer, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Uint32 color)
757 Uint8 *c = (Uint8 *)&color;
758 return lineRGBA(renderer, x1, y1, x2, y2, c[0], c[1], c[2], c[3]);
776 int lineRGBA(SDL_Renderer * renderer, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
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_RenderDrawLine(renderer, x1, y1, x2, y2);
816 int _aalineRGBA(SDL_Renderer * renderer, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Uint8 r, Uint8 g, Uint8 b, Uint8 a,
int draw_endpoint)
818 Sint32 xx0, yy0, xx1, yy1;
820 Uint32 intshift, erracc, erradj;
821 Uint32 erracctmp, wgt, wgtcompmask;
822 int dx, dy, tmp, xdir, y0p1, x0pxdir;
869 return (
vlineRGBA(renderer, x1, y1, y2, r, g, b, a));
872 return (
vlineRGBA(renderer, x1, yy0, yy0+dy, r, g, b, a));
874 return (
pixelRGBA(renderer, x1, y1, r, g, b, a));
877 }
else if (dy == 0) {
883 return (
hlineRGBA(renderer, x1, x2, y1, r, g, b, a));
886 return (
hlineRGBA(renderer, xx0, xx0+dx, y1, r, g, b, a));
888 return (
pixelRGBA(renderer, x1, y1, r, g, b, a));
891 }
else if ((dx == dy) && (draw_endpoint)) {
895 return (
lineRGBA(renderer, x1, y1, x2, y2, r, g, b, a));
922 result |=
pixelRGBA(renderer, x1, y1, r, g, b, a);
937 erradj = ((dx << 16) / dy) << 16;
942 x0pxdir = xx0 + xdir;
946 if (erracc <= erracctmp) {
960 wgt = (erracc >> intshift) & 255;
975 erradj = ((dy << 16) / dx) << 16;
985 if (erracc <= erracctmp) {
998 wgt = (erracc >> intshift) & 255;
1007 if (draw_endpoint) {
1012 result |=
pixelRGBA (renderer, x2, y2, r, g, b, a);
1030 int aalineColor(SDL_Renderer * renderer, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Uint32 color)
1032 Uint8 *c = (Uint8 *)&color;
1033 return _aalineRGBA(renderer, x1, y1, x2, y2, c[0], c[1], c[2], c[3], 1);
1051 int aalineRGBA(SDL_Renderer * renderer, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
1053 return _aalineRGBA(renderer, x1, y1, x2, y2, r, g, b, a, 1);
1069 int circleColor(SDL_Renderer * renderer, Sint16 x, Sint16 y, Sint16 rad, Uint32 color)
1071 Uint8 *c = (Uint8 *)&color;
1072 return ellipseRGBA(renderer, x, y, rad, rad, c[0], c[1], c[2], c[3]);
1089 int circleRGBA(SDL_Renderer * renderer, Sint16 x, Sint16 y, Sint16 rad, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
1091 return ellipseRGBA(renderer, x, y, rad, rad, r, g, b, a);
1109 int arcColor(SDL_Renderer * renderer, Sint16 x, Sint16 y, Sint16 rad, Sint16 start, Sint16 end, Uint32 color)
1111 Uint8 *c = (Uint8 *)&color;
1112 return arcRGBA(renderer, x, y, rad, start, end, c[0], c[1], c[2], c[3]);
1131 int arcRGBA(SDL_Renderer * renderer, Sint16 x, Sint16 y, Sint16 rad, Sint16 start, Sint16 end, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
1136 Sint16 df = 1 - rad;
1138 Sint16 d_se = -2 * rad + 5;
1139 Sint16 xpcx, xmcx, xpcy, xmcy;
1140 Sint16 ypcy, ymcy, ypcx, ymcx;
1142 int startoct, endoct, oct, stopval_start = 0, stopval_end = 0;
1143 double dstart, dend, temp = 0.;
1156 return (
pixelRGBA(renderer, x, y, r, g, b, a));
1183 while (start < 0) start += 360;
1184 while (end < 0) end += 360;
1189 startoct = start / 45;
1196 oct = (oct + 1) % 8;
1198 if (oct == startoct) {
1200 dstart = (double)start;
1205 temp = sin(dstart *
M_PI / 180.);
1209 temp = cos(dstart *
M_PI / 180.);
1213 temp = -cos(dstart *
M_PI / 180.);
1217 temp = -sin(dstart *
M_PI / 180.);
1221 stopval_start = (int)temp;
1228 if (oct % 2) drawoct |= (1 << oct);
1229 else drawoct &= 255 - (1 << oct);
1231 if (oct == endoct) {
1238 temp = sin(dend *
M_PI / 180);
1242 temp = cos(dend *
M_PI / 180);
1246 temp = -cos(dend *
M_PI / 180);
1250 temp = -sin(dend *
M_PI / 180);
1254 stopval_end = (int)temp;
1257 if (startoct == endoct) {
1265 drawoct &= 255 - (1 << oct);
1268 else if (oct % 2) drawoct &= 255 - (1 << oct);
1269 else drawoct |= (1 << oct);
1270 }
else if (oct != startoct) {
1271 drawoct |= (1 << oct);
1273 }
while (oct != endoct);
1281 result |= SDL_SetRenderDrawBlendMode(renderer, (a == 255) ? SDL_BLENDMODE_NONE : SDL_BLENDMODE_BLEND);
1282 result |= SDL_SetRenderDrawColor(renderer, r, g, b, a);
1295 if (drawoct & 4) result |=
pixel(renderer, xmcx, ypcy);
1296 if (drawoct & 2) result |=
pixel(renderer, xpcx, ypcy);
1297 if (drawoct & 32) result |=
pixel(renderer, xmcx, ymcy);
1298 if (drawoct & 64) result |=
pixel(renderer, xpcx, ymcy);
1300 if (drawoct & 96) result |=
pixel(renderer, x, ymcy);
1301 if (drawoct & 6) result |=
pixel(renderer, x, ypcy);
1306 if (cx > 0 && cx != cy) {
1309 if (drawoct & 8) result |=
pixel(renderer, xmcy, ypcx);
1310 if (drawoct & 1) result |=
pixel(renderer, xpcy, ypcx);
1311 if (drawoct & 16) result |=
pixel(renderer, xmcy, ymcx);
1312 if (drawoct & 128) result |=
pixel(renderer, xpcy, ymcx);
1313 }
else if (cx == 0) {
1314 if (drawoct & 24) result |=
pixel(renderer, xmcy, y);
1315 if (drawoct & 129) result |=
pixel(renderer, xpcy, y);
1321 if (stopval_start == cx) {
1324 if (drawoct & (1 << startoct)) drawoct &= 255 - (1 << startoct);
1325 else drawoct |= (1 << startoct);
1327 if (stopval_end == cx) {
1328 if (drawoct & (1 << endoct)) drawoct &= 255 - (1 << endoct);
1329 else drawoct |= (1 << endoct);
1364 int aacircleColor(SDL_Renderer * renderer, Sint16 x, Sint16 y, Sint16 rad, Uint32 color)
1366 Uint8 *c = (Uint8 *)&color;
1367 return aaellipseRGBA(renderer, x, y, rad, rad, c[0], c[1], c[2], c[3]);
1384 int aacircleRGBA(SDL_Renderer * renderer, Sint16 x, Sint16 y, Sint16 rad, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
1407 Uint8 *c = (Uint8 *)&color;
1425 int filledCircleRGBA(SDL_Renderer * renderer, Sint16 x, Sint16 y, Sint16 rad, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
1430 Sint16 ocx = (Sint16) 0xffff;
1431 Sint16 ocy = (Sint16) 0xffff;
1432 Sint16 df = 1 - rad;
1434 Sint16 d_se = -2 * rad + 5;
1435 Sint16 xpcx, xmcx, xpcy, xmcy;
1436 Sint16 ypcy, ymcy, ypcx, ymcx;
1449 return (
pixelRGBA(renderer, x, y, r, g, b, a));
1456 result |= SDL_SetRenderDrawBlendMode(renderer, (a == 255) ? SDL_BLENDMODE_NONE : SDL_BLENDMODE_BLEND);
1457 result |= SDL_SetRenderDrawColor(renderer, r, g, b, a);
1471 result |=
hline(renderer, xmcx, xpcx, ypcy);
1472 result |=
hline(renderer, xmcx, xpcx, ymcy);
1474 result |=
hline(renderer, xmcx, xpcx, y);
1483 result |=
hline(renderer, xmcy, xpcy, ymcx);
1484 result |=
hline(renderer, xmcy, xpcy, ypcx);
1486 result |=
hline(renderer, xmcy, xpcy, y);
1525 int ellipseColor(SDL_Renderer * renderer, Sint16 x, Sint16 y, Sint16 rx, Sint16 ry, Uint32 color)
1527 Uint8 *c = (Uint8 *)&color;
1528 return ellipseRGBA(renderer, x, y, rx, ry, c[0], c[1], c[2], c[3]);
1546 int ellipseRGBA(SDL_Renderer * renderer, Sint16 x, Sint16 y, Sint16 rx, Sint16 ry, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
1552 int xmh, xph, ypk, ymk;
1553 int xmi, xpi, ymj, ypj;
1554 int xmj, xpj, ymi, ypi;
1555 int xmk, xpk, ymh, yph;
1560 if ((rx < 0) || (ry < 0)) {
1568 return (
vlineRGBA(renderer, x, y - ry, y + ry, r, g, b, a));
1574 return (
hlineRGBA(renderer, x - rx, x + rx, y, r, g, b, a));
1581 result |= SDL_SetRenderDrawBlendMode(renderer, (a == 255) ? SDL_BLENDMODE_NONE : SDL_BLENDMODE_BLEND);
1582 result |= SDL_SetRenderDrawColor(renderer, r, g, b, a);
1587 oh = oi = oj = ok = 0xFFFF;
1602 if (((ok != k) && (oj != k)) || ((oj != j) && (ok != j)) || (k != j)) {
1608 result |=
pixel(renderer, xmh, ypk);
1609 result |=
pixel(renderer, xph, ypk);
1610 result |=
pixel(renderer, xmh, ymk);
1611 result |=
pixel(renderer, xph, ymk);
1613 result |=
pixel(renderer, xmh, y);
1614 result |=
pixel(renderer, xph, y);
1622 result |=
pixel(renderer, xmi, ypj);
1623 result |=
pixel(renderer, xpi, ypj);
1624 result |=
pixel(renderer, xmi, ymj);
1625 result |=
pixel(renderer, xpi, ymj);
1627 result |=
pixel(renderer, xmi, y);
1628 result |=
pixel(renderer, xpi, y);
1647 if (((oi != i) && (oh != i)) || ((oh != h) && (oi != h) && (i != h))) {
1653 result |=
pixel(renderer, xmj, ypi);
1654 result |=
pixel(renderer, xpj, ypi);
1655 result |=
pixel(renderer, xmj, ymi);
1656 result |=
pixel(renderer, xpj, ymi);
1658 result |=
pixel(renderer, xmj, y);
1659 result |=
pixel(renderer, xpj, y);
1667 result |=
pixel(renderer, xmk, yph);
1668 result |=
pixel(renderer, xpk, yph);
1669 result |=
pixel(renderer, xmk, ymh);
1670 result |=
pixel(renderer, xpk, ymh);
1672 result |=
pixel(renderer, xmk, y);
1673 result |=
pixel(renderer, xpk, y);
1690 #if defined(_MSC_VER)
1693 #include <emmintrin.h>
1694 static __inline
long
1697 return _mm_cvtss_si32(_mm_load_ss(&f));
1699 #elif defined(_M_IX86)
1711 #elif defined(_M_ARM)
1712 #include <armintr.h>
1713 #pragma warning(push)
1714 #pragma warning(disable: 4716)
1715 __declspec(naked) long
int
1723 #pragma warning(pop)
1725 #error lrint needed for MSVC on non X86/AMD64/ARM targets.
1741 int aaellipseColor(SDL_Renderer * renderer, Sint16 x, Sint16 y, Sint16 rx, Sint16 ry, Uint32 color)
1743 Uint8 *c = (Uint8 *)&color;
1744 return aaellipseRGBA(renderer, x, y, rx, ry, c[0], c[1], c[2], c[3]);
1762 int aaellipseRGBA(SDL_Renderer * renderer, Sint16 x, Sint16 y, Sint16 rx, Sint16 ry, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
1766 int a2, b2, ds, dt, dxt, t, s, d;
1767 Sint16 xp, yp, xs, ys, dyt, od, xx, yy, xc2, yc2;
1770 Uint8 weight, iweight;
1775 if ((rx < 0) || (ry < 0)) {
1783 return (
vlineRGBA(renderer, x, y - ry, y + ry, r, g, b, a));
1789 return (
hlineRGBA(renderer, x - rx, x + rx, y, r, g, b, a));
1802 sab = sqrt((
double)(a2 + b2));
1803 od = (Sint16)lrint(sab*0.01) + 1;
1804 dxt = (Sint16)lrint((
double)a2 / sab) + od;
1815 result |= SDL_SetRenderDrawBlendMode(renderer, (a == 255) ? SDL_BLENDMODE_NONE : SDL_BLENDMODE_BLEND);
1818 result |=
pixelRGBA(renderer, xp, yp, r, g, b, a);
1819 result |=
pixelRGBA(renderer, xc2 - xp, yp, r, g, b, a);
1820 result |=
pixelRGBA(renderer, xp, yc2 - yp, r, g, b, a);
1821 result |=
pixelRGBA(renderer, xc2 - xp, yc2 - yp, r, g, b, a);
1823 for (i = 1; i <= dxt; i++) {
1829 else if ((d - s - a2) > 0) {
1830 if ((2 * d - s - a2) >= 0)
1849 cp = (float) abs(d) / (float) abs(s);
1858 weight = (Uint8) (cp * 255);
1859 iweight = 255 - weight;
1880 dyt = (Sint16)lrint((
double)b2 / sab ) + od;
1882 for (i = 1; i <= dyt; i++) {
1888 else if ((d + t - b2) < 0) {
1889 if ((2 * d + t - b2) <= 0)
1908 cp = (float) abs(d) / (float) abs(t);
1917 weight = (Uint8) (cp * 255);
1918 iweight = 255 - weight;
1957 Uint8 *c = (Uint8 *)&color;
1976 int filledEllipseRGBA(SDL_Renderer * renderer, Sint16 x, Sint16 y, Sint16 rx, Sint16 ry, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
1990 if ((rx < 0) || (ry < 0)) {
1998 return (
vlineRGBA(renderer, x, y - ry, y + ry, r, g, b, a));
2004 return (
hlineRGBA(renderer, x - rx, x + rx, y, r, g, b, a));
2011 result |= SDL_SetRenderDrawBlendMode(renderer, (a == 255) ? SDL_BLENDMODE_NONE : SDL_BLENDMODE_BLEND);
2012 result |= SDL_SetRenderDrawColor(renderer, r, g, b, a);
2017 oh = oi = oj = ok = 0xFFFF;
2032 if ((ok != k) && (oj != k)) {
2036 result |=
hline(renderer, xmh, xph, y + k);
2037 result |=
hline(renderer, xmh, xph, y - k);
2039 result |=
hline(renderer, xmh, xph, y);
2043 if ((oj != j) && (ok != j) && (k != j)) {
2047 result |=
hline(renderer, xmi, xpi, y + j);
2048 result |=
hline(renderer, xmi, xpi, y - j);
2050 result |=
hline(renderer, xmi, xpi, y);
2069 if ((oi != i) && (oh != i)) {
2073 result |=
hline(renderer, xmj, xpj, y + i);
2074 result |=
hline(renderer, xmj, xpj, y - i);
2076 result |=
hline(renderer, xmj, xpj, y);
2080 if ((oh != h) && (oi != h) && (i != h)) {
2084 result |=
hline(renderer, xmk, xpk, y + h);
2085 result |=
hline(renderer, xmk, xpk, y - h);
2087 result |=
hline(renderer, xmk, xpk, y);
2122 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)
2125 double angle, start_angle, end_angle;
2141 start = start % 360;
2148 return (
pixelRGBA(renderer, x, y, r, g, b, a));
2155 deltaAngle = 3.0 / dr;
2156 start_angle = (double) start *(2.0 *
M_PI / 360.0);
2157 end_angle = (double) end *(2.0 *
M_PI / 360.0);
2159 end_angle += (2.0 *
M_PI);
2166 angle = start_angle;
2167 while (angle < end_angle) {
2168 angle += deltaAngle;
2173 vx = vy = (Sint16 *) malloc(2 *
sizeof(Uint16) * numpoints);
2186 angle = start_angle;
2187 vx[1] = x + (int) (dr * cos(angle));
2188 vy[1] = y + (int) (dr * sin(angle));
2192 result =
lineRGBA(renderer, vx[0], vy[0], vx[1], vy[1], r, g, b, a);
2198 angle = start_angle;
2199 while (angle < end_angle) {
2200 angle += deltaAngle;
2201 if (angle>end_angle)
2205 vx[i] = x + (int) (dr * cos(angle));
2206 vy[i] = y + (int) (dr * sin(angle));
2214 result =
polygonRGBA(renderer, vx, vy, numpoints, r, g, b, a);
2237 int pieColor(SDL_Renderer * renderer, Sint16 x, Sint16 y, Sint16 rad,
2238 Sint16 start, Sint16 end, Uint32 color)
2240 Uint8 *c = (Uint8 *)&color;
2241 return _pieRGBA(renderer, x, y, rad, start, end, c[0], c[1], c[2], c[3], 0);
2260 int pieRGBA(SDL_Renderer * renderer, Sint16 x, Sint16 y, Sint16 rad,
2261 Sint16 start, Sint16 end, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
2263 return _pieRGBA(renderer, x, y, rad, start, end, r, g, b, a, 0);
2279 int filledPieColor(SDL_Renderer * renderer, Sint16 x, Sint16 y, Sint16 rad, Sint16 start, Sint16 end, Uint32 color)
2281 Uint8 *c = (Uint8 *)&color;
2282 return _pieRGBA(renderer, x, y, rad, start, end, c[0], c[1], c[2], c[3], 1);
2302 Sint16 start, Sint16 end, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
2304 return _pieRGBA(renderer, x, y, rad, start, end, r, g, b, a, 1);
2325 int trigonColor(SDL_Renderer * renderer, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Sint16 x3, Sint16 y3, Uint32 color)
2357 int trigonRGBA(SDL_Renderer * renderer, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Sint16 x3, Sint16 y3,
2358 Uint8 r, Uint8 g, Uint8 b, Uint8 a)
2391 int aatrigonColor(SDL_Renderer * renderer, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Sint16 x3, Sint16 y3, Uint32 color)
2423 int aatrigonRGBA(SDL_Renderer * renderer, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Sint16 x3, Sint16 y3,
2424 Uint8 r, Uint8 g, Uint8 b, Uint8 a)
2457 int filledTrigonColor(SDL_Renderer * renderer, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Sint16 x3, Sint16 y3, Uint32 color)
2491 int filledTrigonRGBA(SDL_Renderer * renderer, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Sint16 x3, Sint16 y3,
2492 Uint8 r, Uint8 g, Uint8 b, Uint8 a)
2520 int polygonColor(SDL_Renderer * renderer,
const Sint16 * vx,
const Sint16 * vy,
int n, Uint32 color)
2522 Uint8 *c = (Uint8 *)&color;
2523 return polygonRGBA(renderer, vx, vy, n, c[0], c[1], c[2], c[3]);
2536 int polygon(SDL_Renderer * renderer,
const Sint16 * vx,
const Sint16 * vy,
int n)
2566 points = (SDL_Point*)malloc(
sizeof(SDL_Point) * nn);
2573 points[i].x = vx[i];
2574 points[i].y = vy[i];
2576 points[n].x = vx[0];
2577 points[n].y = vy[0];
2582 result |= SDL_RenderDrawLines(renderer, points, nn);
2602 int polygonRGBA(SDL_Renderer * renderer,
const Sint16 * vx,
const Sint16 * vy,
int n, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
2608 const Sint16 *x1, *y1, *x2, *y2;
2639 result |= SDL_SetRenderDrawBlendMode(renderer, (a == 255) ? SDL_BLENDMODE_NONE : SDL_BLENDMODE_BLEND);
2640 result |= SDL_SetRenderDrawColor(renderer, r, g, b, a);
2645 result |=
polygon(renderer, vx, vy, n);
2663 int aapolygonColor(SDL_Renderer * renderer,
const Sint16 * vx,
const Sint16 * vy,
int n, Uint32 color)
2665 Uint8 *c = (Uint8 *)&color;
2666 return aapolygonRGBA(renderer, vx, vy, n, c[0], c[1], c[2], c[3]);
2683 int aapolygonRGBA(SDL_Renderer * renderer,
const Sint16 * vx,
const Sint16 * vy,
int n, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
2687 const Sint16 *x1, *y1, *x2, *y2;
2718 for (i = 1; i < n; i++) {
2719 result |=
_aalineRGBA(renderer, *x1, *y1, *x2, *y2, r, g, b, a, 0);
2726 result |=
_aalineRGBA(renderer, *x1, *y1, *vx, *vy, r, g, b, a, 0);
2743 return (*(
const int *) a) - (*(
const int *) b);
2751 static int *gfxPrimitivesPolyIntsGlobal = NULL;
2758 static int gfxPrimitivesPolyAllocatedGlobal = 0;
2778 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)
2788 int *gfxPrimitivesPolyInts = NULL;
2789 int *gfxPrimitivesPolyIntsNew = NULL;
2790 int gfxPrimitivesPolyAllocated = 0;
2812 if ((polyInts==NULL) || (polyAllocated==NULL)) {
2814 gfxPrimitivesPolyInts = gfxPrimitivesPolyIntsGlobal;
2815 gfxPrimitivesPolyAllocated = gfxPrimitivesPolyAllocatedGlobal;
2818 gfxPrimitivesPolyInts = *polyInts;
2819 gfxPrimitivesPolyAllocated = *polyAllocated;
2825 if (!gfxPrimitivesPolyAllocated) {
2826 gfxPrimitivesPolyInts = (
int *) malloc(
sizeof(
int) * n);
2827 gfxPrimitivesPolyAllocated = n;
2829 if (gfxPrimitivesPolyAllocated < n) {
2830 gfxPrimitivesPolyIntsNew = (
int *) realloc(gfxPrimitivesPolyInts,
sizeof(
int) * n);
2831 if (!gfxPrimitivesPolyIntsNew) {
2832 if (!gfxPrimitivesPolyInts) {
2833 free(gfxPrimitivesPolyInts);
2834 gfxPrimitivesPolyInts = NULL;
2836 gfxPrimitivesPolyAllocated = 0;
2838 gfxPrimitivesPolyInts = gfxPrimitivesPolyIntsNew;
2839 gfxPrimitivesPolyAllocated = n;
2847 if (gfxPrimitivesPolyInts==NULL) {
2848 gfxPrimitivesPolyAllocated = 0;
2854 if ((polyInts==NULL) || (polyAllocated==NULL)) {
2855 gfxPrimitivesPolyIntsGlobal = gfxPrimitivesPolyInts;
2856 gfxPrimitivesPolyAllocatedGlobal = gfxPrimitivesPolyAllocated;
2858 *polyInts = gfxPrimitivesPolyInts;
2859 *polyAllocated = gfxPrimitivesPolyAllocated;
2865 if (gfxPrimitivesPolyInts==NULL) {
2874 for (i = 1; (i < n); i++) {
2877 }
else if (vy[i] > maxy) {
2886 for (y = miny; (y <= maxy); y++) {
2888 for (i = 0; (i < n); i++) {
2901 }
else if (y1 > y2) {
2909 if ( ((y >= y1) && (y < y2)) || ((y == maxy) && (y > y1) && (y <= y2)) ) {
2910 gfxPrimitivesPolyInts[ints++] = ((65536 * (y - y1)) / (y2 - y1)) * (x2 - x1) + (65536 * x1);
2920 result |= SDL_SetRenderDrawBlendMode(renderer, (a == 255) ? SDL_BLENDMODE_NONE : SDL_BLENDMODE_BLEND);
2921 result |= SDL_SetRenderDrawColor(renderer, r, g, b, a);
2923 for (i = 0; (i < ints); i += 2) {
2924 xa = gfxPrimitivesPolyInts[i] + 1;
2925 xa = (xa >> 16) + ((xa & 32768) >> 15);
2926 xb = gfxPrimitivesPolyInts[i+1] - 1;
2927 xb = (xb >> 16) + ((xb & 32768) >> 15);
2928 result |=
hline(renderer, xa, xb, y);
2946 int filledPolygonColor(SDL_Renderer * renderer,
const Sint16 * vx,
const Sint16 * vy,
int n, Uint32 color)
2948 Uint8 *c = (Uint8 *)&color;
2966 int filledPolygonRGBA(SDL_Renderer * renderer,
const Sint16 * vx,
const Sint16 * vy,
int n, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
2988 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)
2993 int texture_x_walker;
2994 int texture_y_start;
2995 SDL_Rect source_rect,dst_rect;
2996 int pixels_written,write_width;
3015 texture_x_walker = (x1 - texture_dx) % texture_w;
3016 if (texture_x_walker < 0){
3017 texture_x_walker = texture_w + texture_x_walker ;
3020 texture_y_start = (y + texture_dy) % texture_h;
3021 if (texture_y_start < 0){
3022 texture_y_start = texture_h + texture_y_start;
3026 source_rect.y = texture_y_start;
3027 source_rect.x = texture_x_walker;
3035 if (w <= texture_w -texture_x_walker){
3037 source_rect.x = texture_x_walker;
3039 result = (SDL_RenderCopy(renderer, texture, &source_rect ,&dst_rect) == 0);
3042 pixels_written = texture_w - texture_x_walker;
3043 source_rect.w = pixels_written;
3044 source_rect.x = texture_x_walker;
3046 result |= (SDL_RenderCopy(renderer, texture, &source_rect , &dst_rect) == 0);
3047 write_width = texture_w;
3052 while (pixels_written < w){
3053 if (write_width >= w - pixels_written) {
3054 write_width = w - pixels_written;
3056 source_rect.w = write_width;
3057 dst_rect.x = x1 + pixels_written;
3058 result |= (SDL_RenderCopy(renderer,texture,&source_rect , &dst_rect) == 0);
3059 pixels_written += write_width;
3083 SDL_Surface * texture,
int texture_dx,
int texture_dy,
int **polyInts,
int *polyAllocated)
3088 int minx,maxx,miny, maxy;
3093 int *gfxPrimitivesPolyInts = NULL;
3094 int gfxPrimitivesPolyAllocated = 0;
3095 SDL_Texture *textureAsTexture;
3107 if ((polyInts==NULL) || (polyAllocated==NULL)) {
3109 gfxPrimitivesPolyInts = gfxPrimitivesPolyIntsGlobal;
3110 gfxPrimitivesPolyAllocated = gfxPrimitivesPolyAllocatedGlobal;
3113 gfxPrimitivesPolyInts = *polyInts;
3114 gfxPrimitivesPolyAllocated = *polyAllocated;
3120 if (!gfxPrimitivesPolyAllocated) {
3121 gfxPrimitivesPolyInts = (
int *) malloc(
sizeof(
int) * n);
3122 gfxPrimitivesPolyAllocated = n;
3124 if (gfxPrimitivesPolyAllocated < n) {
3125 gfxPrimitivesPolyInts = (
int *) realloc(gfxPrimitivesPolyInts,
sizeof(
int) * n);
3126 gfxPrimitivesPolyAllocated = n;
3133 if (gfxPrimitivesPolyInts==NULL) {
3134 gfxPrimitivesPolyAllocated = 0;
3140 if ((polyInts==NULL) || (polyAllocated==NULL)) {
3141 gfxPrimitivesPolyIntsGlobal = gfxPrimitivesPolyInts;
3142 gfxPrimitivesPolyAllocatedGlobal = gfxPrimitivesPolyAllocated;
3144 *polyInts = gfxPrimitivesPolyInts;
3145 *polyAllocated = gfxPrimitivesPolyAllocated;
3151 if (gfxPrimitivesPolyInts==NULL) {
3162 for (i = 1; (i < n); i++) {
3165 }
else if (vy[i] > maxy) {
3170 }
else if (vx[i] > maxx) {
3179 for (y = miny; (y <= maxy); y++) {
3181 for (i = 0; (i < n); i++) {
3194 }
else if (y1 > y2) {
3202 if ( ((y >= y1) && (y < y2)) || ((y == maxy) && (y > y1) && (y <= y2)) ) {
3203 gfxPrimitivesPolyInts[ints++] = ((65536 * (y - y1)) / (y2 - y1)) * (x2 - x1) + (65536 * x1);
3209 textureAsTexture = SDL_CreateTextureFromSurface(renderer, texture);
3210 if (textureAsTexture == NULL)
3215 for (i = 0; (i < ints); i += 2) {
3216 xa = gfxPrimitivesPolyInts[i] + 1;
3217 xa = (xa >> 16) + ((xa & 32768) >> 15);
3218 xb = gfxPrimitivesPolyInts[i+1] - 1;
3219 xb = (xb >> 16) + ((xb & 32768) >> 15);
3220 result |=
_HLineTextured(renderer, xa, xb, y, textureAsTexture, texture->w, texture->h, texture_dx, texture_dy);
3222 SDL_DestroyTexture(textureAsTexture);
3244 int texturedPolygon(SDL_Renderer *renderer,
const Sint16 * vx,
const Sint16 * vy,
int n, SDL_Surface *texture,
int texture_dx,
int texture_dy)
3249 return (
texturedPolygonMT(renderer, vx, vy, n, texture, texture_dx, texture_dy, NULL, NULL));
3257 static SDL_Texture *gfxPrimitivesFont[256];
3262 static const unsigned char *currentFontdata = gfxPrimitivesFontdata;
3267 static Uint32 charWidth = 8;
3272 static Uint32 charHeight = 8;
3277 static Uint32 charWidthLocal = 8;
3282 static Uint32 charHeightLocal = 8;
3287 static Uint32 charPitch = 1;
3292 static Uint32 charRotation = 0;
3297 static Uint32 charSize = 8;
3316 if ((fontdata) && (cw) && (ch)) {
3317 currentFontdata = (
unsigned char *)fontdata;
3321 currentFontdata = gfxPrimitivesFontdata;
3326 charPitch = (charWidth+7)/8;
3327 charSize = charPitch * charHeight;
3330 if ((charRotation==1) || (charRotation==3))
3332 charWidthLocal = charHeight;
3333 charHeightLocal = charWidth;
3337 charWidthLocal = charWidth;
3338 charHeightLocal = charHeight;
3342 for (i = 0; i < 256; i++) {
3343 if (gfxPrimitivesFont[i]) {
3344 SDL_DestroyTexture(gfxPrimitivesFont[i]);
3345 gfxPrimitivesFont[i] = NULL;
3362 rotation = rotation & 3;
3363 if (charRotation != rotation)
3366 charRotation = rotation;
3369 if ((charRotation==1) || (charRotation==3))
3371 charWidthLocal = charHeight;
3372 charHeightLocal = charWidth;
3376 charWidthLocal = charWidth;
3377 charHeightLocal = charHeight;
3381 for (i = 0; i < 256; i++) {
3382 if (gfxPrimitivesFont[i]) {
3383 SDL_DestroyTexture(gfxPrimitivesFont[i]);
3384 gfxPrimitivesFont[i] = NULL;
3404 int characterRGBA(SDL_Renderer *renderer, Sint16 x, Sint16 y,
char c, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
3410 const unsigned char *charpos;
3415 SDL_Surface *character;
3416 SDL_Surface *rotatedCharacter;
3424 srect.w = charWidthLocal;
3425 srect.h = charHeightLocal;
3432 drect.w = charWidthLocal;
3433 drect.h = charHeightLocal;
3436 ci = (
unsigned char) c;
3442 if (gfxPrimitivesFont[ci] == NULL) {
3446 character = SDL_CreateRGBSurface(SDL_SWSURFACE,
3447 charWidth, charHeight, 32,
3448 0xFF000000, 0x00FF0000, 0x0000FF00, 0x000000FF);
3449 if (character == NULL) {
3453 charpos = currentFontdata + ci * charSize;
3454 linepos = (Uint8 *)character->pixels;
3455 pitch = character->pitch;
3461 for (iy = 0; iy < charHeight; iy++) {
3464 for (ix = 0; ix < charWidth; ix++) {
3465 if (!(mask >>= 1)) {
3470 *(Uint32 *)curpos = 0xffffffff;
3472 *(Uint32 *)curpos = 0;
3483 SDL_FreeSurface(character);
3484 character = rotatedCharacter;
3488 gfxPrimitivesFont[ci] = SDL_CreateTextureFromSurface(renderer, character);
3489 SDL_FreeSurface(character);
3494 if (gfxPrimitivesFont[ci] == NULL) {
3503 result |= SDL_SetTextureColorMod(gfxPrimitivesFont[ci], r, g, b);
3504 result |= SDL_SetTextureAlphaMod(gfxPrimitivesFont[ci], a);
3509 result |= SDL_RenderCopy(renderer, gfxPrimitivesFont[ci], &srect, &drect);
3526 int characterColor(SDL_Renderer * renderer, Sint16 x, Sint16 y,
char c, Uint32 color)
3528 Uint8 *co = (Uint8 *)&color;
3529 return characterRGBA(renderer, x, y, c, co[0], co[1], co[2], co[3]);
3547 int stringColor(SDL_Renderer * renderer, Sint16 x, Sint16 y,
const char *s, Uint32 color)
3549 Uint8 *c = (Uint8 *)&color;
3550 return stringRGBA(renderer, x, y, s, c[0], c[1], c[2], c[3]);
3567 int stringRGBA(SDL_Renderer * renderer, Sint16 x, Sint16 y,
const char *s, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
3572 const char *curchar = s;
3574 while (*curchar && !result) {
3575 result |=
characterRGBA(renderer, curx, cury, *curchar, r, g, b, a);
3576 switch (charRotation)
3579 curx += charWidthLocal;
3582 curx -= charWidthLocal;
3585 cury += charHeightLocal;
3588 cury -= charHeightLocal;
3612 double blend,muk,munk;
3618 if (t>=(
double)ndata) {
3619 return(data[ndata-1]);
3629 munk = pow(1-mu,(
double)n);
3630 for (k=0;k<=n;k++) {
3641 blend /= (double)kn;
3645 blend /= (double)nkn;
3649 result += data[k] * blend;
3667 int bezierColor(SDL_Renderer * renderer,
const Sint16 * vx,
const Sint16 * vy,
int n,
int s, Uint32 color)
3669 Uint8 *c = (Uint8 *)&color;
3670 return bezierRGBA(renderer, vx, vy, n, s, c[0], c[1], c[2], c[3]);
3688 int bezierRGBA(SDL_Renderer * renderer,
const Sint16 * vx,
const Sint16 * vy,
int n,
int s, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
3692 double *x, *y, t, stepsize;
3693 Sint16 x1, y1, x2, y2;
3708 stepsize=(double)1.0/(
double)s;
3711 if ((x=(
double *)malloc(
sizeof(
double)*(n+1)))==NULL) {
3714 if ((y=(
double *)malloc(
sizeof(
double)*(n+1)))==NULL) {
3718 for (i=0; i<n; i++) {
3729 result |= SDL_SetRenderDrawBlendMode(renderer, (a == 255) ? SDL_BLENDMODE_NONE : SDL_BLENDMODE_BLEND);
3730 result |= SDL_SetRenderDrawColor(renderer, r, g, b, a);
3738 for (i = 0; i <= (n*s); i++) {
3742 result |=
line(renderer, x1, y1, x2, y2);
3787 if ((b->
dx = x2 - x1) != 0) {
3799 if ((b->
dy = y2 - y1) != 0) {
3810 if (b->
dy > b->
dx) {
3819 b->
count = (b->
dx<0) ? 0 : (
unsigned int)b->
dx;
3848 while (b->
error >= 0) {
3868 return ((b->
count) ? 0 : 1);
3885 for (p = 0; p <= m->
u; p++) {
3893 if (m->
quad4 == 0) {
3902 if (m->
quad4 == 0) {
3931 Uint16 ml1bx, Uint16 ml1by, Uint16 ml2bx, Uint16 ml2by,
3932 Uint16 ml1x, Uint16 ml1y, Uint16 ml2x, Uint16 ml2y)
3936 Uint16 m1x, m1y, m2x, m2y;
3937 Uint16 fix, fiy, lax, lay, curx, cury;
3938 Sint16 px[4], py[4];
3947 curx = (ml1x + ml2x) / 2;
3948 cury = (ml1y + ml2y) / 2;
3950 atemp1 = (fix - curx);
3951 atemp2 = (fiy - cury);
3952 ftmp1 = atemp1 * atemp1 + atemp2 * atemp2;
3953 atemp1 = (lax - curx);
3954 atemp2 = (lay - cury);
3955 ftmp2 = atemp1 * atemp1 + atemp2 * atemp2;
3957 if (ftmp1 <= ftmp2) {
3969 atemp1 = (m2x - ml2x);
3970 atemp2 = (m2y - ml2y);
3971 ftmp1 = atemp1 * atemp1 + atemp2 * atemp2;
3972 atemp1 = (m2x - ml2bx);
3973 atemp2 = (m2y - ml2by);
3974 ftmp2 = atemp1 * atemp1 + atemp2 * atemp2;
3976 if (ftmp2 >= ftmp1) {
4037 #define HYPOT(x,y) sqrt((double)(x)*(double)(x)+(double)(y)*(double)(y))
4055 float offset = (float)width / 2.f;
4058 Sint16 ptx, pty, ptxx, ptxy, ml1x, ml1y, ml2x, ml2y, ml1bx, ml1by, ml2bx, ml2by;
4101 m->
ku = m->
u + m->
u;
4102 m->
kv = m->
v + m->
v;
4104 m->
kt = m->
u - m->
kv;
4110 ang = atan((
double) m->
v / (
double) m->
u);
4115 ptx = x1 + (Sint16)lrint(offset * sang);
4116 if (m->
quad4 == 0) {
4117 pty = y1 - (Sint16)lrint(offset * cang);
4119 pty = y1 + (Sint16)lrint(offset * cang);
4122 ptx = x1 - (Sint16)lrint(offset * cang);
4123 if (m->
quad4 == 0) {
4124 pty = y1 + (Sint16)lrint(offset * sang);
4126 pty = y1 - (Sint16)lrint(offset * sang);
4131 tk = (int) (4. *
HYPOT(ptx - x1, pty - y1) *
HYPOT(m->
u, m->
v));
4146 for (q = 0; dd <= tk; q++) {
4162 if (m->
quad4 == 0) {
4176 if (m->
quad4 == 0) {
4183 if (m->
quad4 == 0) {
4194 if (m->
quad4 == 0) {
4202 _murphyIteration(m, miter, ml1bx, ml1by, ml2bx, ml2by, ml1x, ml1y, ml2x, ml2y);
4207 if (m->
quad4 == 0) {
4222 _murphyIteration(m, miter, ml1bx, ml1by, ml2bx, ml2by, ml1x, ml1y, ml2x, ml2y);
4239 int thickLineColor(SDL_Renderer *renderer, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Uint8 width, Uint32 color)
4241 Uint8 *c = (Uint8 *)&color;
4242 return thickLineRGBA(renderer, x1, y1, x2, y2, width, c[0], c[1], c[2], c[3]);
4261 int thickLineRGBA(SDL_Renderer *renderer, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Uint8 width, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
4267 if (renderer == NULL) {
4275 if ((x1 == x2) && (y1 == y2)) {
4277 return boxRGBA(renderer, x1 - wh, y1 - wh, x2 + width, y2 + width, r, g, b, a);
4284 result |= SDL_SetRenderDrawBlendMode(renderer, (a == 255) ? SDL_BLENDMODE_NONE : SDL_BLENDMODE_BLEND);
4285 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.