Skip to content

Instantly share code, notes, and snippets.

@baba-s
Created March 25, 2024 07:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save baba-s/351a3201d344535c5d6d0b4e6653a735 to your computer and use it in GitHub Desktop.
Save baba-s/351a3201d344535c5d6d0b4e6653a735 to your computer and use it in GitHub Desktop.
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