Created
March 25, 2024 07:38
-
-
Save baba-s/351a3201d344535c5d6d0b4e6653a735 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
namespace Kogane | |
{ | |
public static class ColorExtensionMethods | |
{ | |
public static Color Brighten | |
( | |
this Color color, | |
float amount | |
) | |
{ | |
Color.RGBToHSV( color, out var h, out var s, out var v ); | |
return Color.HSVToRGB( h, s, Mathf.Clamp01( v + amount ) ); | |
} | |
public static Color Darken | |
( | |
this Color color, | |
float amount | |
) | |
{ | |
Color.RGBToHSV( color, out var h, out var s, out var v ); | |
return Color.HSVToRGB( h, s, Mathf.Clamp01( v - amount ) ); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment