![]() |
tinyimg 1.0.0
Lightweight image manipulation library for Cloudflare Workers
|
Color and pixel manipulation utilities. More...
Go to the source code of this file.
Classes | |
| struct | TinyIccProfile |
| A parsed matrix and TRC profile. More... | |
Functions | |
| int | tiny_rgb_to_grayscale (uint8_t r, uint8_t g, uint8_t b) |
| Converts RGB color values to a grayscale value using the luminosity method. | |
| int | tiny_grayscale_to_rgb (uint8_t grayscale, uint8_t *r, uint8_t *g, uint8_t *b) |
| Converts a grayscale value to RGB color values. | |
| int | tiny_rgb_to_hsv (uint8_t r, uint8_t g, uint8_t b, float *h, float *s, float *v) |
| Converts RGB color values to HSV (Hue, Saturation, Value) color space. | |
| int | tiny_hsv_to_rgb (float h, float s, float v, uint8_t *r, uint8_t *g, uint8_t *b) |
| Converts HSV (Hue, Saturation, Value) color space values to RGB color values. | |
| int | tiny_rgb_to_hsl (uint8_t r, uint8_t g, uint8_t b, float *h, float *s, float *l) |
| Converts RGB color values to HSL (Hue, Saturation, Lightness) color space. | |
| int | tiny_hsl_to_rgb (float h, float s, float l, uint8_t *r, uint8_t *g, uint8_t *b) |
| Converts HSL (Hue, Saturation, Lightness) color space values to RGB color values. | |
| int | tiny_rgb_to_cmyk (uint8_t r, uint8_t g, uint8_t b, float *c, float *m, float *y, float *k) |
| Converts RGB color values to CMYK (Cyan, Magenta, Yellow, Key/Black) color space. | |
| int | tiny_cmyk_to_rgb (float c, float m, float y, float k, uint8_t *r, uint8_t *g, uint8_t *b) |
| Converts CMYK (Cyan, Magenta, Yellow, Key/Black) color space values to RGB color values. | |
| int | tiny_interpolate_rgb (uint8_t r1, uint8_t g1, uint8_t b1, uint8_t r2, uint8_t g2, uint8_t b2, float t, uint8_t *r_out, uint8_t *g_out, uint8_t *b_out) |
| Interpolates between two RGB colors based on a given interpolation factor t. | |
| int | tiny_interpolate_hsv (float h1, float s1, float v1, float h2, float s2, float v2, float t, float *h_out, float *s_out, float *v_out) |
| Interpolates between two HSV colors based on a given interpolation factor t. | |
| int | tiny_interpolate_hsl (float h1, float s1, float l1, float h2, float s2, float l2, float t, float *h_out, float *s_out, float *l_out) |
| Interpolates between two HSL colors based on a given interpolation factor t. | |
| int * | tiny_gradient_rgb (uint8_t r1, uint8_t g1, uint8_t b1, uint8_t r2, uint8_t g2, uint8_t b2, size_t steps) |
| Generates a gradient of RGB colors between two specified colors over a given number of steps. | |
| int * | tiny_gradient_rgba (uint8_t r1, uint8_t g1, uint8_t b1, uint8_t a1, uint8_t r2, uint8_t g2, uint8_t b2, uint8_t a2, size_t steps) |
| Generates a gradient of RGBA colors between two specified colors over a given number of steps. | |
| float * | tiny_gradient_hsv (float h1, float s1, float v1, float h2, float s2, float v2, size_t steps) |
| Generates a gradient of HSV colors between two specified colors over a given number of steps. | |
| float * | tiny_gradient_hsl (float h1, float s1, float l1, float h2, float s2, float l2, size_t steps) |
| Generates a gradient of HSL colors between two specified colors over a given number of steps. | |
| float * | tiny_gradient_cmyk (float c1, float m1, float y1, float k1, float c2, float m2, float y2, float k2, size_t steps) |
| Generates a gradient of CMYK colors between two specified colors over a given number of steps. | |
| int * | tiny_multigradient_rgb (uint8_t *colors, size_t num_colors, size_t steps) |
| Generates a multi-gradient of RGB colors based on an array of input colors and a specified number of steps equally distributed across the input colors. | |
| int * | tiny_multigradient_rgb_sized (uint8_t *colors, size_t num_colors, size_t steps, float *color_distribution) |
| Generates a multi-gradient of RGB colors based on an array of input colors and a specified number of steps distributed based on color_distribution. | |
| int * | tiny_multigradient_rgba (uint8_t *colors, size_t num_colors, size_t steps) |
| Generates a multi-gradient of RGBA colors based on an array of input colors and a specified number of steps equally distributed across the input colors. | |
| int * | tiny_multigradient_rgba_sized (uint8_t *colors, size_t num_colors, size_t steps, float *color_distribution) |
| Generates a multi-gradient of RGBA colors based on an array of input colors and a specified number of steps distributed based on color_distribution. | |
| float * | tiny_multigradient_hsv (float *colors, size_t num_colors, size_t steps) |
| Generates a multi-gradient of HSV colors based on an array of input colors and a specified number of steps equally distributed across the input colors. | |
| float * | tiny_multigradient_hsv_sized (float *colors, size_t num_colors, size_t steps, float *color_distribution) |
| Generates a multi-gradient of HSV colors based on an array of input colors and a specified number of steps distributed based on color_distribution. | |
| float * | tiny_multigradient_hsl (float *colors, size_t num_colors, size_t steps) |
| Generates a multi-gradient of HSL colors based on an array of input colors and a specified number of steps equally distributed across the input colors. | |
| float * | tiny_multigradient_hsl_sized (float *colors, size_t num_colors, size_t steps, float *color_distribution) |
| Generates a multi-gradient of HSL colors based on an array of input colors and a specified number of steps distributed based on color_distribution. | |
| float * | tiny_multigradient_cmyk (float *colors, size_t num_colors, size_t steps) |
| Generates a multi-gradient of CMYK colors based on an array of input colors and a specified number of steps equally distributed across the input colors. | |
| float * | tiny_multigradient_cmyk_sized (float *colors, size_t num_colors, size_t steps, float *color_distribution) |
| Generates a multi-gradient of CMYK colors based on an array of input colors and a specified number of steps distributed based on color_distribution. | |
| int | tiny_icc_parse (TinyIccProfile *profile, const uint8_t *data, size_t size) |
| Reads a matrix and TRC profile. | |
| int | tiny_icc_srgb (TinyIccProfile *profile) |
| The sRGB profile, without needing a file for it. | |
| int | tiny_icc_to_srgb (const TinyIccProfile *profile, const uint8_t *in, uint8_t *out) |
| Converts one color from a profile's space to sRGB. | |
| int | tiny_icc_convert_image (TinyImage *image, const TinyIccProfile *profile) |
| Converts a whole image from a profile's space to sRGB. | |
| int | tiny_icc_matrix_between (float *out, const TinyIccProfile *from, const TinyIccProfile *to) |
| The matrix taking one profile's RGB to another's. | |
Color and pixel manipulation utilities.
| int tiny_cmyk_to_rgb | ( | float | c, |
| float | m, | ||
| float | y, | ||
| float | k, | ||
| uint8_t * | r, | ||
| uint8_t * | g, | ||
| uint8_t * | b ) |
Converts CMYK (Cyan, Magenta, Yellow, Key/Black) color space values to RGB color values.
The CMYK values are expected to be in the ranges:
| c | Cyan value (0-1) |
| m | Magenta value (0-1) |
| y | Yellow value (0-1) |
| k | Key/Black value (0-1) |
| r | Pointer to store the Red component (0-255) |
| g | Pointer to store the Green component (0-255) |
| b | Pointer to store the Blue component (0-255) |
| float * tiny_gradient_cmyk | ( | float | c1, |
| float | m1, | ||
| float | y1, | ||
| float | k1, | ||
| float | c2, | ||
| float | m2, | ||
| float | y2, | ||
| float | k2, | ||
| size_t | steps ) |
Generates a gradient of CMYK colors between two specified colors over a given number of steps.
The function returns a dynamically allocated array of integers, where each entry is four floats: cyan, magenta, yellow and key. The memory comes from the arena, so tiny_arena_reset() or a matching tiny_arena_release() reclaims it and nothing frees it individually.
| c1 | Cyan of the starting color (0-1) |
| m1 | Magenta of the starting color (0-1) |
| y1 | Yellow of the starting color (0-1) |
| k1 | Key/Black of the starting color (0-1) |
| c2 | Cyan of the ending color (0-1) |
| m2 | Magenta of the ending color (0-1) |
| y2 | Yellow of the ending color (0-1) |
| k2 | Key/Black of the ending color (0-1) |
| steps | Number of steps in the gradient (must be greater than 1) |
| float * tiny_gradient_hsl | ( | float | h1, |
| float | s1, | ||
| float | l1, | ||
| float | h2, | ||
| float | s2, | ||
| float | l2, | ||
| size_t | steps ) |
Generates a gradient of HSL colors between two specified colors over a given number of steps.
The function returns a dynamically allocated array of integers, where each entry is three floats: hue, saturation and lightness. The memory comes from the arena, so tiny_arena_reset() or a matching tiny_arena_release() reclaims it and nothing frees it individually.
| h1 | Hue of the starting color (0-360) |
| s1 | Saturation of the starting color (0-1) |
| l1 | Lightness of the starting color (0-1) |
| h2 | Hue of the ending color (0-360) |
| s2 | Saturation of the ending color (0-1) |
| l2 | Lightness of the ending color (0-1) |
| steps | Number of steps in the gradient (must be greater than 1) |
| float * tiny_gradient_hsv | ( | float | h1, |
| float | s1, | ||
| float | v1, | ||
| float | h2, | ||
| float | s2, | ||
| float | v2, | ||
| size_t | steps ) |
Generates a gradient of HSV colors between two specified colors over a given number of steps.
The function returns a dynamically allocated array of integers, where each entry is three floats: hue, saturation and value. The memory comes from the arena, so tiny_arena_reset() or a matching tiny_arena_release() reclaims it and nothing frees it individually.
| h1 | Hue of the starting color (0-360) |
| s1 | Saturation of the starting color (0-1) |
| v1 | Value (Brightness) of the starting color (0-1) |
| h2 | Hue of the ending color (0-360) |
| s2 | Saturation of the ending color (0-1) |
| v2 | Value (Brightness) of the ending color (0-1) |
| steps | Number of steps in the gradient (must be greater than 1) |
| int * tiny_gradient_rgb | ( | uint8_t | r1, |
| uint8_t | g1, | ||
| uint8_t | b1, | ||
| uint8_t | r2, | ||
| uint8_t | g2, | ||
| uint8_t | b2, | ||
| size_t | steps ) |
Generates a gradient of RGB colors between two specified colors over a given number of steps.
The function returns a dynamically allocated array of integers, where each integer holds one RGB color as 0xRRGGBB. The memory comes from the arena, so tiny_arena_reset() or a matching tiny_arena_release() reclaims it and nothing frees it individually.
| r1 | Red component of the starting color (0-255) |
| g1 | Green component of the starting color (0-255) |
| b1 | Blue component of the starting color (0-255) |
| r2 | Red component of the ending color (0-255) |
| g2 | Green component of the ending color (0-255) |
| b2 | Blue component of the ending color (0-255) |
| steps | Number of steps in the gradient (must be greater than 1) |
| int * tiny_gradient_rgba | ( | uint8_t | r1, |
| uint8_t | g1, | ||
| uint8_t | b1, | ||
| uint8_t | a1, | ||
| uint8_t | r2, | ||
| uint8_t | g2, | ||
| uint8_t | b2, | ||
| uint8_t | a2, | ||
| size_t | steps ) |
Generates a gradient of RGBA colors between two specified colors over a given number of steps.
The function returns a dynamically allocated array of integers, where each integer holds one RGBA color as 0xRRGGBBAA. The memory comes from the arena, so tiny_arena_reset() or a matching tiny_arena_release() reclaims it and nothing frees it individually.
| r1 | Red component of the starting color (0-255) |
| g1 | Green component of the starting color (0-255) |
| b1 | Blue component of the starting color (0-255) |
| a1 | Alpha component of the starting color (0-255) |
| r2 | Red component of the ending color (0-255) |
| g2 | Green component of the ending color (0-255) |
| b2 | Blue component of the ending color (0-255) |
| a2 | Alpha component of the ending color (0-255) |
| steps | Number of steps in the gradient (must be greater than 1) |
| int tiny_grayscale_to_rgb | ( | uint8_t | grayscale, |
| uint8_t * | r, | ||
| uint8_t * | g, | ||
| uint8_t * | b ) |
Converts a grayscale value to RGB color values.
The grayscale value is replicated across the R, G, and B channels.
| grayscale | Grayscale value (0-255) |
| r | Pointer to store the Red component (0-255) |
| g | Pointer to store the Green component (0-255) |
| b | Pointer to store the Blue component (0-255) |
| int tiny_hsl_to_rgb | ( | float | h, |
| float | s, | ||
| float | l, | ||
| uint8_t * | r, | ||
| uint8_t * | g, | ||
| uint8_t * | b ) |
Converts HSL (Hue, Saturation, Lightness) color space values to RGB color values.
The HSL values are expected to be in the ranges:
| h | Hue value (0-360) |
| s | Saturation value (0-1) |
| l | Lightness value (0-1) |
| r | Pointer to store the Red component (0-255) |
| g | Pointer to store the Green component (0-255) |
| b | Pointer to store the Blue component (0-255) |
| int tiny_hsv_to_rgb | ( | float | h, |
| float | s, | ||
| float | v, | ||
| uint8_t * | r, | ||
| uint8_t * | g, | ||
| uint8_t * | b ) |
Converts HSV (Hue, Saturation, Value) color space values to RGB color values.
The HSV values are expected to be in the ranges:
| h | Hue value (0-360) |
| s | Saturation value (0-1) |
| v | Value (Brightness) value (0-1) |
| r | Pointer to store the Red component (0-255) |
| g | Pointer to store the Green component (0-255) |
| b | Pointer to store the Blue component (0-255) |
| int tiny_icc_convert_image | ( | TinyImage * | image, |
| const TinyIccProfile * | profile ) |
Converts a whole image from a profile's space to sRGB.
| image | The image to convert. |
| profile | The profile its pixels are in. |
| int tiny_icc_matrix_between | ( | float * | out, |
| const TinyIccProfile * | from, | ||
| const TinyIccProfile * | to ) |
The matrix taking one profile's RGB to another's.
| out | Receives nine weights, row major. |
| from | The source profile. |
| to | The destination profile. |
| int tiny_icc_parse | ( | TinyIccProfile * | profile, |
| const uint8_t * | data, | ||
| size_t | size ) |
Reads a matrix and TRC profile.
| profile | Receives the parsed profile. |
| data | The profile bytes. |
| size | How many bytes. |
| int tiny_icc_srgb | ( | TinyIccProfile * | profile | ) |
The sRGB profile, without needing a file for it.
| profile | Receives it. |
| int tiny_icc_to_srgb | ( | const TinyIccProfile * | profile, |
| const uint8_t * | in, | ||
| uint8_t * | out ) |
Converts one color from a profile's space to sRGB.
| profile | The source profile. |
| in | Three channels in the profile's space. |
| out | Receives three channels of sRGB. |
| int tiny_interpolate_hsl | ( | float | h1, |
| float | s1, | ||
| float | l1, | ||
| float | h2, | ||
| float | s2, | ||
| float | l2, | ||
| float | t, | ||
| float * | h_out, | ||
| float * | s_out, | ||
| float * | l_out ) |
Interpolates between two HSL colors based on a given interpolation factor t.
The interpolation factor t should be in the range [0, 1], where:
| h1 | Hue of the first color (0-360) |
| s1 | Saturation of the first color (0-1) |
| l1 | Lightness of the first color (0-1) |
| h2 | Hue of the second color (0-360) |
| s2 | Saturation of the second color (0-1) |
| l2 | Lightness of the second color (0-1) |
| t | Interpolation factor (0-1) |
| h_out | Pointer to store the interpolated Hue value (0-360) |
| s_out | Pointer to store the interpolated Saturation value (0-1) |
| l_out | Pointer to store the interpolated Lightness value (0-1) |
| int tiny_interpolate_hsv | ( | float | h1, |
| float | s1, | ||
| float | v1, | ||
| float | h2, | ||
| float | s2, | ||
| float | v2, | ||
| float | t, | ||
| float * | h_out, | ||
| float * | s_out, | ||
| float * | v_out ) |
Interpolates between two HSV colors based on a given interpolation factor t.
The interpolation factor t should be in the range [0, 1], where:
| h1 | Hue of the first color (0-360) |
| s1 | Saturation of the first color (0-1) |
| v1 | Value of the first color (0-1) |
| h2 | Hue of the second color (0-360) |
| s2 | Saturation of the second color (0-1) |
| v2 | Value of the second color (0-1) |
| t | Interpolation factor (0-1) |
| h_out | Pointer to store the interpolated Hue value (0-360) |
| s_out | Pointer to store the interpolated Saturation value (0-1) |
| v_out | Pointer to store the interpolated Value (0-1) |
| int tiny_interpolate_rgb | ( | uint8_t | r1, |
| uint8_t | g1, | ||
| uint8_t | b1, | ||
| uint8_t | r2, | ||
| uint8_t | g2, | ||
| uint8_t | b2, | ||
| float | t, | ||
| uint8_t * | r_out, | ||
| uint8_t * | g_out, | ||
| uint8_t * | b_out ) |
Interpolates between two RGB colors based on a given interpolation factor t.
The interpolation factor t should be in the range [0, 1], where:
| r1 | Red component of the first color (0-255) |
| g1 | Green component of the first color (0-255) |
| b1 | Blue component of the first color (0-255) |
| r2 | Red component of the second color (0-255) |
| g2 | Green component of the second color (0-255) |
| b2 | Blue component of the second color (0-255) |
| t | Interpolation factor (0-1) |
| r_out | Pointer to store the interpolated Red component (0-255) |
| g_out | Pointer to store the interpolated Green component (0-255) |
| b_out | Pointer to store the interpolated Blue component (0-255) |
| float * tiny_multigradient_cmyk | ( | float * | colors, |
| size_t | num_colors, | ||
| size_t | steps ) |
Generates a multi-gradient of CMYK colors based on an array of input colors and a specified number of steps equally distributed across the input colors.
The function returns a dynamically allocated array of integers, where each entry is four floats: cyan, magenta, yellow and key. The memory comes from the arena, so tiny_arena_reset() or a matching tiny_arena_release() reclaims it and nothing frees it individually.
| colors | Pointer to an array of float values representing the input colors. Each color should be represented by four consecutive values (C, M, Y, K). |
| num_colors | The number of colors in the input array. |
| steps | The total number of steps in the multi-gradient (must be greater than 1). |
| float * tiny_multigradient_cmyk_sized | ( | float * | colors, |
| size_t | num_colors, | ||
| size_t | steps, | ||
| float * | color_distribution ) |
Generates a multi-gradient of CMYK colors based on an array of input colors and a specified number of steps distributed based on color_distribution.
The function returns a dynamically allocated array of integers, where each entry is four floats: cyan, magenta, yellow and key. The memory comes from the arena, so tiny_arena_reset() or a matching tiny_arena_release() reclaims it and nothing frees it individually.
| colors | Pointer to an array of float values representing the input colors. Each color should be represented by four consecutive values (C, M, Y, K). |
| num_colors | The number of colors in the input array. |
| steps | The total number of steps in the multi-gradient (must be greater than 1). |
| color_distribution | One weight per transition, so num_colors - 1 of them, each between 0.0 and 1.0 and together summing to 1.0. A transition given a larger weight takes up more of the gradient. |
| float * tiny_multigradient_hsl | ( | float * | colors, |
| size_t | num_colors, | ||
| size_t | steps ) |
Generates a multi-gradient of HSL colors based on an array of input colors and a specified number of steps equally distributed across the input colors.
The function returns a dynamically allocated array of integers, where each entry is three floats: hue, saturation and lightness. The memory comes from the arena, so tiny_arena_reset() or a matching tiny_arena_release() reclaims it and nothing frees it individually.
| colors | Pointer to an array of float values representing the input colors. Each color should be represented by three consecutive values (H, S, L). |
| num_colors | The number of colors in the input array. |
| steps | The total number of steps in the multi-gradient (must be greater than 1). |
| float * tiny_multigradient_hsl_sized | ( | float * | colors, |
| size_t | num_colors, | ||
| size_t | steps, | ||
| float * | color_distribution ) |
Generates a multi-gradient of HSL colors based on an array of input colors and a specified number of steps distributed based on color_distribution.
The function returns a dynamically allocated array of integers, where each entry is three floats: hue, saturation and lightness. The memory comes from the arena, so tiny_arena_reset() or a matching tiny_arena_release() reclaims it and nothing frees it individually.
| colors | Pointer to an array of float values representing the input colors. Each color should be represented by three consecutive values (H, S, L). |
| num_colors | The number of colors in the input array. |
| steps | The total number of steps in the multi-gradient (must be greater than 1). |
| color_distribution | One weight per transition, so num_colors - 1 of them, each between 0.0 and 1.0 and together summing to 1.0. A transition given a larger weight takes up more of the gradient. |
| float * tiny_multigradient_hsv | ( | float * | colors, |
| size_t | num_colors, | ||
| size_t | steps ) |
Generates a multi-gradient of HSV colors based on an array of input colors and a specified number of steps equally distributed across the input colors.
The function returns a dynamically allocated array of integers, where each entry is three floats: hue, saturation and value. The memory comes from the arena, so tiny_arena_reset() or a matching tiny_arena_release() reclaims it and nothing frees it individually.
| colors | Pointer to an array of float values representing the input colors. Each color should be represented by three consecutive values (H, S, V). |
| num_colors | The number of colors in the input array. |
| steps | The total number of steps in the multi-gradient (must be greater than 1). |
| float * tiny_multigradient_hsv_sized | ( | float * | colors, |
| size_t | num_colors, | ||
| size_t | steps, | ||
| float * | color_distribution ) |
Generates a multi-gradient of HSV colors based on an array of input colors and a specified number of steps distributed based on color_distribution.
The function returns a dynamically allocated array of integers, where each entry is three floats: hue, saturation and value. The memory comes from the arena, so tiny_arena_reset() or a matching tiny_arena_release() reclaims it and nothing frees it individually.
| colors | Pointer to an array of float values representing the input colors. Each color should be represented by three consecutive values (H, S, V). |
| num_colors | The number of colors in the input array. |
| steps | The total number of steps in the multi-gradient (must be greater than 1). |
| color_distribution | One weight per transition, so num_colors - 1 of them, each between 0.0 and 1.0 and together summing to 1.0. A transition given a larger weight takes up more of the gradient. |
| int * tiny_multigradient_rgb | ( | uint8_t * | colors, |
| size_t | num_colors, | ||
| size_t | steps ) |
Generates a multi-gradient of RGB colors based on an array of input colors and a specified number of steps equally distributed across the input colors.
The function returns a dynamically allocated array of integers, where each integer holds one RGB color as 0xRRGGBB. The memory comes from the arena, so tiny_arena_reset() or a matching tiny_arena_release() reclaims it and nothing frees it individually.
| colors | Pointer to an array of uint8_t values representing the input colors. Each color should be represented by three consecutive values (R, G, B). |
| num_colors | The number of colors in the input array. |
| steps | The total number of steps in the multi-gradient (must be greater than 1). |
| int * tiny_multigradient_rgb_sized | ( | uint8_t * | colors, |
| size_t | num_colors, | ||
| size_t | steps, | ||
| float * | color_distribution ) |
Generates a multi-gradient of RGB colors based on an array of input colors and a specified number of steps distributed based on color_distribution.
The function returns a dynamically allocated array of integers, where each integer holds one RGB color as 0xRRGGBB. The memory comes from the arena, so tiny_arena_reset() or a matching tiny_arena_release() reclaims it and nothing frees it individually.
| colors | Pointer to an array of uint8_t values representing the input colors. Each color should be represented by three consecutive values (R, G, B). |
| num_colors | The number of colors in the input array. |
| steps | The total number of steps in the multi-gradient (must be greater than 1). |
| color_distribution | One weight per transition, so num_colors - 1 of them, each between 0.0 and 1.0 and together summing to 1.0. A transition given a larger weight takes up more of the gradient. |
| int * tiny_multigradient_rgba | ( | uint8_t * | colors, |
| size_t | num_colors, | ||
| size_t | steps ) |
Generates a multi-gradient of RGBA colors based on an array of input colors and a specified number of steps equally distributed across the input colors.
The function returns a dynamically allocated array of integers, where each integer holds one RGBA color as 0xRRGGBBAA. The memory comes from the arena, so tiny_arena_reset() or a matching tiny_arena_release() reclaims it and nothing frees it individually.
| colors | Pointer to an array of uint8_t values representing the input colors. Each color should be represented by four consecutive values (R, G, B, A). |
| num_colors | The number of colors in the input array. |
| steps | The total number of steps in the multi-gradient (must be greater than 1). |
| int * tiny_multigradient_rgba_sized | ( | uint8_t * | colors, |
| size_t | num_colors, | ||
| size_t | steps, | ||
| float * | color_distribution ) |
Generates a multi-gradient of RGBA colors based on an array of input colors and a specified number of steps distributed based on color_distribution.
The function returns a dynamically allocated array of integers, where each integer holds one RGBA color as 0xRRGGBBAA. The memory comes from the arena, so tiny_arena_reset() or a matching tiny_arena_release() reclaims it and nothing frees it individually.
| colors | Pointer to an array of uint8_t values representing the input colors. Each color should be represented by four consecutive values (R, G, B, A). |
| num_colors | The number of colors in the input array. |
| steps | The total number of steps in the multi-gradient (must be greater than 1). |
| color_distribution | One weight per transition, so num_colors - 1 of them, each between 0.0 and 1.0 and together summing to 1.0. A transition given a larger weight takes up more of the gradient. |
| int tiny_rgb_to_cmyk | ( | uint8_t | r, |
| uint8_t | g, | ||
| uint8_t | b, | ||
| float * | c, | ||
| float * | m, | ||
| float * | y, | ||
| float * | k ) |
Converts RGB color values to CMYK (Cyan, Magenta, Yellow, Key/Black) color space.
The RGB values are expected to be in the range [0, 255], and the resulting CMYK values will be in the ranges:
| r | Red component (0-255) |
| g | Green component (0-255) |
| b | Blue component (0-255) |
| c | Pointer to store the Cyan value (0-1) |
| m | Pointer to store the Magenta value (0-1) |
| y | Pointer to store the Yellow value (0-1) |
| k | Pointer to store the Key/Black value (0-1) |
| int tiny_rgb_to_grayscale | ( | uint8_t | r, |
| uint8_t | g, | ||
| uint8_t | b ) |
Converts RGB color values to a grayscale value using the luminosity method.
The formula used is: grayscale = 0.21 * R + 0.72 * G + 0.07 * B
| r | Red component (0-255) |
| g | Green component (0-255) |
| b | Blue component (0-255) |
| int tiny_rgb_to_hsl | ( | uint8_t | r, |
| uint8_t | g, | ||
| uint8_t | b, | ||
| float * | h, | ||
| float * | s, | ||
| float * | l ) |
Converts RGB color values to HSL (Hue, Saturation, Lightness) color space.
The RGB values are expected to be in the range [0, 255], and the resulting HSL values will be in the ranges:
| r | Red component (0-255) |
| g | Green component (0-255) |
| b | Blue component (0-255) |
| h | Pointer to store the Hue value (0-360) |
| s | Pointer to store the Saturation value (0-1) |
| l | Pointer to store the Lightness value (0-1) |
| int tiny_rgb_to_hsv | ( | uint8_t | r, |
| uint8_t | g, | ||
| uint8_t | b, | ||
| float * | h, | ||
| float * | s, | ||
| float * | v ) |
Converts RGB color values to HSV (Hue, Saturation, Value) color space.
The RGB values are expected to be in the range [0, 255], and the resulting HSV values will be in the ranges:
| r | Red component (0-255) |
| g | Green component (0-255) |
| b | Blue component (0-255) |
| h | Pointer to store the Hue value (0-360) |
| s | Pointer to store the Saturation value (0-1) |
| v | Pointer to store the Value (Brightness) value (0-1) |