make colour definition more consise

This commit is contained in:
2025-06-18 14:15:05 +02:00
parent 16e0c9a95e
commit cf1ed2a721

View File

@@ -4,23 +4,17 @@
#include <stdint.h> #include <stdint.h>
// stores colour in a rgba format stored as little-endian, each channel being a 8 bits wide. // stores colour in a rgba format stored as little-endian, each channel being a 8 bits wide.
typedef union { typedef union colour32 {
uint32_t dat; // full colour data; little-endian uint32_t dat; // full colour data; little-endian
#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ #if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
// colour channel information for little-endian systems // colour channel information for little-endian systems
struct { struct {
uint8_t a; uint8_t a, b, g, r;
uint8_t b;
uint8_t g;
uint8_t r;
} ch; } ch;
#elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ #elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
// colour channel information for big-endian systems // colour channel information for big-endian systems
struct { struct {
uint8_t r; uint8_t r, g, b, a;
uint8_t g;
uint8_t b;
uint8_t a;
} ch; } ch;
#endif #endif
} colour32; } colour32;