OpenBarnyard
 
Loading...
Searching...
No Matches
TColor.h
Go to the documentation of this file.
1#pragma once
2#include "Toshi/Typedefs.h"
3
4#define TCOLOR( R, G, B ) ( ( ( ( R & 0xff ) << 8 | G & 0xff ) << 8 | B & 0xff ) | 0xFF000000 )
5#define TCOLOR_ALPHA( R, G, B, A ) ( ( ( ( R & 0xff ) << 8 | G & 0xff ) << 8 | B & 0xff ) | ( TUINT32( A ) << 24 ) )
6#define TCOLOR_GET_ALPHA( COLOR ) ( ( COLOR >> 24 ) & 0xff )
7#define TCOLOR_GET_RED( COLOR ) ( ( COLOR >> 16 ) & 0xff )
8#define TCOLOR_GET_GREEN( COLOR ) ( ( COLOR >> 8 ) & 0xff )
9#define TCOLOR_GET_BLUE( COLOR ) ( COLOR & 0xff )
10#define TCOLOR_GET_A( COLOR ) TCOLOR_GET_ALPHA( COLOR )
11#define TCOLOR_GET_R( COLOR ) TCOLOR_GET_RED( COLOR )
12#define TCOLOR_GET_G( COLOR ) TCOLOR_GET_GREEN( COLOR )
13#define TCOLOR_GET_B( COLOR ) TCOLOR_GET_BLUE( COLOR )
14
16
17struct TColor
18{
19 union
20 {
21 struct
22 {
27 };
28
30 };
31
32 TColor() = default;
33
34 TFORCEINLINE constexpr TColor( TUINT32 a_uiColor )
35 : Value32( a_uiColor ) {}
36
37 TFORCEINLINE constexpr TColor( TUINT8 a_uiR, TUINT8 a_uiG, TUINT8 a_uiB, TUINT8 a_uiA = 255 )
38 : R( a_uiR ), G( a_uiG ), B( a_uiB ), A( a_uiA ) {}
39
41 {
42 Value32 = a_uiColor;
43 }
44};
45
46TSTATICASSERT( sizeof( TColor ) == 4 );
47
#define TOSHI_NAMESPACE_START
Definition Defines.h:47
#define TFORCEINLINE
Definition Defines.h:74
#define TSTATICASSERT(...)
Definition Defines.h:67
#define TOSHI_NAMESPACE_END
Definition Defines.h:50
uint8_t TUINT8
Definition Typedefs.h:17
uint32_t TUINT32
Definition Typedefs.h:13
TUINT8 A
Definition TColor.h:26
TUINT8 G
Definition TColor.h:24
TFORCEINLINE constexpr TColor(TUINT8 a_uiR, TUINT8 a_uiG, TUINT8 a_uiB, TUINT8 a_uiA=255)
Definition TColor.h:37
TFORCEINLINE constexpr TColor(TUINT32 a_uiColor)
Definition TColor.h:34
TUINT32 Value32
Definition TColor.h:29
TFORCEINLINE TColor & operator=(TUINT32 a_uiColor)
Definition TColor.h:40
TUINT8 B
Definition TColor.h:23
TColor()=default
TUINT8 R
Definition TColor.h:25