Skip to content

Commit

Permalink
feat: add colors ops to pl_math.h
Browse files Browse the repository at this point in the history
  • Loading branch information
hoffstadt committed Oct 22, 2024
1 parent db87039 commit e713c3e
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions libs/pl_math.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ Index of this file:
// [SECTION] matrix ops
// [SECTION] quaternion ops
// [SECTION] rect ops
// [SECTION] colors
// [SECTION] implementations
*/

Expand Down Expand Up @@ -387,6 +388,28 @@ static inline plRect pl_rect_move_start (const plRect* ptRect, float fX, floa
static inline plRect pl_rect_move_start_x (const plRect* ptRect, float fX) { const plRect tResult = { { fX, ptRect->tMin.y}, { fX + ptRect->tMax.x - ptRect->tMin.x, ptRect->tMax.y} }; return tResult;}
static inline plRect pl_rect_move_start_y (const plRect* ptRect, float fY) { const plRect tResult = {{ ptRect->tMin.x, fY}, { ptRect->tMax.x, fY + ptRect->tMax.y - ptRect->tMin.y}}; return tResult;}

//-----------------------------------------------------------------------------
// [SECTION] colors
//-----------------------------------------------------------------------------

// creates packed 32-bit encoded colors
#define PL_COLOR_32_RGBA(R, G, B, A) ((uint32_t)(255.0f * (R) + 0.5f) | (uint32_t) (255.0f * (G) + 0.5f) << 8 | (uint32_t) (255.0f * (B) + 0.5f) << 16 | (uint32_t) (255.0f * (A) + 0.5f) << 24)
#define PL_COLOR_32_VEC4(X) ((uint32_t)(255.0f * (X).r + 0.5f) | (uint32_t) (255.0f * (X).g + 0.5f) << 8 | (uint32_t) (255.0f * (X).b + 0.5f) << 16 | (uint32_t) (255.0f * (X).a + 0.5f) << 24)
#define PL_COLOR_32_RGB(R, G, B) ((uint32_t)(255.0f * (R) + 0.5f) | (uint32_t) (255.0f * (G) + 0.5f) << 8 | (uint32_t) (255.0f * (B) + 0.5f) << 16 | (uint32_t) (255.5f) << 24)
#define PL_COLOR_32_VEC3(X) ((uint32_t)(255.0f * (X).r + 0.5f) | (uint32_t) (255.0f * (X).g + 0.5f) << 8 | (uint32_t) (255.0f * (X).b + 0.5f) << 16 | (uint32_t) (255.5f) << 24)
#define PL_COLOR_32_WHITE UINT32_MAX
#define PL_COLOR_32_BLACK 0x00
#define PL_COLOR_32_RED 0xFF0000FF
#define PL_COLOR_32_BLUE 0xFFFF0000
#define PL_COLOR_32_DARK_BLUE 0xFF8B0000
#define PL_COLOR_32_GREEN 0xFF00FF00
#define PL_COLOR_32_YELLOW 0xFF00FFFF
#define PL_COLOR_32_ORANGE 0xFF00A5FF
#define PL_COLOR_32_MAGENTA 0xFFFF00FF
#define PL_COLOR_32_CYAN 0xFFFFFF00
#define PL_COLOR_32_GREY 0xFF808080
#define PL_COLOR_32_LIGHT_GREY 0xFFD3D3D3

//-----------------------------------------------------------------------------
// [SECTION] implementations
//-----------------------------------------------------------------------------
Expand Down

0 comments on commit e713c3e

Please sign in to comment.