public ColorWheelEntry(string name, int min, int max, RGB color) { Name = name; Min = min; Max = max; Color = color; }
public RGB Mix(RGB other, float otherAmount) { float thisAmount = 1 - otherAmount; int red = (int)(otherAmount * other.Red + thisAmount * this.Red); int green = (int)(otherAmount * other.Green + thisAmount * this.Green); int blue = (int)(otherAmount * other.Blue + thisAmount * this.Blue); return new Color.RGB(red, green, blue); }
public static ColorWheelEntry Load(JObject obj) { string name = obj["name"].Value<string>(); byte min= obj["min"].Value<byte>(); byte max = obj["max"].Value<byte>(); string colorString = obj["color"].Value<string>(); int red = int.Parse(colorString.Substring(1, 2), System.Globalization.NumberStyles.AllowHexSpecifier); int green = int.Parse(colorString.Substring(3, 2), System.Globalization.NumberStyles.AllowHexSpecifier); int blue = int.Parse(colorString.Substring(5, 2), System.Globalization.NumberStyles.AllowHexSpecifier); RGB color = new RGB(red, green, blue); return new ColorWheelEntry(name, min, max, color); }
/// <summary> /// Converts YUV to RGB. /// </summary> /// <param name="y">Y must be in [0, 1].</param> /// <param name="u">U must be in [-0.436, +0.436].</param> /// <param name="v">V must be in [-0.615, +0.615].</param> public static RGB YUVtoRGB(double y, double u, double v) { RGB rgb = new RGB(); rgb.Red = Convert.ToInt32((y + 1.139837398373983740*v)*255); rgb.Green = Convert.ToInt32((y - 0.3946517043589703515*u - 0.5805986066674976801*v)*255); rgb.Blue = Convert.ToInt32((y + 2.032110091743119266*u)*255); return rgb; }
/// <summary> /// Converts RGB to CIELab. /// </summary> public static CIELab RGBtoLab(RGB rgb) { return XYZtoLab( RGBtoXYZ(rgb.Red, rgb.Green, rgb.Blue) ); }
/// <summary> /// Converts RGB to CIEXYZ. /// </summary> public static CIEXYZ RGBtoXYZ(RGB rgb) { return RGBtoXYZ(rgb.Red, rgb.Green, rgb.Blue); }
/// <summary> /// Converts RGB to YUV. /// </summary> public static YUV RGBtoYUV(RGB rgb) { return RGBtoYUV(rgb.Red, rgb.Green, rgb.Blue); }
/// <summary> /// Converts RGB to CMYK /// </summary> public static CMYK RGBtoCMYK(RGB rgb) { return RGBtoCMYK(rgb.Red, rgb.Green, rgb.Blue); }
/// <summary> /// Converts RGB to HSB. /// </summary> public static HSB RGBtoHSB(RGB rgb) { return RGBtoHSB(rgb.Red, rgb.Green, rgb.Blue); }