summaryrefslogtreecommitdiff
path: root/src/gfx_type.h
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2012-04-10 20:16:51 +0000
committerrubidium <rubidium@openttd.org>2012-04-10 20:16:51 +0000
commit54e36c4ff83d86346479bfae0e9bcef64afb1a49 (patch)
treee5a3d23f17267095d47dda66face3f2e7c77d67a /src/gfx_type.h
parentbf867483005c034e0040a976b94a2dc8698bd35f (diff)
downloadopenttd-54e36c4ff83d86346479bfae0e9bcef64afb1a49.tar.xz
(svn r24111) -Codechange: use Colour more instead of manually bitstuffing
Diffstat (limited to 'src/gfx_type.h')
-rw-r--r--src/gfx_type.h27
1 files changed, 27 insertions, 0 deletions
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.