aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/SideChains/Colourful/Other/SaturationLChFormulas.cs
blob: 24ecb4d205e0db8df9626d5d738f3dfd1d42733e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
namespace Colourful
{
    /// <summary>
    /// Extensions useful for <see cref="LChabColor" /> and <see cref="LChuvColor" /> color spaces.
    /// </summary>
    internal static class SaturationLChFormulas
    {
        /// <summary>
        /// Returns saturation of the color (chroma normalized by lightness)
        /// </summary>
        public static double GetSaturation(double L, double C)
        {
            var result = 100 * (C / L);

            if (double.IsNaN(result))
                return 0;

            return result;
        }

        /// <summary>
        /// Gets chroma from saturation and lightness
        /// </summary>
        public static double GetChroma(double saturation, double L)
        {
            var result = L * (saturation / 100);
            return result;
        }
    }
}