#pragma once #include "Rgb.h" #include "fixed.h" #include "ColorConverter.h" class RgbMixer { public: template static Rgb Lerp(const Rgb& from, const Rgb& to, int t, int tMax) { return Rgb( (u32)((from.r * (tMax - t) + to.r * t) + (tMax >> 1)) / tMax, (u32)((from.g * (tMax - t) + to.g * t) + (tMax >> 1)) / tMax, (u32)((from.b * (tMax - t) + to.b * t) + (tMax >> 1)) / tMax); } static void MakeGradientPalette(u16* palette, const Rgb<8, 8, 8>& from, const Rgb<8, 8, 8>& to) { for (int i = 0; i < 16; i++) { auto newColor = Lerp(from, to, i, 15); palette[i] = ColorConverter::ToGBGR565(newColor); } } };