A1: add ColourUtil.LerpTowardWhite accent-tint helper
This commit is contained in:
@@ -102,6 +102,26 @@ internal static class ColourUtil
|
|||||||
return (abgr & 0x00FFFFFFu) | ((uint)newAlpha << 24);
|
return (abgr & 0x00FFFFFFu) | ((uint)newAlpha << 24);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Mixes an ABGR colour's RGB channels toward white (0xFF) by factor t in
|
||||||
|
// [0, 1]; the alpha byte is left untouched. A1 hover-sheen accent-tint:
|
||||||
|
// a low factor nudges the sweep toward the element's accent hue without
|
||||||
|
// going fully saturated (effect level stays "subtle"). RGB-only on
|
||||||
|
// purpose -- DrawHoverSheen owns the alpha falloff.
|
||||||
|
internal static uint LerpTowardWhite(uint abgr, float t)
|
||||||
|
{
|
||||||
|
t = Math.Clamp(t, 0f, 1f);
|
||||||
|
var a = (byte)((abgr >> 24) & 0xFFu);
|
||||||
|
var b = (byte)((abgr >> 16) & 0xFFu);
|
||||||
|
var g = (byte)((abgr >> 8) & 0xFFu);
|
||||||
|
var r = (byte)(abgr & 0xFFu);
|
||||||
|
|
||||||
|
var nr = (byte)Math.Round(r + (0xFF - r) * t);
|
||||||
|
var ng = (byte)Math.Round(g + (0xFF - g) * t);
|
||||||
|
var nb = (byte)Math.Round(b + (0xFF - b) * t);
|
||||||
|
|
||||||
|
return ((uint)a << 24) | ((uint)nb << 16) | ((uint)ng << 8) | nr;
|
||||||
|
}
|
||||||
|
|
||||||
public static uint HexToRgba(string hex)
|
public static uint HexToRgba(string hex)
|
||||||
{
|
{
|
||||||
ArgumentNullException.ThrowIfNull(hex);
|
ArgumentNullException.ThrowIfNull(hex);
|
||||||
|
|||||||
Reference in New Issue
Block a user