mirror of
https://github.com/DCFApixels/DragonECS-Unity.git
synced 2025-09-19 10:34:35 +08:00
20 lines
603 B
C#
20 lines
603 B
C#
![]() |
using UnityEngine;
|
|||
|
|
|||
|
namespace DCFApixels.DragonECS.Unity.Internal
|
|||
|
{
|
|||
|
internal static class ColorUtility
|
|||
|
{
|
|||
|
public static Color Desaturate(this Color self, float t)
|
|||
|
{
|
|||
|
float r = self.r;
|
|||
|
float g = self.g;
|
|||
|
float b = self.b;
|
|||
|
//float gray = r * 0.299f + g * 0.587f + b * 0.114f;
|
|||
|
float gray = r * 0.3333333f + g * 0.3333333f + b * 0.3333333f;
|
|||
|
r = r + (gray - r) * (1 - t);
|
|||
|
g = g + (gray - g) * (1 - t);
|
|||
|
b = b + (gray - b) * (1 - t);
|
|||
|
return new Color(r, g, b);
|
|||
|
}
|
|||
|
}
|
|||
|
}
|