| 170 | } |
| 171 | |
| 172 | Float3 Color::ToHSV() const |
| 173 | { |
| 174 | const float rgbMin = Math::Min(R, G, B); |
| 175 | const float rgbMax = Math::Max(R, G, B); |
| 176 | const float rgbRange = rgbMax - rgbMin; |
| 177 | const float hue = rgbMax == rgbMin ? 0.0f : rgbMax == R ? Math::Mod((G - B) / rgbRange * 60.0f + 360.0f, 360.0f) : rgbMax == G ? (B - R) / rgbRange * 60.0f + 120.0f : rgbMax == B ? (R - G) / rgbRange * 60.0f + 240.0f : 0.0f; |
| 178 | const float saturation = rgbMax == 0.0f ? 0.0f : rgbRange / rgbMax; |
| 179 | const float value = rgbMax; |
| 180 | return Float3(hue, saturation, value); |
| 181 | } |
| 182 | |
| 183 | void Color::Lerp(const Color& start, const Color& end, float amount, Color& result) |
| 184 | { |
no test coverage detected