104 #define PNTR_IMPLEMENTATION
111 #define PNTR_PIXELFORMAT_RGBA
118 #define PNTR_PIXELFORMAT_ARGB
125 #define PNTR_ENABLE_DEFAULT_FONT
133 #define PNTR_ENABLE_TTF
142 #define PNTR_ENABLE_UTF8
153 #define PNTR_SAVE_IMAGE_TO_MEMORY
164 #define PNTR_LOAD_IMAGE_FROM_MEMORY
169 #define PNTR_ENABLE_MATH
177 #define PNTR_LOAD_FILE
185 #define PNTR_SAVE_FILE
198 #define PNTR_STB_IMAGE
211 #define PNTR_CUTE_PNG
218 #define PNTR_NO_ALPHABLEND
226 #define PNTR_NO_STDIO
233 #define PNTR_NO_LOAD_IMAGE
240 #define PNTR_NO_SAVE_IMAGE
245 #define PNTR_NO_CUTE_PNG_IMPLEMENTATION
250 #define PNTR_NO_STB_IMAGE_WRITE_IMPLEMENTATION
255 #define PNTR_NO_STB_IMAGE_IMPLEMENTATION
260 #define PNTR_NO_STB_TRUETYPE_IMPLEMENTATION
279 #if !defined(PNTR_PIXELFORMAT_RGBA) && !defined(PNTR_PIXELFORMAT_ARGB)
280 #define PNTR_PIXELFORMAT_RGBA
282 #if defined(PNTR_PIXELFORMAT_RGBA) && defined(PNTR_PIXELFORMAT_ARGB)
283 #undef PNTR_PIXELFORMAT_ARGB
286 #ifdef PNTR_PIXELFORMAT
287 #undef PNTR_PIXELFORMAT
289 #ifdef PNTR_PIXELFORMAT_RGBA
298 #define PNTR_PIXELFORMAT PNTR_PIXELFORMAT_RGBA8888
299 #elif defined(PNTR_PIXELFORMAT_ARGB)
300 #define PNTR_PIXELFORMAT PNTR_PIXELFORMAT_ARGB8888
329 #if defined(PNTR_PIXELFORMAT_RGBA)
349 #elif defined(PNTR_PIXELFORMAT_ARGB)
639 PNTR_API void pntr_draw_arc(
pntr_image* dst,
int centerX,
int centerY,
float radius,
float startAngle,
float endAngle,
int segments,
pntr_color color);
640 PNTR_API void pntr_draw_arc_fill(
pntr_image* dst,
int centerX,
int centerY,
float radius,
float startAngle,
float endAngle,
int segments,
pntr_color color);
641 PNTR_API void pntr_draw_rectangle_rounded(
pntr_image* dst,
int x,
int y,
int width,
int height,
int topLeftRadius,
int topRightRadius,
int bottomLeftRadius,
int bottomRightRadius,
pntr_color color);
642 PNTR_API void pntr_draw_rectangle_rounded_fill(
pntr_image* dst,
int x,
int y,
int width,
int height,
int cornerRadius,
pntr_color color);
649 PNTR_API void pntr_draw_image_flipped(
pntr_image* dst,
pntr_image* src,
int posX,
int posY,
bool flipHorizontal,
bool flipVertical,
bool flipDiagonal);
655 #ifdef PNTR_ENABLE_VARGS
678 PNTR_API const char* pntr_get_error(
void);
696 PNTR_API pntr_font* pntr_load_font_bmf_from_memory(
const unsigned char* fileData,
unsigned int dataSize,
const char* characters);
701 PNTR_API pntr_font* pntr_load_font_tty_from_memory(
const unsigned char* fileData,
unsigned int dataSize,
int glyphWidth,
int glyphHeight,
const char* characters);
742 #ifndef PNTR_LIGHTGRAY
746 #define PNTR_LIGHTGRAY pntr_new_color(200, 200, 200, 255)
752 #define PNTR_GRAY pntr_new_color(130, 130, 130, 255)
754 #ifndef PNTR_DARKGRAY
758 #define PNTR_DARKGRAY pntr_new_color(80, 80, 80, 255)
764 #define PNTR_YELLOW pntr_new_color(253, 249, 0, 255)
770 #define PNTR_GOLD pntr_new_color(255, 203, 0, 255)
776 #define PNTR_ORANGE pntr_new_color(255, 161, 0, 255)
782 #define PNTR_PINK pntr_new_color(255, 109, 194, 255)
788 #define PNTR_RED pntr_new_color(230, 41, 55, 255)
794 #define PNTR_MAROON pntr_new_color(190, 33, 55, 255)
800 #define PNTR_GREEN pntr_new_color(0, 228, 48, 255)
806 #define PNTR_LIME pntr_new_color(0, 158, 47, 255)
808 #ifndef PNTR_DARKGREEN
812 #define PNTR_DARKGREEN pntr_new_color(0, 117, 44, 255)
818 #define PNTR_SKYBLUE pntr_new_color(102, 191, 255, 255)
824 #define PNTR_BLUE pntr_new_color(0, 121, 241, 255)
826 #ifndef PNTR_DARKBLUE
830 #define PNTR_DARKBLUE pntr_new_color(0, 82, 172, 255)
836 #define PNTR_PURPLE pntr_new_color(200, 122, 255, 255)
842 #define PNTR_VIOLET pntr_new_color(135, 60, 190, 255)
844 #ifndef PNTR_DARKPURPLE
848 #define PNTR_DARKPURPLE pntr_new_color(112, 31, 126, 255)
854 #define PNTR_BEIGE pntr_new_color(211, 176, 131, 255)
860 #define PNTR_BROWN pntr_new_color(127, 106, 79, 255)
862 #ifndef PNTR_DARKBROWN
866 #define PNTR_DARKBROWN pntr_new_color(76, 63, 47, 255)
872 #define PNTR_WHITE pntr_new_color(255, 255, 255, 255)
875 #ifndef PNTR_WHITE_VALUE
884 #define PNTR_WHITE_VALUE 4294967295
891 #define PNTR_BLACK pntr_new_color(0, 0, 0, 255)
897 #define PNTR_BLANK pntr_new_color(0, 0, 0, 0)
903 #define PNTR_MAGENTA pntr_new_color(255, 0, 255, 255)
905 #ifndef PNTR_RAYWHITE
909 #define PNTR_RAYWHITE pntr_new_color(245, 245, 245, 255)
918 #ifdef PNTR_IMPLEMENTATION
919 #ifndef PNTR_IMPLEMENTATION_ONCE
920 #define PNTR_IMPLEMENTATION_ONCE
942 #define PNTR_MALLOC(size) malloc(size)
955 #define PNTR_FREE(ptr) free(ptr)
970 #define PNTR_REALLOC(ptr, new_size) realloc(ptr, new_size)
984 #define PNTR_MEMCPY(dest, src, n) memcpy(dest, src, n)
992 #define PNTR_MEMSET(str, c, n) memset((str), (c), (n))
1004 #if defined(PNTR_ENABLE_UTF8) && !defined(_DOXYGEN_)
1005 #include "external/utf8.h"
1006 #define PNTR_STRSTR utf8str
1007 #define PNTR_STRCHR utf8chr
1008 #define PNTR_STRLEN utf8len
1009 #define PNTR_STRSIZE utf8size
1010 #define PNTR_STRCODEPOINT utf8codepoint
1037 #define PNTR_STRSTR strstr
1049 #define PNTR_STRCHR strchr
1061 #define PNTR_STRLEN strlen
1064 #ifndef PNTR_STRSIZE
1073 #define PNTR_STRSIZE(text) ((PNTR_STRLEN(text) + (size_t)1))
1076 #ifndef PNTR_STRCODEPOINT
1083 const char* pntr_strcodepoint(
const char * str,
char* out_codepoint) {
1088 char character = str[0];
1089 *out_codepoint = character;
1101 #define PNTR_STRCODEPOINT pntr_strcodepoint
1119 #define PNTR_PI 3.1415926535897932f
1122 #ifndef PNTR_DEG2RAD
1130 #define PNTR_DEG2RAD 0.017453293f
1133 #if !defined(PNTR_ENABLE_MATH) || defined(_DOXYGEN_)
1135 float _pntr_sinf(
float x) {
1136 static const float a0 = +1.91059300966915117e-31f;
1137 static const float a1 = +1.00086760103908896f;
1138 static const float a2 = -1.21276126894734565e-2f;
1139 static const float a3 = -1.38078780785773762e-1f;
1140 static const float a4 = -2.67353392911981221e-2f;
1141 static const float a5 = +2.08026600266304389e-2f;
1142 static const float a6 = -3.03996055049204407e-3f;
1143 static const float a7 = +1.38235642404333740e-4f;
1144 return a0 + x*(a1 + x*(a2 + x*(a3 + x*(a4 + x*(a5 + x*(a6 + x*a7))))));
1154 #define PNTR_SINF _pntr_sinf
1158 float _pntr_cosf(
float x) {
1159 static const float a0 = 9.9995999154986614e-1f;
1160 static const float a1 = 1.2548995793001028e-3f;
1161 static const float a2 = -5.0648546280678015e-1f;
1162 static const float a3 = 1.2942246466519995e-2f;
1163 static const float a4 = 2.8668384702547972e-2f;
1164 static const float a5 = 7.3726485210586547e-3f;
1165 static const float a6 = -3.8510875386947414e-3f;
1166 static const float a7 = 4.7196604604366623e-4f;
1167 static const float a8 = -1.8776444013090451e-5f;
1168 return a0 + x*(a1 + x*(a2 + x*(a3 + x*(a4 + x*(a5 + x*(a6 + x*(a7 + x*a8)))))));
1178 #define PNTR_COSF _pntr_cosf
1182 float _pntr_ceilf(
float x) {
1185 return (x > i) ? (float)i + 1.0f : (
float)i;
1188 float r = x - (float)t;
1189 return (r > 0.0f) ? (float)t + 1.0f: (
float)t;
1199 #define PNTR_CEILF _pntr_ceilf
1210 #define PNTR_FABSF(a) (((a) < 0) ? -(a) : (a))
1221 #define PNTR_FLOORF(x) (float)((int)x - ((x < 0.0f) ? 1 : 0))
1225 float _pntr_fmodf(
float dividend,
float divisor) {
1226 if (divisor == 0.0f) {
1229 float quotient = dividend / divisor;
1230 return dividend - ((int)quotient) * divisor;
1240 #define PNTR_FMODF _pntr_fmodf
1245 #define PNTR_SINF sinf
1250 #define PNTR_COSF cosf
1255 #define PNTR_CEILF ceilf
1260 #define PNTR_FABSF fabsf
1265 #define PNTR_FLOORF floorf
1270 #define PNTR_SQRTF sqrtf
1275 #define PNTR_FMODF fmodf
1279 #ifndef PNTR_CLITERAL
1280 #define PNTR_CLITERAL(type) (type)
1292 #define PNTR_MAX(a, b) ((a) > (b) ? (a) : (b))
1304 #define PNTR_MIN(a, b) ((a) < (b) ? (a) : (b))
1312 #ifdef PNTR_ENABLE_TTF
1313 #ifdef PNTR_NO_STB_TRUETYPE_IMPLEMENTATION
1314 #ifdef STB_TRUETYPE_IMPLEMENTATION
1315 #undef STB_TRUETYPE_IMPLEMENTATION
1319 #ifndef STBTT_ifloor
1320 #define STBTT_ifloor(x) ((int)PNTR_FLOORF(x))
1324 #define STBTT_iceil(x) ((int)PNTR_CEILF(x))
1328 #define STBTT_fmod(x, y) PNTR_FMODF((x), (y))
1332 #define STBTT_cos(x) PNTR_COSF((float)(x))
1335 #ifndef PNTR_ENABLE_MATH
1337 float _pntr_sqrtf(
float number) {
1338 float guess = number / 2.0f;
1339 float epsilon = 1e-6f;
1341 float next_guess = 0.5f * (guess + number / guess);
1342 if (
PNTR_FABSF(next_guess - guess) < epsilon) {
1348 #define STBTT_sqrt(x) _pntr_sqrtf(x)
1352 float _pntr_pow(
float base,
float exponent) {
1353 float result = 1.0f;
1354 if (exponent >= 0) {
1355 for (
int i = 0; i < exponent; i++) {
1359 for (
int i = 0; i > exponent; i--) {
1365 #define STBTT_pow(x, y) _pntr_pow((x), (y))
1369 float _pntr_acos(
float x) {
1370 float negate = (float)(x < 0);
1372 float ret = -0.0187293f;
1374 ret = ret + 0.0742610f;
1376 ret = ret - 0.2121144f;
1378 ret = ret + 1.5707288f;
1379 ret = ret * STBTT_sqrt(1.0f - x);
1380 ret = ret - 2 * negate * ret;
1381 return negate *
PNTR_PI + ret;
1383 #define STBTT_acos(x) _pntr_acos((x))
1387 #define STBTT_sqrt(x) sqrt(x)
1390 #define STBTT_pow(x, y) pow(x, y)
1393 #define STBTT_acos(x) acos(x)
1397 #ifndef STBTT_malloc
1398 #define STBTT_malloc(x,u) ((void)(u), PNTR_MALLOC(x))
1402 #define STBTT_free(x,u) ((void)(u), PNTR_FREE(x))
1405 #ifndef STBTT_assert
1406 #define STBTT_assert(x) ((void)(0))
1409 #ifndef STBTT_strlen
1410 #define STBTT_strlen(x) PNTR_STRLEN(x)
1413 #ifndef STBTT_memcpy
1414 #define STBTT_memcpy PNTR_MEMCPY
1417 #ifndef STBTT_memset
1418 #define STBTT_memset PNTR_MEMSET
1421 #define STB_TRUETYPE_IMPLEMENTATION
1424 #if defined(__GNUC__) || defined(__clang__)
1425 #pragma GCC diagnostic push
1426 #pragma GCC diagnostic ignored "-Wpragmas"
1427 #pragma GCC diagnostic ignored "-Wunknown-pragmas"
1428 #pragma GCC diagnostic ignored "-Wsign-conversion"
1429 #pragma GCC diagnostic ignored "-Wconversion"
1432 #include "external/stb_truetype.h"
1433 #define PNTR_NO_STB_TRUETYPE_IMPLEMENTATION
1435 #if defined(__GNUC__) || defined(__clang__)
1436 #pragma GCC diagnostic pop
1440 #ifdef PNTR_ENABLE_VARGS
1455 #define PNTR_PIXEL(image, x, y) image->data[(y) * (image->pitch >> 2) + (x)]
1469 PNTR_API const char* pntr_get_error(
void) {
1470 switch (_pntr_error) {
1495 _pntr_error = error;
1497 #ifdef PNTR_SET_ERROR
1498 PNTR_SET_ERROR(error);
1517 if (width <= 0 || height <= 0) {
1522 if (image == NULL) {
1527 image->
width = width;
1532 if (image->
data == NULL) {
1564 if (image == NULL) {
1569 if (newImage == NULL) {
1589 #ifdef PNTR_NO_ALPHABLEND
1593 if (src.rgba.
a == 255) {
1597 #ifndef PNTR_NO_ALPHABLEND
1598 if (src.rgba.
a == 0) {
1602 unsigned int alpha = (
unsigned int)src.rgba.
a + 1;
1603 unsigned int dstAlpha = (
unsigned int)dst->rgba.
a * (256 - alpha);
1604 dst->rgba.
a = (
unsigned char)((alpha * 256 + dstAlpha) >> 8);
1606 if (dst->rgba.
a > 0) {
1607 dst->rgba.
r = (
unsigned char)((((
unsigned int)src.rgba.
r * alpha * 256 + (
unsigned int)dst->rgba.
r * dstAlpha) / dst->rgba.
a) >> 8);
1608 dst->rgba.
g = (
unsigned char)((((
unsigned int)src.rgba.
g * alpha * 256 + (
unsigned int)dst->rgba.
g * dstAlpha) / dst->rgba.
a) >> 8);
1609 dst->rgba.
b = (
unsigned char)((((
unsigned int)src.rgba.
b * alpha * 256 + (
unsigned int)dst->rgba.
b * dstAlpha) / dst->rgba.
a) >> 8);
1636 PNTR_API bool _pntr_rectangle_intersect(
int x,
int y,
int width,
int height,
int destX,
int destY,
int destWidth,
int destHeight,
pntr_rectangle *out) {
1637 if (width <= 0 || height <= 0) {
1643 if (out->
width <= 0) {
1673 if (image == NULL) {
1678 if (!_pntr_rectangle_intersect(x, y, width, height, 0, 0, image->
width, image->
height, &dstRect)) {
1683 if (result == NULL) {
1687 for (
int destY = 0; destY < dstRect.
height; destY++) {
1690 (
size_t)result->
pitch);
1713 if (image == NULL) {
1719 if (!_pntr_rectangle_intersect(x, y, width, height, 0, 0, image->
width, image->
height, &dstRect)) {
1725 if (subimage == NULL) {
1745 if (image == NULL) {
1762 while (--width >= 0) {
1776 if (image == NULL) {
1789 if (color.rgba.
a == 0) {
1799 for (
int y = 1; y < image->
height; y++) {
1835 .r = (
unsigned char)(hexValue >> 24) & 0xFF,
1836 .g = (
unsigned char)(hexValue >> 16) & 0xFF,
1837 .b = (
unsigned char)(hexValue >> 8) & 0xFF,
1838 .a = (
unsigned char)hexValue & 0xFF
1844 return color.rgba.
r;
1848 return color.rgba.
g;
1852 return color.rgba.
b;
1856 return color.rgba.
a;
1886 if ((color.rgba.
a == 0) || (dst == NULL) || (x < dst->clip.x) || (x >= dst->
clip.
x + dst->
clip.
width) || (y < dst->clip.y) || (y >= dst->
clip.
y + dst->
clip.
height)) {
1894 if (point != NULL) {
1900 if (dst == NULL || color.rgba.
a == 0 || points == NULL || pointsCount <= 0) {
1904 for (
int i = 0; i < pointsCount; i++) {
1920 if (dst == NULL || color.rgba.
a == 0) {
1924 int changeInX = (endPosX - startPosX);
1925 int absChangeInX = (changeInX < 0) ? -changeInX : changeInX;
1926 int changeInY = (endPosY - startPosY);
1927 int absChangeInY = (changeInY < 0) ? -changeInY : changeInY;
1930 if (startPosX == endPosX) {
1935 if (startPosY == endPosY) {
1940 int startU, startV, endU, stepV;
1942 int reversedXY = (absChangeInY < absChangeInX);
1945 A = 2 * absChangeInY;
1946 B = A - 2 * absChangeInX;
1947 P = A - absChangeInX;
1949 if (changeInX > 0) {
1962 changeInX = -changeInX;
1963 changeInY = -changeInY;
1966 stepV = (changeInY < 0) ? -1 : 1;
1971 A = 2 * absChangeInX;
1972 B = A - 2 * absChangeInY;
1973 P = A - absChangeInY;
1975 if (changeInY > 0) {
1985 changeInX = -changeInX;
1986 changeInY = -changeInY;
1989 stepV = (changeInX < 0) ? -1 : 1;
1994 for (
int u = startU + 1, v = startV; u <= endU; u++) {
2013 if (color.rgba.
a == 0 || dst == NULL || numPoints <= 0 || points == NULL) {
2017 if (numPoints == 1) {
2018 pntr_draw_point_vec(dst, points, color);
2022 for (
int i = 0; i < numPoints - 1; i++) {
2023 pntr_draw_line_vec(dst, points[i], points[i + 1], color);
2039 if (color.rgba.
a == 0 || dst == NULL || posY < dst->clip.y || posY >= dst->
clip.
y + dst->
clip.
height || posX >= dst->
clip.
x + dst->
clip.
width || posX + width < dst->clip.x) {
2043 if (posX < dst->clip.x) {
2044 width += posX - dst->
clip.
x;
2051 if (color.rgba.
a == 255) {
2056 while (--width >= 0) {
2074 if (color.rgba.
a == 0 || dst == NULL || posX < dst->clip.x || posX >= dst->
clip.
x + dst->
clip.
width || posY >= dst->
clip.
y + dst->
clip.
height || posY + height < dst->clip.y) {
2078 if (posY < dst->clip.y) {
2079 height += posY - dst->
clip.
y;
2086 if (color.rgba.
a == 255) {
2087 for (
int y = 0; y < height; y++) {
2092 for (
int y = 0; y < height; y++) {
2123 if (color.rgba.
a == 0 || dst == NULL || width <= 0 || height <= 0) {
2134 for (
int i = 0; i < thickness; i++) {
2140 pntr_draw_rectangle_thick(dst, rect.
x, rect.
y, rect.
width, rect.
height, thickness, color);
2169 if (color.rgba.
a == 0 || dst == NULL) {
2178 if (color.rgba.
a == 255) {
2182 for (
int y = rect.
y + 1; y < rect.
y + rect.
height; y++) {
2187 for (
int y = 0; y < rect.
height; y++) {
2189 for (
int x = 0; x < rect.
width; x++) {
2206 float width = (float)rect.
width;
2207 float height = (
float)rect.
height;
2208 for (
int x = dstRect.
x; x < dstRect.
x + dstRect.
width; x++) {
2209 float factorX = (float)(x - rect.
x) / width;
2210 for (
int y = dstRect.
y; y < dstRect.
y + dstRect.
height; y++) {
2212 topLeft, bottomLeft,
2213 topRight, bottomRight,
2215 (
float)(y - rect.
y) / height
2222 pntr_draw_rectangle_gradient_rec(dst, PNTR_CLITERAL(
pntr_rectangle) {x, y, width, height}, topLeft, topRight, bottomLeft, bottomRight);
2242 if (dst == NULL || color.rgba.
a == 0) {
2251 if (centerX + radius < dst->clip.x || centerY + radius < dst->clip.y || centerX - radius > dst->
clip.
x + dst->
clip.
width || centerY - radius > dst->
clip.
y + dst->
clip.
height) {
2255 int largestX = radius;
2256 int r2 = radius * radius;
2257 for (
int y = 0; y <= radius; ++y) {
2259 for (
int x = largestX; x >= 0; --x) {
2260 if (x * x + y2 <= r2) {
2294 if (dst == NULL || color.rgba.
a == 0 || radius == 0 || centerX + radius < dst->clip.x || centerX - radius >= dst->
clip.
x + dst->
clip.
width || centerY + radius < dst->clip.y || centerY - radius >= dst->
clip.
y + dst->
clip.
height) {
2298 int largestX = radius;
2299 int r2 = radius * radius;
2300 for (
int y = 0; y <= radius; ++y) {
2302 for (
int x = largestX; x >= 0; --x) {
2303 if (x * x + y2 <= r2) {
2328 if (dst == NULL || radiusX == 0 || radiusY == 0 || color.rgba.
a == 0) {
2340 int radiusXSquared = radiusX * radiusX;
2341 int radiusXSquared2 = radiusXSquared * 2;
2342 int radiusYSquared = radiusY * radiusY;
2343 int radiusYSquared2 = radiusYSquared * 2;
2344 int error = radiusYSquared - radiusXSquared * radiusY;
2346 while (radiusY >= 0) {
2354 error += radiusYSquared2 * x + radiusYSquared;
2358 error -= radiusXSquared2 * radiusY - radiusXSquared;
2385 if (dst == NULL || radiusX == 0 || radiusY == 0 || color.rgba.
a == 0 || centerX + radiusX < dst->clip.x || centerX - radiusX > dst->
clip.
x + dst->
clip.
width || centerY + radiusY < dst->clip.y || centerY - radiusY > dst->
clip.
y + dst->
clip.
height) {
2390 int radiusXSquared = radiusX * radiusX;
2391 int radiusXSquared2 = radiusXSquared * 2;
2392 int radiusYSquared = radiusY * radiusY;
2393 int radiusYSquared2 = radiusYSquared * 2;
2394 int error = radiusYSquared - radiusXSquared * radiusY;
2396 while (radiusY >= 0) {
2404 error += radiusYSquared2 * x + radiusYSquared;
2408 error -= radiusXSquared2 * radiusY - radiusXSquared;
2470 if (dst == NULL || color.rgba.
a == 0 || numPoints <= 0 || points == NULL) {
2475 for (
int i = 0; i < numPoints; i++) {
2476 if (i < numPoints - 1) {
2477 nextPointIndex = i + 1;
2483 pntr_draw_line(dst, points[i].x, points[i].y, points[nextPointIndex].x, points[nextPointIndex].y, color);
2488 if (dst == NULL || points == NULL || numPoints <= 0 || color.rgba.
a == 0) {
2493 int ymin = dst->
height + 1;
2495 for (
int i = 0; i < numPoints; ++i) {
2496 ymin =
PNTR_MIN(ymin, points[i].y);
2497 ymax =
PNTR_MAX(ymax, points[i].y);
2501 for (
int yy = ymin; yy <= ymax; yy++) {
2502 int xmin = dst->
width + 1;
2504 for (
int i = 0; i < numPoints; ++i) {
2506 pntr_vector point2 = i < (numPoints - 1) ? points[i + 1] : points[0];
2508 if ((point1.
y > yy) != (point2.
y > yy)) {
2509 int testx = point1.
x + ((point2.
x - point1.
x) * (yy - point1.
y)) / (point2.
y - point1.
y);
2533 pntr_draw_polygon_fill(dst, points, 3, color);
2536 PNTR_API void pntr_draw_arc(
pntr_image* dst,
int centerX,
int centerY,
float radius,
float startAngle,
float endAngle,
int segments,
pntr_color color) {
2537 if (radius == 0.0f) {
2545 float startAngleRad = startAngle *
PNTR_PI / 180.0f;
2546 float endAngleRad = endAngle *
PNTR_PI / 180.0f;
2549 float stepAngle = (endAngleRad - startAngleRad) / (
float)(segments);
2567 for (
int i = 0; i < segments; i++) {
2568 endAngleRad = startAngleRad + (float)i * stepAngle;
2570 centerX + (
int)(radius *
PNTR_COSF(endAngleRad)),
2571 centerY + (
int)(radius *
PNTR_SINF(endAngleRad)),
2576 PNTR_API void pntr_draw_arc_fill(
pntr_image* dst,
int centerX,
int centerY,
float radius,
float startAngle,
float endAngle,
int segments,
pntr_color color) {
2577 if (radius <= 0.0f) {
2584 float startAngleRad = startAngle *
PNTR_PI / 180.0f;
2585 float endAngleRad = endAngle *
PNTR_PI / 180.0f;
2588 float stepAngle = (endAngleRad - startAngleRad) / (
float)segments;
2592 for (
int i = 0; i < segments; i++) {
2593 endAngleRad = startAngleRad + (float)i * stepAngle;
2594 points[i].
x = centerX + (int)(radius *
PNTR_COSF(endAngleRad));
2595 points[i].
y = centerY + (int)(radius *
PNTR_SINF(endAngleRad));
2598 points[segments].
x = centerX;
2599 points[segments].
y = centerY;
2601 pntr_draw_polygon_fill(dst, points, segments + 1, color);
2605 PNTR_API void pntr_draw_rectangle_rounded(
pntr_image* dst,
int x,
int y,
int width,
int height,
int topLeftRadius,
int topRightRadius,
int bottomLeftRadius,
int bottomRightRadius,
pntr_color color) {
2609 pntr_draw_line_vertical(dst, x + width, y + topRightRadius, height - topRightRadius - bottomRightRadius, color);
2612 pntr_draw_arc(dst, x + topLeftRadius, y + topLeftRadius, (
float)topLeftRadius, 180.0f, 270.0f, topLeftRadius * 2, color);
2613 pntr_draw_arc(dst, x + width - topRightRadius, y + topRightRadius, (
float)topRightRadius, 0.0f, -90.0f, topRightRadius * 2, color);
2614 pntr_draw_arc(dst, x + bottomLeftRadius, y + height - bottomLeftRadius, (
float)bottomLeftRadius, -180.0f, -270.0f, bottomLeftRadius * 2, color);
2615 pntr_draw_arc(dst, x + width - bottomRightRadius, y + height - bottomRightRadius, (
float)bottomRightRadius, 0.0f, 90.0f, bottomRightRadius * 2, color);
2618 PNTR_API void pntr_draw_rectangle_rounded_fill(
pntr_image* dst,
int x,
int y,
int width,
int height,
int cornerRadius,
pntr_color color) {
2624 pntr_draw_circle_fill(dst, x + width - cornerRadius, y + height - cornerRadius, cornerRadius, color);
2628 pntr_draw_rectangle_fill(dst, x + width - cornerRadius, y + cornerRadius, cornerRadius, height - cornerRadius * 2, color);
2630 pntr_draw_rectangle_fill(dst, x + cornerRadius, y + height - cornerRadius, width - cornerRadius * 2, cornerRadius, color);
2633 pntr_draw_rectangle_fill(dst, x + cornerRadius, y + cornerRadius, width - cornerRadius * 2, height - cornerRadius * 2, color);
2646 if (image == NULL || x < 0 || y < 0 || x >= image->
width || y >= image->
height) {
2666 if (filePath == NULL) {
2686 #ifndef PNTR_LOAD_IMAGE_FROM_MEMORY
2687 #ifdef PNTR_STB_IMAGE
2688 #include "extensions/pntr_stb_image.h"
2689 #elif defined(PNTR_CUTE_PNG)
2690 #include "extensions/pntr_cute_png.h"
2693 #ifdef PNTR_NO_LOAD_IMAGE
2694 #define PNTR_LOAD_IMAGE_FROM_MEMORY(type, fileData, dataSize) NULL
2697 #include "extensions/pntr_stb_image.h"
2702 #ifndef PNTR_SAVE_IMAGE_TO_MEMORY
2703 #ifdef PNTR_STB_IMAGE
2704 #include "extensions/pntr_stb_image_write.h"
2705 #elif defined(PNTR_CUTE_PNG)
2706 #include "extensions/pntr_cute_png.h"
2709 #ifdef PNTR_NO_SAVE_IMAGE
2710 #define PNTR_SAVE_IMAGE_TO_MEMORY(image, type, dataSize) NULL
2713 #include "extensions/pntr_stb_image_write.h"
2732 if (fileData == NULL || dataSize == 0) {
2747 if (fileName == NULL) {
2751 unsigned int bytesRead;
2752 const unsigned char* fileData =
pntr_load_file(fileName, &bytesRead);
2753 if (fileData == NULL) {
2837 if (!_pntr_rectangle_intersect(srcRect.
x, srcRect.
y,
2846 if (posX < dst->clip.x) {
2847 srcRect.
x -= posX - dst->
clip.
x;
2851 if (posY < dst->clip.y) {
2852 srcRect.
y -= posY - dst->
clip.
y;
2859 if (!_pntr_rectangle_intersect(dstRect.
x, dstRect.
y,
2868 int dst_skip = dst->
pitch >> 2;
2869 int src_skip = src->
pitch >> 2;
2876 while (dstRect.
height-- > 0) {
2877 for (
int x = 0; x < dstRect.
width; ++x) {
2881 dstPixel += dst_skip;
2882 srcPixel += src_skip;
2886 while (dstRect.
height-- > 0) {
2887 for (
int x = 0; x < dstRect.
width; ++x) {
2891 dstPixel += dst_skip;
2892 srcPixel += src_skip;
2910 if (imageData == NULL || width <= 0 || height <= 0 || pixelFormat < 0) {
2915 switch (pixelFormat) {
2918 if (output == NULL) {
2922 unsigned char* source = (
unsigned char*)imageData;
2923 for (
int i = 0; i < width * height; i++) {
2935 for (
int i = 0; i < width * height; i++) {
2961 if (image == NULL || scaleX <= 0.0f || scaleY <= 0.0f) {
2981 if (image == NULL || newWidth <= 0 || newHeight <= 0 || filter < 0) {
2986 if (output == NULL) {
2992 float xRatio = (float)image->
width / (
float)newWidth;
2993 float yRatio = (float)image->
height / (
float)newHeight;
2995 for (
int y = 0; y < newHeight; y++) {
2996 float srcY = (float)y * yRatio;
2997 int srcYPixel = (int)srcY;
2998 int srcYPixelPlusOne = y == newHeight - 1 ? (int)srcY : (
int)srcY + 1;
2999 for (
int x = 0; x < newWidth; x++) {
3000 float srcX = (float)x * xRatio;
3001 int srcXPixel = (int)srcX;
3002 int srcXPixelPlusOne = x == newWidth - 1 ? (int)srcX : (
int)srcX + 1;
3004 image->
data[srcYPixel * (image->
pitch >> 2) + srcXPixel],
3005 image->
data[srcYPixelPlusOne * (image->
pitch >> 2) + srcXPixel],
3006 image->
data[srcYPixel * (image->
pitch >> 2) + srcXPixelPlusOne],
3007 image->
data[srcYPixelPlusOne * (image->
pitch >> 2) + srcXPixelPlusOne],
3017 int xRatio = (image->
width << 16) / newWidth + 1;
3018 int yRatio = (image->
height << 16) / newHeight + 1;
3020 for (
int y = 0; y < newHeight; y++) {
3021 int y2 = (y * yRatio) >> 16;
3022 for (
int x = 0; x < newWidth; x++) {
3045 if (image == NULL) {
3051 for (
int y = 0; y < image->
height / 2; y++) {
3052 for (
int x = 0; x < image->
width; x++) {
3061 for (
int y = 0; y < image->
height; y++) {
3062 for (
int x = 0; x < image->
width / 2; x++) {
3079 if (image == NULL) {
3083 for (
int y = image->
clip.
y; y < image->clip.y + image->
clip.
height; y++) {
3085 for (
int x = image->
clip.
x; x < image->clip.x + image->
clip.
width; x++) {
3111 .r = (
unsigned char)(((
float)color.rgba.
r / 255.0f * (
float)tint.rgba.
r / 255.0f) * 255.0f),
3112 .g = (
unsigned char)(((float)color.rgba.
g / 255.0f * (
float)tint.rgba.
g / 255.0f) * 255.0f),
3113 .b = (
unsigned char)(((
float)color.rgba.
b / 255.0f * (float)tint.rgba.
b / 255.0f) * 255.0f),
3114 .a = (
unsigned char)(((float)color.rgba.
a / 255.0f * (
float)tint.rgba.
a / 255.0f) * 255.0f)
3128 if (factor < -1.0f) {
3131 else if (factor > 1.0f) {
3135 if (factor < 0.0f) {
3136 factor = 1.0f + factor;
3137 color.rgba.
r = (
unsigned char)((
float)color.rgba.
r * factor);
3138 color.rgba.
g = (
unsigned char)((
float)color.rgba.
g * factor);
3139 color.rgba.
b = (
unsigned char)((
float)color.rgba.
b * factor);
3142 color.rgba.
r = (
unsigned char)(((
float)(255 - color.rgba.
r) * factor) + color.rgba.
r);
3143 color.rgba.
g = (
unsigned char)(((
float)(255 - color.rgba.
g) * factor) + color.rgba.
g);
3144 color.rgba.
b = (
unsigned char)(((
float)(255 - color.rgba.
b) * factor) + color.rgba.
b);
3161 if (factor < -1.0f) {
3164 else if (factor > 1.0f) {
3168 if (factor < 0.0f) {
3169 color.rgba.
a = (
unsigned char)((
float)color.rgba.
a * (1.0f + factor));
3172 color.rgba.
a = (
unsigned char)(((
float)(255 - color.rgba.
a) * factor) + color.rgba.
a);
3187 if (image == NULL) {
3191 if (factor < -1.0f) {
3194 else if (factor > 1.0f) {
3198 for (
int y = image->
clip.
y; y < image->clip.y + image->
clip.
height; y++) {
3200 for (
int x = 0; x < image->
clip.
width; x++) {
3201 if (pixel->rgba.
a > 0) {
3222 switch (dstPixelFormat) {
3224 *((uint32_t*)(dstPtr)) = ((uint32_t)color.rgba.
a << 24) | ((uint32_t)color.rgba.
b << 16) | ((uint32_t)color.rgba.
g << 8) | (uint32_t)color.rgba.
r;
3227 *((uint32_t*)(dstPtr)) = ((uint32_t)color.rgba.
b << 24) | ((uint32_t)color.rgba.
g << 16) | ((uint32_t)color.rgba.
r << 8) | (uint32_t)color.rgba.
a;
3230 float r = (float)color.rgba.
r / 255.0f;
3231 float g = (
float)color.rgba.
g / 255.0f;
3232 float b = (float)color.rgba.
b / 255.0f;
3233 ((
unsigned char *)dstPtr)[0] = (
unsigned char)((r * 0.299f + g * 0.587f + b * 0.114f) * 255.0f);
3248 switch (srcPixelFormat) {
3252 .r = ((
unsigned char *)srcPtr)[0],
3253 .g = ((
unsigned char *)srcPtr)[1],
3254 .b = ((
unsigned char *)srcPtr)[2],
3255 .a = ((
unsigned char *)srcPtr)[3]
3261 .a = ((
unsigned char *)srcPtr)[0],
3262 .r = ((
unsigned char *)srcPtr)[1],
3263 .g = ((
unsigned char *)srcPtr)[2],
3264 .b = ((
unsigned char *)srcPtr)[3]
3274 .a = ((
unsigned char*)srcPtr)[0]
3291 if (image == NULL) {
3295 for (
int y = image->
clip.
y; y < image->clip.y + image->
clip.
height; y++) {
3297 for (
int x = 0; x < image->
clip.
width; x++) {
3316 if (image == NULL) {
3320 return pntr_load_font_bmf_from_image(image, characters);
3323 PNTR_API pntr_font* pntr_load_font_bmf_from_memory(
const unsigned char* fileData,
unsigned int dataSize,
const char* characters) {
3324 if (fileData == NULL || dataSize == 0 || characters == NULL) {
3329 if (image == NULL) {
3333 return pntr_load_font_bmf_from_image(image, characters);
3348 if (numCharacters <= 0) {
3383 font->
atlas = atlas;
3389 if (image == NULL || characters == NULL) {
3397 int numCharacters = 0;
3398 for (
int i = 0; i < image->
width; i++) {
3410 int currentCharacter = 0;
3411 for (
int i = 1; i < image->
width; i++) {
3413 font->
characters[currentCharacter] = characters[currentCharacter];
3414 font->
srcRects[currentCharacter] = currentRectangle;
3418 .width = currentRectangle.
width,
3419 .height = currentRectangle.
height,
3421 currentRectangle.
width = 0;
3422 currentRectangle.
x = i + 1;
3427 currentRectangle.
width++;
3431 #ifdef PNTR_ENABLE_UTF8
3452 if (image == NULL) {
3456 pntr_font* output = pntr_load_font_tty_from_image(image, glyphWidth, glyphHeight, characters);
3457 if (output == NULL) {
3464 PNTR_API pntr_font* pntr_load_font_tty_from_memory(
const unsigned char* fileData,
unsigned int dataSize,
int glyphWidth,
int glyphHeight,
const char* characters) {
3465 if (fileData == NULL || dataSize == 0 || characters == NULL || glyphWidth <= 0 || glyphHeight <= 0) {
3470 if (image == NULL) {
3474 pntr_font* output = pntr_load_font_tty_from_image(image, glyphWidth, glyphHeight, characters);
3475 if (output == NULL) {
3483 if (image == NULL || characters == NULL || glyphWidth <= 0 || glyphHeight <= 0) {
3497 for (
int currentCharIndex = 0; currentCharIndex < font->
charactersLen; currentCharIndex++) {
3500 .x = (currentCharIndex % (image->
width / glyphWidth)) * glyphWidth,
3501 .y = (currentCharIndex / (image->
width / glyphWidth)) * glyphHeight,
3502 .width = glyphWidth,
3503 .height = glyphHeight
3510 .width = glyphWidth,
3511 .height = glyphHeight,
3515 font->
characters[currentCharIndex] = characters[currentCharIndex];
3518 #ifdef PNTR_ENABLE_UTF8
3555 if (atlas == NULL) {
3561 if (output == NULL) {
3584 if (font == NULL || scaleX <= 0.0f || scaleY <= 0.0f) {
3590 if (output == NULL) {
3597 output->
atlas = resizedAtlas;
3627 if (dst == NULL || font == NULL || text == NULL) {
3633 int tallestCharacter = 0;
3638 if (codepoint ==
'\n') {
3641 y += tallestCharacter;
3645 if (foundCharacter != NULL) {
3648 #ifdef PNTR_ENABLE_UTF8
3651 int i = (int)(foundCharacter - font->
characters);
3655 if (codepoint !=
' ') {
3660 if (tallestCharacter < font->glyphRects[i].y + font->
glyphRects[i].
height) {
3682 if (dst == NULL || font == NULL || text == NULL) {
3692 int currentLineLength = 0;
3696 while (text[i] !=
'\0') {
3697 if (text[i] ==
' ' || text[i] ==
'\n') {
3699 if (
pntr_measure_text_ex(font, text + i - currentLineLength, currentLineLength).x >= maxWidth) {
3701 newText[lastSpace] =
'\n';
3702 currentLineLength = i - lastSpace - 1;
3707 currentLineLength++;
3712 if (
pntr_measure_text_ex(font, text + i - currentLineLength, currentLineLength).x >= maxWidth) {
3713 newText[lastSpace] =
'\n';
3721 #ifdef PNTR_ENABLE_VARGS
3739 #ifndef PNTR_DRAW_TEXT_EX_STRING_LENGTH
3740 #define PNTR_DRAW_TEXT_EX_STRING_LENGTH 256
3742 char output[PNTR_DRAW_TEXT_EX_STRING_LENGTH];
3745 va_start(arg_ptr, text);
3746 vsnprintf(output, PNTR_DRAW_TEXT_EX_STRING_LENGTH, text, arg_ptr);
3775 if (font == NULL || text == NULL) {
3788 if (textLength > 0 && index++ >= textLength) {
3793 if (codepoint ==
'\n') {
3794 output.
y += currentY;
3801 if (foundCharacter != NULL) {
3803 #ifdef PNTR_ENABLE_UTF8
3806 int i = (int)(foundCharacter - font->
characters);
3810 if (currentX > output.
x) {
3811 output.
x = currentX;
3822 output.
y += currentY;
3838 if (size.
x <= 0 || size.
y <= 0) {
3843 if (output == NULL) {
3870 #ifdef PNTR_DEFAULT_FONT
3871 return PNTR_DEFAULT_FONT();
3872 #elif defined(PNTR_ENABLE_DEFAULT_FONT)
3875 #include "external/font8x8_basic.h"
3879 #define PNTR_DEFAULT_FONT_NAME font8x8_basic
3880 #define PNTR_DEFAULT_FONT_GLYPH_WIDTH 8
3881 #define PNTR_DEFAULT_FONT_GLYPH_HEIGHT 8
3882 #define PNTR_DEFAULT_FONT_CHARACTERS_LEN 97
3886 PNTR_DEFAULT_FONT_GLYPH_WIDTH * PNTR_DEFAULT_FONT_CHARACTERS_LEN,
3887 PNTR_DEFAULT_FONT_GLYPH_HEIGHT,
3889 if (atlas == NULL) {
3894 for (
int i = 0; i < PNTR_DEFAULT_FONT_CHARACTERS_LEN; i++) {
3895 const unsigned char* bitmap = PNTR_DEFAULT_FONT_NAME[i];
3896 for (
int x = 0; x < 8; x++) {
3897 for (
int y = 0; y < 8; y++) {
3898 if (bitmap[y] & 1 << x) {
3906 char characters[PNTR_DEFAULT_FONT_CHARACTERS_LEN];
3907 for (
int i = 0; i < PNTR_DEFAULT_FONT_CHARACTERS_LEN; i++) {
3908 characters[i] = (char)(i + 32);
3912 pntr_font* font = pntr_load_font_tty_from_image(atlas, PNTR_DEFAULT_FONT_GLYPH_WIDTH, PNTR_DEFAULT_FONT_GLYPH_HEIGHT, characters);
3939 if (fileName == NULL || fontSize <= 0) {
3943 #ifndef PNTR_ENABLE_TTF
3946 unsigned int bytesRead;
3948 if (fileData == NULL) {
3975 if (fileData == NULL || dataSize == 0 || fontSize <= 0) {
3979 #ifndef PNTR_ENABLE_TTF
3983 #define PNTR_FONT_TTF_GLYPH_START 32
3986 #ifndef PNTR_FONT_TTF_GLYPH_NUM
3987 #ifdef PNTR_ENABLE_UTF8
3990 #define PNTR_FONT_TTF_GLYPH_NUM 1295
3993 #define PNTR_FONT_TTF_GLYPH_NUM 95
3999 int rows = PNTR_FONT_TTF_GLYPH_NUM / columns;
4000 int width = fontSize * columns;
4001 int height = fontSize * rows;
4002 unsigned char* bitmap = (
unsigned char*)
PNTR_MALLOC((
size_t)(width * height));
4003 if (bitmap == NULL) {
4008 stbtt_bakedchar characterData[PNTR_FONT_TTF_GLYPH_NUM];
4009 int result = stbtt_BakeFontBitmap(fileData, 0, (
float)fontSize, bitmap, width, height, PNTR_FONT_TTF_GLYPH_START, PNTR_FONT_TTF_GLYPH_NUM, characterData);
4020 if (atlas == NULL) {
4029 size_t charactersSize =
sizeof(
pntr_codepoint_t) * (
size_t)PNTR_FONT_TTF_GLYPH_NUM;
4030 pntr_font* font = _pntr_new_font(PNTR_FONT_TTF_GLYPH_NUM, charactersSize, atlas);
4037 #ifdef PNTR_ENABLE_UTF8
4042 for (
int i = 0; i < PNTR_FONT_TTF_GLYPH_NUM; i++) {
4045 .x = characterData[i].x0,
4046 .y = characterData[i].y0,
4047 .width = characterData[i].x1 - characterData[i].x0,
4048 .height = characterData[i].y1 - characterData[i].y0
4053 .x = (int)characterData[i].xoff,
4054 .y = (
int)(characterData[i].yoff + ((float)fontSize / 1.5f)),
4055 .width = (
int)characterData[i].xadvance,
4056 .height = (int)((
float)fontSize / 3.0f)
4060 #ifndef PNTR_ENABLE_UTF8
4061 font->
characters[i] = (char)(PNTR_FONT_TTF_GLYPH_START + i);
4064 destination = utf8catcodepoint(destination, (
pntr_codepoint_t)(PNTR_FONT_TTF_GLYPH_START + i), charactersSize - (
size_t)(destination - font->
characters));
4068 #ifdef PNTR_ENABLE_UTF8
4094 .r = 255 - color.rgba.
r,
4095 .g = 255 - color.rgba.
g,
4096 .b = 255 - color.rgba.
b,
4110 if (image == NULL) {
4114 for (
int y = image->
clip.
y; y < image->clip.y + image->
clip.
height; y++) {
4116 for (
int x = 0; x < image->
clip.
width; x++) {
4132 if (image == NULL) {
4136 if (factor < -1.0f) {
4139 else if (factor > 1.0f) {
4143 for (
int y = image->
clip.
y; y < image->clip.y + image->
clip.
height; y++) {
4145 for (
int x = 0; x < image->
clip.
width; x++) {
4152 #ifndef PNTR_LOAD_FILE
4153 #ifdef PNTR_NO_STDIO
4154 #define PNTR_LOAD_FILE(fileName, bytesRead) NULL
4176 if (fileName == NULL) {
4180 #ifdef PNTR_LOAD_FILE
4183 FILE* file = fopen(fileName,
"rb");
4185 if (bytesRead != NULL) {
4191 fseek(file, 0, SEEK_END);
4192 size_t size = (size_t)ftell(file);
4193 fseek(file, 0, SEEK_SET);
4197 if (bytesRead != NULL) {
4203 unsigned char* data = (
unsigned char*)
PNTR_MALLOC(size *
sizeof(
unsigned char));
4206 if (bytesRead != NULL) {
4213 unsigned int bytes = (
unsigned int)fread(data,
sizeof(
unsigned char), size, file);
4215 if (bytesRead != NULL) {
4232 unsigned int bytesRead;
4241 if (output == NULL) {
4247 output[bytesRead] =
'\0';
4249 return (
const char*)output;
4263 #ifndef PNTR_SAVE_FILE
4264 #ifdef PNTR_NO_STDIO
4265 #define PNTR_SAVE_FILE(fileName, data, bytesToWrite) NULL
4285 if (fileName == NULL || data == NULL) {
4289 #ifdef PNTR_SAVE_FILE
4292 FILE *file = fopen(fileName,
"wb");
4297 size_t count = fwrite(data,
sizeof(
unsigned char), bytesToWrite, file);
4304 if (count != (
size_t)bytesToWrite) {
4309 return fclose(file) == 0;
4323 if (width <= 0 || height <= 0 || pixelFormat < 0) {
4327 int bitsPerPixel = 0;
4328 int bitsPerByte = 8;
4329 switch (pixelFormat) {
4332 bitsPerPixel = (int)
sizeof(
pntr_color) * bitsPerByte;
4335 bitsPerPixel = (int)
sizeof(
unsigned char) * bitsPerByte;
4338 bitsPerPixel = (int)
sizeof(
pntr_color) * bitsPerByte;
4343 return bitsPerPixel * width * height / bitsPerByte;
4356 if (image == NULL) {
4361 if (imageSize <= 0) {
4373 for (
int y = 0; y < image->
height; y++) {
4374 for (
int x = 0; x < image->
width; x++) {
4376 ((
unsigned char*)data) + (i++ * pixelSize),
4384 if (dataSize != NULL) {
4385 *dataSize = (
unsigned int)imageSize;
4408 if (image == NULL) {
4427 unsigned int dataSize;
4460 if (image == NULL) {
4464 unsigned char alphaThreshold = (
unsigned char)(threshold * 255.0f);
4470 for (
int y = 0; y < image->
height; y++) {
4471 for (
int x = 0; x < image->
width; x++) {
4472 if (image->
data[y * (image->
pitch >> 2) + x].rgba.
a > alphaThreshold) {
4490 if ((xMin != 9999999) && (xMax != 9999999)) {
4494 .width = xMax + 1 - xMin,
4495 .height = yMax + 1 - yMin
4514 if (image == NULL) {
4519 if (newImage == NULL) {
4550 if (image == NULL) {
4570 if (contrast < -1.0f) {
4573 else if (contrast > 1.0f) {
4577 contrast = (1.0f + contrast) * contrast;
4579 float pR = (float)color.rgba.
r / 255.0f - 0.5f;
4586 else if (pR > 255) {
4590 float pG = (float)color.rgba.
g / 255.0f - 0.5f;
4597 else if (pG > 255) {
4601 float pB = (float)color.rgba.
b / 255.0f - 0.5f;
4608 else if (pB > 255) {
4614 .r = (
unsigned char)pR,
4615 .g = (
unsigned char)pG,
4616 .b = (
unsigned char)pB,
4631 if (image == NULL) {
4635 if (contrast < -1.0f) {
4638 else if (contrast > 1.0f) {
4642 for (
int y = image->
clip.
y; y < image->clip.y + image->
clip.
height; y++) {
4644 for (
int x = 0; x < image->
clip.
width; x++) {
4662 if (image == NULL || alphaMask == NULL) {
4670 if (dstRect.
x < 0) {
4671 srcRect.
x -= dstRect.
x;
4672 srcRect.
width += dstRect.
x;
4674 if (dstRect.
y < 0) {
4675 srcRect.
y -= dstRect.
y;
4679 if (!_pntr_rectangle_intersect(dstRect.
x, dstRect.
y,
4687 for (
int y = 0; y < dstRect.
height; y++) {
4689 for (
int x = 0; x < dstRect.
width; x++) {
4690 if (pixel->rgba.
a > 0) {
4691 pixel->rgba.
a =
PNTR_PIXEL(alphaMask, x, y).rgba.a;
4711 if (image == NULL) {
4717 if (newImage == NULL) {
4741 PNTR_API inline void pntr_draw_image_flipped(
pntr_image* dst,
pntr_image* src,
int posX,
int posY,
bool flipHorizontal,
bool flipVertical,
bool flipDiagonal) {
4742 if (dst == NULL || src == NULL) {
4746 pntr_draw_image_flipped_rec(dst, src,
4757 if (!flipHorizontal && !flipVertical && !flipDiagonal) {
4762 if (dst == NULL || src == NULL) {
4766 if (!_pntr_rectangle_intersect(srcRec.
x, srcRec.
y, srcRec.
width, srcRec.
height, 0, 0, src->
width, src->
height, &srcRec)) {
4771 for (
int y = 0; y < srcRec.
height; y++) {
4772 for (
int x = 0; x < srcRec.
width; x++) {
4775 dstX = flipHorizontal ? srcRec.
height - y - 1 : y;
4776 dstY = flipVertical ? srcRec.
width - x - 1 : x;
4779 dstY = flipVertical ? srcRec.
height - y - 1 : y;
4780 dstX = flipHorizontal ? srcRec.
width - x - 1 : x;
4804 if (dst == NULL || src == NULL) {
4808 pntr_draw_image_scaled_rec(dst, src,
4817 if (dst == NULL || src == NULL || scaleX <= 0.0f || scaleY <= 0.0f) {
4821 if (!_pntr_rectangle_intersect(srcRect.
x, srcRect.
y, srcRect.
width, srcRect.
height, 0, 0, src->
width, src->
height, &srcRect)) {
4825 int newWidth = (int)((
float)srcRect.
width * scaleX);
4826 int newHeight = (int)((
float)srcRect.
height * scaleY);
4827 int offsetXRatio = (int)(offsetX / (
float)srcRect.
width * (float)newWidth);
4828 int offsetYRatio = (int)(offsetY / (
float)srcRect.
height * (float)newHeight);
4832 float xRatio = (float)srcRect.
width / (
float)newWidth;
4833 float yRatio = (float)srcRect.
height / (
float)newHeight;
4835 for (
int y = 0; y < newHeight; y++) {
4836 int yPosition = posY + y - offsetYRatio;
4837 if (yPosition < dst->clip.y || yPosition >= dst->
clip.
y + dst->
clip.
height) {
4840 float srcY = (float)y * yRatio;
4841 int srcYPixel = srcRect.
y + (int)srcY;
4842 int srcYPixelPlusOne = y == newHeight - 1 ? (int)srcYPixel : (
int)srcYPixel + 1;
4843 for (
int x = 0; x < newWidth; x++) {
4844 int xPosition = posX + x - offsetXRatio;
4845 if (xPosition < dst->clip.x || xPosition >= dst->
clip.
x + dst->
clip.
width) {
4848 float srcX = (float)x * xRatio;
4849 int srcXPixel = srcRect.
y + (int)srcX;
4850 int srcXPixelPlusOne = x == newWidth - 1 ? (int)srcXPixel : (
int)srcXPixel + 1;
4852 src->
data[srcYPixel * (src->
pitch >> 2) + srcXPixel],
4853 src->
data[srcYPixelPlusOne * (src->
pitch >> 2) + srcXPixel],
4854 src->
data[srcYPixel * (src->
pitch >> 2) + srcXPixelPlusOne],
4855 src->
data[srcYPixelPlusOne * (src->
pitch >> 2) + srcXPixelPlusOne],
4865 int xRatio = (srcRect.
width << 16) / newWidth + 1;
4866 int yRatio = (srcRect.
height << 16) / newHeight + 1;
4868 for (
int y = 0; y < newHeight; y++) {
4869 int yPosition = posY + y - offsetYRatio;
4870 if (yPosition < dst->clip.y || yPosition >= dst->
clip.
y + dst->
clip.
height) {
4873 int y2 = (y * yRatio) >> 16;
4874 for (
int x = 0; x < newWidth; x++) {
4875 int xPosition = posX + x - offsetXRatio;
4876 if (xPosition < dst->clip.x || xPosition >= dst->
clip.
x + dst->
clip.
width) {
4879 int x2 = (x * xRatio) >> 16;
4899 float _pntr_normalize_degrees(
float degrees) {
4901 return 360.0f -
PNTR_FMODF(-degrees, 360.0f);
4919 if (image == NULL) {
4923 degrees = _pntr_normalize_degrees(degrees);
4925 if (degrees == 0.0f) {
4929 if (degrees == 90.0f || degrees == 180.0f || degrees == 270.0f) {
4931 if (degrees == 180.0f) {
4937 if (output == NULL) {
4954 if (rotatedImage == NULL) {
4960 return rotatedImage;
4983 .r = (uint8_t)(color00.rgba.
r * (1 - coordinateX) * (1 - coordinateY) + color01.rgba.
r * (1 - coordinateX) * coordinateY + color10.rgba.
r * coordinateX * (1 - coordinateY) + color11.rgba.
r * coordinateX * coordinateY),
4984 .g = (uint8_t)(color00.rgba.
g * (1 - coordinateX) * (1 - coordinateY) + color01.rgba.
g * (1 - coordinateX) * coordinateY + color10.rgba.
g * coordinateX * (1 - coordinateY) + color11.rgba.
g * coordinateX * coordinateY),
4985 .b = (uint8_t)(color00.rgba.
b * (1 - coordinateX) * (1 - coordinateY) + color01.rgba.
b * (1 - coordinateX) * coordinateY + color10.rgba.
b * coordinateX * (1 - coordinateY) + color11.rgba.
b * coordinateX * coordinateY),
4986 .a = (uint8_t)(color00.rgba.
a * (1 - coordinateX) * (1 - coordinateY) + color01.rgba.
a * (1 - coordinateX) * coordinateY + color10.rgba.
a * coordinateX * (1 - coordinateY) + color11.rgba.
a * coordinateX * coordinateY)
5007 if (dst == NULL || src == NULL) {
5035 if (dst == NULL || src == NULL) {
5039 degrees = _pntr_normalize_degrees(degrees);
5042 if (degrees == 0.0f) {
5048 if (srcRect.
x < 0) {
5051 if (srcRect.
y < 0) {
5062 if (degrees == 90.0f || degrees == 180.0f || degrees == 270.0f) {
5065 if (degrees == 90.0f || degrees == 270.0f) {
5068 dstRect.
x -= (int)offsetY;
5069 dstRect.
y -= (int)offsetX;
5072 dstRect.
x -= (int)offsetX;
5073 dstRect.
y -= (int)offsetY;
5082 for (
int y = 0; y < srcRect.
height; y++) {
5083 for (
int x = 0; x < srcRect.
width; x++) {
5084 if (degrees == 90.0f) {
5087 dstRect.
y + srcRect.
width - x,
5090 }
else if (degrees == 180.0f) {
5092 dstRect.
x + srcRect.
width - x,
5093 dstRect.
y + srcRect.
height - y,
5099 dstRect.
x + srcRect.
height - y,
5117 int offsetXRatio = (int)(offsetX / (
float)srcRect.
width * (float)newWidth);
5118 int offsetYRatio = (int)(offsetY / (
float)srcRect.
height * (float)newHeight);
5121 if (posX - offsetXRatio + newWidth < dst->clip.x || posX - offsetXRatio >= dst->
clip.
x + dst->
clip.
width || posY - offsetYRatio + newHeight < dst->clip.y || posY - offsetYRatio >= dst->
clip.
y + dst->
clip.
height) {
5125 float centerX = (float)srcRect.
width / 2.0f;
5126 float centerY = (
float)srcRect.
height / 2.0f;
5127 int srcXint, srcYint;
5130 for (
int y = 0; y < newHeight; y++) {
5132 int destY = posY + y - offsetYRatio;
5137 for (
int x = 0; x < newWidth; x++) {
5139 int destX = posX + x - offsetXRatio;
5140 if (destX < dst->clip.x || destX >= dst->
clip.
x + dst->
clip.
width ) {
5144 srcX = (float)(x - newWidth / 2) * cosTheta - (float)(y - newHeight / 2) * sinTheta + centerX;
5145 srcY = (float)(x - newWidth / 2) * sinTheta + (float)(y - newHeight / 2) * cosTheta + centerY;
5148 if (srcX < 0 || srcX >= srcRect.
width || srcY < 0 || srcY >= srcRect.
height) {
5152 srcXint = (int)srcX + srcRect.
x;
5153 srcYint = (
int)srcY + srcRect.
y;
5164 if (srcX >= srcRect.
width - 1 || srcY >= srcRect.
height - 1) {
5199 if (image == NULL) {
5203 pntr_draw_rectangle_gradient(image, 0, 0, width, height, topLeft, topRight, bottomLeft, bottomRight);
5216 if (image == NULL) {
5241 if (image == NULL) {
5246 if (_pntr_rectangle_intersect(x, y, width, height, 0, 0, image->
width, image->
height, &clip)) {
5272 if (image == NULL) {
5303 if (pointer != NULL) {
#define PNTR_BLANK
Definition: pntr.h:897
#define PNTR_WHITE
Definition: pntr.h:872
#define PNTR_WHITE_VALUE
Definition: pntr.h:884
#define PNTR_SAVE_IMAGE_TO_MEMORY
Definition: pntr.h:153
#define PNTR_SAVE_FILE
Definition: pntr.h:185
#define PNTR_LOAD_FILE
Definition: pntr.h:177
#define PNTR_LOAD_IMAGE_FROM_MEMORY
Definition: pntr.h:164
#define PNTR_FABSF(a)
Definition: pntr.h:1210
#define PNTR_MAX(a, b)
Definition: pntr.h:1292
#define PNTR_CEILF
Definition: pntr.h:1199
#define PNTR_SINF
Definition: pntr.h:1154
#define PNTR_FLOORF(x)
Definition: pntr.h:1221
#define PNTR_FMODF
Definition: pntr.h:1240
#define PNTR_COSF
Definition: pntr.h:1178
#define PNTR_MIN(a, b)
Definition: pntr.h:1304
#define PNTR_PI
Definition: pntr.h:1119
#define PNTR_DEG2RAD
Definition: pntr.h:1130
#define PNTR_MALLOC(size)
Definition: pntr.h:942
#define PNTR_MEMSET(str, c, n)
Definition: pntr.h:992
#define PNTR_FREE(ptr)
Definition: pntr.h:955
#define PNTR_MEMCPY(dest, src, n)
Definition: pntr.h:984
PNTR_API pntr_color pntr_color_invert(pntr_color color)
Definition: pntr.h:4091
PNTR_API pntr_image * pntr_gen_image_color(int width, int height, pntr_color color)
Definition: pntr.h:1549
PNTR_API pntr_font * pntr_load_font_ttf_from_memory(const unsigned char *fileData, unsigned int dataSize, int fontSize)
Definition: pntr.h:3974
PNTR_API void pntr_draw_triangle_vec(pntr_image *dst, pntr_vector point1, pntr_vector point2, pntr_vector point3, pntr_color color)
Definition: pntr.h:2422
PNTR_API void pntr_image_set_clip(pntr_image *image, int x, int y, int width, int height)
Definition: pntr.h:5240
PNTR_API void pntr_image_set_clip_rec(pntr_image *image, pntr_rectangle clip)
Definition: pntr.h:5260
PNTR_API pntr_color pntr_get_color(unsigned int hexValue)
Definition: pntr.h:1832
PNTR_API void pntr_draw_circle(pntr_image *dst, int centerX, int centerY, int radius, pntr_color color)
Definition: pntr.h:2241
PNTR_API void pntr_draw_image_rotated_rec(pntr_image *dst, pntr_image *src, pntr_rectangle srcRect, int posX, int posY, float degrees, float offsetX, float offsetY, pntr_filter filter)
Definition: pntr.h:5034
PNTR_API void pntr_image_color_invert(pntr_image *image)
Definition: pntr.h:4109
struct pntr_image pntr_image
PNTR_API void pntr_draw_triangle_fill_vec(pntr_image *dst, pntr_vector point1, pntr_vector point2, pntr_vector point3, pntr_color color)
Definition: pntr.h:2528
PNTR_API void pntr_unload_image(pntr_image *image)
Definition: pntr.h:1744
PNTR_API void pntr_image_color_tint(pntr_image *image, pntr_color color)
Definition: pntr.h:3290
PNTR_API void pntr_draw_line_horizontal(pntr_image *dst, int posX, int posY, int width, pntr_color color)
Definition: pntr.h:2038
PNTR_API void pntr_blend_color(pntr_color *dst, pntr_color src)
Definition: pntr.h:1592
PNTR_API pntr_image * pntr_image_from_image(pntr_image *image, int x, int y, int width, int height)
Definition: pntr.h:1672
PNTR_API void pntr_image_alpha_crop(pntr_image *image, float threshold)
Definition: pntr.h:4549
PNTR_API void pntr_draw_image_scaled(pntr_image *dst, pntr_image *src, int posX, int posY, float scaleX, float scaleY, float offsetX, float offsetY, pntr_filter filter)
Definition: pntr.h:4803
PNTR_API pntr_rectangle pntr_image_get_clip(pntr_image *image)
Definition: pntr.h:5215
pntr_error
Definition: pntr.h:539
PNTR_API void pntr_image_color_contrast(pntr_image *image, float contrast)
Definition: pntr.h:4630
PNTR_API void pntr_draw_text(pntr_image *dst, pntr_font *font, const char *text, int posX, int posY, pntr_color color)
Definition: pntr.h:3626
union pntr_color pntr_color
PNTR_API pntr_image * pntr_load_image(const char *fileName)
Definition: pntr.h:2746
PNTR_API pntr_rectangle pntr_image_alpha_border(pntr_image *image, float threshold)
Definition: pntr.h:4459
PNTR_API void pntr_draw_point(pntr_image *dst, int x, int y, pntr_color color)
Definition: pntr.h:1885
PNTR_API void pntr_draw_triangle_fill(pntr_image *dst, int x1, int y1, int x2, int y2, int x3, int y3, pntr_color color)
Definition: pntr.h:2456
PNTR_API pntr_image * pntr_new_image(int width, int height)
Definition: pntr.h:1516
PNTR_API pntr_color pntr_color_alpha_blend(pntr_color dst, pntr_color src)
Definition: pntr.h:2799
pntr_pixelformat
Definition: pntr.h:497
PNTR_API unsigned char * pntr_save_image_to_memory(pntr_image *image, pntr_image_type type, unsigned int *dataSize)
Definition: pntr.h:4407
PNTR_API int pntr_measure_text(pntr_font *font, const char *text)
Definition: pntr.h:3761
PNTR_API void pntr_draw_image_rec(pntr_image *dst, pntr_image *src, pntr_rectangle srcRect, int posX, int posY)
Definition: pntr.h:2815
PNTR_API unsigned char * pntr_load_file(const char *fileName, unsigned int *bytesRead)
Definition: pntr.h:4175
PNTR_API pntr_image * pntr_gen_image_gradient(int width, int height, pntr_color topLeft, pntr_color topRight, pntr_color bottomLeft, pntr_color bottomRight)
Definition: pntr.h:5197
PNTR_API int pntr_get_pixel_data_size(int width, int height, pntr_pixelformat pixelFormat)
Definition: pntr.h:4322
PNTR_API pntr_color pntr_color_bilinear_interpolate(pntr_color color00, pntr_color color01, pntr_color color10, pntr_color color11, float coordinateX, float coordinateY)
Definition: pntr.h:4980
PNTR_API bool pntr_image_crop(pntr_image *image, int x, int y, int width, int height)
Definition: pntr.h:4513
PNTR_API void pntr_put_horizontal_line_unsafe(pntr_image *dst, int posX, int posY, int width, pntr_color color)
Definition: pntr.h:1760
PNTR_API void pntr_draw_point_unsafe(pntr_image *dst, int x, int y, pntr_color color)
Definition: pntr.h:1878
PNTR_API void pntr_image_color_fade(pntr_image *image, float alpha)
Definition: pntr.h:3186
PNTR_API pntr_image * pntr_gen_image_text(pntr_font *font, const char *text, pntr_color tint)
Definition: pntr.h:3836
PNTR_API pntr_color pntr_image_get_color(pntr_image *image, int x, int y)
Definition: pntr.h:2645
PNTR_API pntr_image * pntr_load_image_from_memory(pntr_image_type type, const unsigned char *fileData, unsigned int dataSize)
Definition: pntr.h:2731
PNTR_API const char * pntr_load_file_text(const char *fileName)
Definition: pntr.h:4231
PNTR_API void pntr_draw_image(pntr_image *dst, pntr_image *src, int posX, int posY)
Definition: pntr.h:2780
PNTR_API void pntr_draw_line(pntr_image *dst, int startPosX, int startPosY, int endPosX, int endPosY, pntr_color color)
Definition: pntr.h:1919
PNTR_API bool pntr_save_image(pntr_image *image, const char *fileName)
Definition: pntr.h:4426
PNTR_API bool pntr_save_file(const char *fileName, const void *data, unsigned int bytesToWrite)
Definition: pntr.h:4284
PNTR_API void pntr_draw_triangle(pntr_image *dst, int x1, int y1, int x2, int y2, int x3, int y3, pntr_color color)
Definition: pntr.h:2438
PNTR_API void pntr_unload_memory(void *pointer)
Definition: pntr.h:5302
PNTR_API void pntr_draw_rectangle_rec(pntr_image *dst, pntr_rectangle rec, pntr_color color)
Definition: pntr.h:2105
PNTR_API void pntr_draw_ellipse_fill(pntr_image *dst, int centerX, int centerY, int radiusX, int radiusY, pntr_color color)
Definition: pntr.h:2377
PNTR_API void pntr_draw_rectangle_fill(pntr_image *dst, int posX, int posY, int width, int height, pntr_color color)
Definition: pntr.h:2155
PNTR_API pntr_font * pntr_load_font_ttf(const char *fileName, int fontSize)
Definition: pntr.h:3938
PNTR_API void pntr_draw_rectangle_fill_rec(pntr_image *dst, pntr_rectangle rect, pntr_color color)
Definition: pntr.h:2168
struct pntr_font pntr_font
PNTR_API void pntr_draw_text_wrapped(pntr_image *dst, pntr_font *font, const char *text, int posX, int posY, int maxWidth, pntr_color tint)
Definition: pntr.h:3681
PNTR_API void * pntr_set_error(pntr_error error)
Definition: pntr.h:1494
PNTR_API pntr_image * pntr_image_resize(pntr_image *image, int newWidth, int newHeight, pntr_filter filter)
Definition: pntr.h:2980
PNTR_API void pntr_set_pixel_color(void *dstPtr, pntr_pixelformat dstPixelFormat, pntr_color color)
Definition: pntr.h:3216
PNTR_API void pntr_unload_file(unsigned char *fileData)
Definition: pntr.h:4447
#define PNTR_PIXEL(image, x, y)
Definition: pntr.h:1455
struct pntr_vector pntr_vector
PNTR_API pntr_font * pntr_load_font_tty(const char *fileName, int glyphWidth, int glyphHeight, const char *characters)
Definition: pntr.h:3450
PNTR_API pntr_color pntr_color_brightness(pntr_color color, float factor)
Definition: pntr.h:3127
PNTR_API void * pntr_memory_copy(void *destination, void *source, size_t size)
Definition: pntr.h:5319
PNTR_API void pntr_image_color_brightness(pntr_image *image, float factor)
Definition: pntr.h:4131
PNTR_API pntr_font * pntr_load_font_bmf(const char *fileName, const char *characters)
Definition: pntr.h:3314
PNTR_API void pntr_unload_file_text(const char *text)
Definition: pntr.h:4259
PNTR_API pntr_font * pntr_font_copy(pntr_font *font)
Definition: pntr.h:3549
#define PNTR_API
Definition: pntr.h:275
PNTR_API pntr_image_type pntr_get_file_image_type(const char *filePath)
Definition: pntr.h:2665
PNTR_API pntr_color pntr_color_tint(pntr_color color, pntr_color tint)
Definition: pntr.h:3104
PNTR_API void pntr_image_alpha_mask(pntr_image *image, pntr_image *alphaMask, int posX, int posY)
Definition: pntr.h:4661
PNTR_API void * pntr_image_to_pixelformat(pntr_image *image, unsigned int *dataSize, pntr_pixelformat pixelFormat)
Definition: pntr.h:4355
PNTR_API pntr_font * pntr_load_font_default(void)
Definition: pntr.h:3869
#define PNTR_PIXELFORMAT
Definition: pntr.h:298
PNTR_API void pntr_image_color_replace(pntr_image *image, pntr_color color, pntr_color replace)
Definition: pntr.h:3078
struct pntr_rectangle pntr_rectangle
PNTR_API void pntr_image_reset_clip(pntr_image *image)
Definition: pntr.h:5271
PNTR_API pntr_color pntr_get_pixel_color(void *srcPtr, pntr_pixelformat srcPixelFormat)
Definition: pntr.h:3247
PNTR_API pntr_image * pntr_image_scale(pntr_image *image, float scaleX, float scaleY, pntr_filter filter)
Definition: pntr.h:2960
pntr_image_type
Definition: pntr.h:579
PNTR_API void pntr_draw_image_tint_rec(pntr_image *dst, pntr_image *src, pntr_rectangle srcRect, int posX, int posY, pntr_color tint)
Definition: pntr.h:2831
PNTR_API void pntr_draw_circle_fill(pntr_image *dst, int centerX, int centerY, int radius, pntr_color color)
Definition: pntr.h:2289
PNTR_API void pntr_draw_ellipse(pntr_image *dst, int centerX, int centerY, int radiusX, int radiusY, pntr_color color)
Definition: pntr.h:2327
PNTR_API void pntr_draw_rectangle(pntr_image *dst, int posX, int posY, int width, int height, pntr_color color)
Definition: pntr.h:2122
PNTR_API pntr_color pntr_color_contrast(pntr_color color, float contrast)
Definition: pntr.h:4569
PNTR_API pntr_image * pntr_image_from_pixelformat(const void *data, int width, int height, pntr_pixelformat pixelFormat)
Definition: pntr.h:2909
PNTR_API pntr_image * pntr_image_subimage(pntr_image *image, int x, int y, int width, int height)
Definition: pntr.h:1712
PNTR_API pntr_font * pntr_font_scale(pntr_font *font, float scaleX, float scaleY, pntr_filter filter)
Definition: pntr.h:3583
PNTR_API void pntr_clear_background(pntr_image *image, pntr_color color)
Definition: pntr.h:1775
PNTR_API void * pntr_load_memory(size_t size)
Definition: pntr.h:5291
PNTR_API void pntr_image_flip(pntr_image *image, bool horizontal, bool vertical)
Definition: pntr.h:3044
PNTR_API pntr_image * pntr_image_copy(pntr_image *image)
Definition: pntr.h:1563
PNTR_API pntr_image * pntr_image_rotate(pntr_image *image, float degrees, pntr_filter filter)
Definition: pntr.h:4918
PNTR_API void pntr_draw_image_tint(pntr_image *dst, pntr_image *src, int posX, int posY, pntr_color tint)
Definition: pntr.h:2767
pntr_filter
Definition: pntr.h:517
PNTR_API pntr_color pntr_color_fade(pntr_color color, float alpha)
Definition: pntr.h:3160
PNTR_API pntr_color pntr_new_color(unsigned char r, unsigned char g, unsigned char b, unsigned char a)
Definition: pntr.h:1814
PNTR_API bool pntr_image_resize_canvas(pntr_image *image, int newWidth, int newHeight, int offsetX, int offsetY, pntr_color fill)
Definition: pntr.h:4710
PNTR_API void pntr_draw_line_vertical(pntr_image *dst, int posX, int posY, int height, pntr_color color)
Definition: pntr.h:2073
PNTR_API pntr_vector pntr_measure_text_ex(pntr_font *font, const char *text, int textLength)
Definition: pntr.h:3774
PNTR_API void pntr_draw_image_rotated(pntr_image *dst, pntr_image *src, int posX, int posY, float degrees, float offsetX, float offsetY, pntr_filter filter)
Definition: pntr.h:5006
PNTR_API void pntr_unload_font(pntr_font *font)
Definition: pntr.h:3530
@ PNTR_ERROR_NOT_SUPPORTED
Definition: pntr.h:558
@ PNTR_ERROR_INVALID_ARGS
Definition: pntr.h:548
@ PNTR_ERROR_FAILED_TO_WRITE
Definition: pntr.h:568
@ PNTR_ERROR_UNKNOWN
Definition: pntr.h:573
@ PNTR_ERROR_NONE
Definition: pntr.h:543
@ PNTR_ERROR_NO_MEMORY
Definition: pntr.h:553
@ PNTR_ERROR_FAILED_TO_OPEN
Definition: pntr.h:563
@ PNTR_PIXELFORMAT_ARGB8888
Definition: pntr.h:506
@ PNTR_PIXELFORMAT_RGBA8888
Definition: pntr.h:501
@ PNTR_PIXELFORMAT_GRAYSCALE
Definition: pntr.h:511
@ PNTR_IMAGE_TYPE_JPG
Definition: pntr.h:591
@ PNTR_IMAGE_TYPE_BMP
Definition: pntr.h:595
@ PNTR_IMAGE_TYPE_PNG
Definition: pntr.h:587
@ PNTR_IMAGE_TYPE_UNKNOWN
Definition: pntr.h:583
@ PNTR_FILTER_NEARESTNEIGHBOR
Definition: pntr.h:523
@ PNTR_FILTER_BILINEAR
Definition: pntr.h:530
#define PNTR_STRCODEPOINT
Definition: pntr.h:1101
#define PNTR_STRLEN
Definition: pntr.h:1061
#define PNTR_STRCHR
Definition: pntr.h:1049
#define PNTR_STRSTR
Definition: pntr.h:1037
#define PNTR_STRSIZE(text)
Definition: pntr.h:1073
char pntr_codepoint_t
Definition: pntr.h:1020
unsigned char g
Definition: pntr.h:338
unsigned char b
Definition: pntr.h:343
unsigned char r
Definition: pntr.h:333
unsigned char a
Definition: pntr.h:348
pntr_rectangle * srcRects
Definition: pntr.h:476
char * characters
Definition: pntr.h:486
pntr_rectangle * glyphRects
Definition: pntr.h:481
int charactersLen
Definition: pntr.h:491
pntr_image * atlas
Definition: pntr.h:471
bool subimage
Definition: pntr.h:430
int width
Definition: pntr.h:413
int height
Definition: pntr.h:418
int pitch
Definition: pntr.h:423
pntr_rectangle clip
Definition: pntr.h:439
pntr_color * data
Definition: pntr.h:408
int x
Definition: pntr.h:380
int height
Definition: pntr.h:395
int y
Definition: pntr.h:385
int width
Definition: pntr.h:390
int x
Definition: pntr.h:449
int y
Definition: pntr.h:454
uint32_t value
Definition: pntr.h:318