Skip to content

ColorConvert

Namespace Nfty.Core.Imaging in assembly Nfty.Ticket.

public static class ColorConvert

Conversions between RGB and the two color spaces a layer can be authored in. Hue is in degrees and wraps at 360; saturation, value and lightness are 0..1 fractions.

Methods

HslToRgb(double, double, double)

public static RgbColor HslToRgb(double h, double s, double l);

Converts a hue/saturation/lightness color to RGB.

Parameters

  • h (double) - Hue in degrees; wrapped, so 360 is 0.
  • s (double) - Saturation, 0..1.
  • l (double) - Lightness, 0..1.

Returns. The color.

HsvToRgb(double, double, double)

public static RgbColor HsvToRgb(double h, double s, double v);

Converts a hue/saturation/value color to RGB.

Parameters

  • h (double) - Hue in degrees; wrapped, so 360 is 0.
  • s (double) - Saturation, 0..1.
  • v (double) - Value, 0..1.

Returns. The color.

RgbToHsl(RgbColor)

public static (double, double, double) RgbToHsl(RgbColor c);

Converts an RGB color to hue/saturation/lightness.

Parameters

  • c (RgbColor) - The color.

Returns. Hue in degrees, saturation and lightness as 0..1.

RgbToHsv(RgbColor)

public static (double, double, double) RgbToHsv(RgbColor c);

Converts an RGB color to hue/saturation/value.

Parameters

  • c (RgbColor) - The color.

Returns. Hue in degrees, saturation and value as 0..1.