src/Colourful/Spaces/RGB/RGBColor.cs
/// <summary>
/// Returns a new color that has channels within the range, and at least one channel is maxed out to 1.
/// Does this by dividing all channels by the maximum channel value out of those three.
/// This is useful for scenarios where we're working with chromaticity.
/// </summary>
Returns a new color that has channels within the range, and at least one channel is maxed out to 1.
Does this by dividing all channels by the maximum channel value out of those three.
This is useful for scenarios where we're working with chromaticity.
Returns a new color that has channels within the range and at least one channel is maxed out to 1 . Does this by dividing all channels by the maximum channel value out of those three . This is useful for scenarios where we ' re working with chromaticity .
public RGBColor NormalizeIntensity()
        {
            var maxChannel = Max(R, Max(G, B));
            if (maxChannel == 0)
            {
                maxChannel = 1;
            }
            var r = (R / maxChannel).Clamp(0, 1);
            var g = (G / maxChannel).Clamp(0, 1);
            var b = (B / maxChannel).Clamp(0, 1);
            return new RGBColor(r, g, b);
        }
public RGBColor NormalizeIntensity ( ) { var maxChannel = Max ( R , Max ( G , B ) ) ; if ( maxChannel == 0 ) { maxChannel = 1 ; } var r = ( R / maxChannel ) . Clamp ( 0 , 1 ) ; var g = ( G / maxChannel ) . Clamp ( 0 , 1 ) ; var b = ( B / maxChannel ) . Clamp ( 0 , 1 ) ; return new RGBColor ( r , g , b ) ; }
Returns a new color that has channels within the range, and at least one channel is maxed out to 1.
Returns a new color that has channels within the range and at least one channel is maxed out to 1 .