From 54e36c4ff83d86346479bfae0e9bcef64afb1a49 Mon Sep 17 00:00:00 2001 From: rubidium Date: Tue, 10 Apr 2012 20:16:51 +0000 Subject: (svn r24111) -Codechange: use Colour more instead of manually bitstuffing --- src/gfx_type.h | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'src/gfx_type.h') diff --git a/src/gfx_type.h b/src/gfx_type.h index 466612755..2b792d090 100644 --- a/src/gfx_type.h +++ b/src/gfx_type.h @@ -158,8 +158,35 @@ union Colour { uint8 b, g, r, a; ///< colour channels in LE order #endif /* TTD_ENDIAN == TTD_BIG_ENDIAN */ }; + + /** + * Create a new colour. + * @param r The channel for the red colour. + * @param g The channel for the green colour. + * @param b The channel for the blue colour. + * @param a The channel for the alpha/transparency. + */ + Colour(uint8 r, uint8 g, uint8 b, uint8 a = 0xFF) : +#if TTD_ENDIAN == TTD_BIG_ENDIAN + a(a), r(r), g(g), b(b) +#else + b(b), g(g), r(r), a(a) +#endif /* TTD_ENDIAN == TTD_BIG_ENDIAN */ + { + } + + /** + * Create a new colour. + * @param The colour in the correct packed format. + */ + Colour(uint data = 0) : data(data) + { + } }; +assert_compile(sizeof(Colour) == sizeof(uint32)); + + /** Available font sizes */ enum FontSize { FS_NORMAL, ///< Index of the normal font in the font tables. -- cgit v1.2.3-54-g00ecf