diff options
author | Andrei Karas <akaras@inbox.ru> | 2016-12-21 23:02:27 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2016-12-21 23:15:11 +0300 |
commit | 6addecc3615d5e3f9caaafd39aa639c8ff49115b (patch) | |
tree | d448d51378fbf6b05215109632734212b51d27e7 /src/resources/dye/dyecolor.h | |
parent | e59b20b4cff4bf54c0b2ea91dbf09345da9d5fe4 (diff) | |
download | plus-6addecc3615d5e3f9caaafd39aa639c8ff49115b.tar.gz plus-6addecc3615d5e3f9caaafd39aa639c8ff49115b.tar.bz2 plus-6addecc3615d5e3f9caaafd39aa639c8ff49115b.tar.xz plus-6addecc3615d5e3f9caaafd39aa639c8ff49115b.zip |
Use precalculated values for A and S dyes.
Diffstat (limited to 'src/resources/dye/dyecolor.h')
-rw-r--r-- | src/resources/dye/dyecolor.h | 33 |
1 files changed, 26 insertions, 7 deletions
diff --git a/src/resources/dye/dyecolor.h b/src/resources/dye/dyecolor.h index 11e12a038..11257fc22 100644 --- a/src/resources/dye/dyecolor.h +++ b/src/resources/dye/dyecolor.h @@ -27,42 +27,61 @@ #include "localconsts.h" +#define buildHex(a, b, c, d) \ + (a) * 16777216U + (b) * 65536U + (c) * 256U + CAST_U32(d) + struct DyeColor final { - DyeColor() noexcept2 + DyeColor() noexcept2 : + valueA(buildHex(0, 0, 0, 255)), + valueS(buildHex(0, 0, 0, 0)), + valueSOgl(buildHex(0, 0, 0, 0)) { value[3] = 255; } DyeColor(const uint8_t r, const uint8_t g, - const uint8_t b) noexcept2 + const uint8_t b) noexcept2 : + valueA(buildHex(r, g, b, 255)), + valueS(buildHex(r, g, b, 0)), + valueSOgl(buildHex(0, b, g, r)) { value[0] = r; value[1] = g; value[2] = b; value[3] = 255; -// value2 = buildHex(r, g, b, 255); } DyeColor(const uint8_t r, const uint8_t g, const uint8_t b, - const uint8_t a) noexcept2 + const uint8_t a) noexcept2 : + valueA(buildHex(r, g, b, a)), + valueS(buildHex(r, g, b, 0)), + valueSOgl(buildHex(0, b, g, r)) { value[0] = r; value[1] = g; value[2] = b; value[3] = a; -// value2 = buildHex(r, g, b, a); + } + + void update() + { + valueA = buildHex(value[0], value[1], value[2], value[3]); + valueS = buildHex(value[0], value[1], value[2], 0); + valueSOgl = buildHex(0, value[2], value[1], value[0]); } union { uint8_t value[4]; - uint32_t value1; + uint32_t valueAOgl; }; -// uint32_t value2; + uint32_t valueA; + uint32_t valueS; + uint32_t valueSOgl; }; #endif // RESOURCES_DYE_DYECOLOR_H |