Ejemplo n.º 1
0
 /// <summary>
 /// Create the nearest LCH equivalent of an HSL color.
 /// </summary>
 /// <param name="hsl">Target color in HSL space.</param>
 /// <returns>The LCH equivalent of the HSL color.</returns>
 public static ColorLCH CreateFromHSL(ColorHSL hsl)
 {
   return CreateFromLAB(ColorLAB.CreateFromHSL(hsl));
 }
Ejemplo n.º 2
0
    ///// <summary>
    ///// Create the nearest XYZ equivalent of an RGB color.
    ///// </summary>
    ///// <param name="rgb">Target color in RGB space.</param>
    ///// <returns>The XYZ equivalent of the RGB color.</returns>
    //public static ColorXYZ CreateFromRGB(ColorRGB rgb)
    //{
    //  ColorXYZ newColor = new ColorXYZ();
    //  double r = ((double)rgb.m_r / 255.0);        //R from 0 to 255
    //  double g = ((double)rgb.m_g / 255.0);        //G from 0 to 255
    //  double b = ((double)rgb.m_b / 255.0);        //B from 0 to 255
    //  double a = ((double)rgb.m_a / 255.0);        //A from 0 to 255

    //  if (r > 0.04045)
    //  {
    //    r = Math.Pow(((r + 0.055) / 1.055), 2.4);
    //  }
    //  else
    //  {
    //    r /= 12.92;
    //  }

    //  if (g > 0.04045)
    //  {
    //    g = Math.Pow(((g + 0.055) / 1.055), 2.4);
    //  }
    //  else
    //  {
    //    g /= 12.92;
    //  }

    //  if (b > 0.04045)
    //  {
    //    b = Math.Pow(((b + 0.055) / 1.055), 2.4);
    //  }
    //  else
    //  {
    //    b /= 12.92;
    //  }

    //  r *= 100.0;
    //  g *= 100.0;
    //  b *= 100.0;

    //  //Observer. = 2°, Illuminant = D65
    //  newColor.m_x = r * 0.4124 + g * 0.3576 + b * 0.1805;
    //  newColor.m_y = r * 0.2126 + g * 0.7152 + b * 0.0722;
    //  newColor.m_z = r * 0.0193 + g * 0.1192 + b * 0.9505;
    //  newColor.m_a = a;

    //  return newColor;
    //}
    /// <summary>
    /// Create the nearest XYZ equivalent of an HSL color.
    /// </summary>
    /// <param name="hsl">Target color in HSL space.</param>
    /// <returns>The XYZ equivalent of the HSL color.</returns>
    public static ColorXYZ CreateFromHSL(ColorHSL hsl)
    {
      return new ColorXYZ(hsl);
    }
Ejemplo n.º 3
0
 ///// <summary>
 ///// Create the nearest LAB equivalent of an RGB color.
 ///// </summary>
 ///// <param name="rgb">Target color in RGB space.</param>
 ///// <returns>The LAB equivalent of the RGB color.</returns>
 //public static ColorLAB CreateFromRGB(ColorRGB rgb)
 //{
 //  return CreateFromXYZ(ColorXYZ.CreateFromRGB(rgb));
 //}
 /// <summary>
 /// Create the nearest LAB equivalent of an HSL color.
 /// </summary>
 /// <param name="hsl">Target color in HSL space.</param>
 /// <returns>The LAB equivalent of the HSL color.</returns>
 public static ColorLAB CreateFromHSL(ColorHSL hsl)
 {
   return CreateFromXYZ(ColorXYZ.CreateFromHSL(hsl));
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Constructs the nearest CMYK equivalent of an HSL color.
 /// </summary>
 /// <param name="hsl">Target color in HSL space.</param>
 /// <returns>The CMYK equivalent of the HSL color.</returns>
 public static ColorCMYK CreateFromHSL(ColorHSL hsl)
 {
   return new ColorCMYK(hsl);
 }
Ejemplo n.º 5
0
 /// <summary>
 /// Create the nearest LCH equivalent of an HSL color.
 /// </summary>
 /// <param name="hsl">Target color in HSL space.</param>
 /// <returns>The LCH equivalent of the HSL color.</returns>
 public static ColorLCH CreateFromHSL(ColorHSL hsl)
 {
     return(CreateFromLAB(ColorLAB.CreateFromHSL(hsl)));
 }
Ejemplo n.º 6
0
 ///// <summary>
 ///// Create the nearest LAB equivalent of an RGB color.
 ///// </summary>
 ///// <param name="rgb">Target color in RGB space.</param>
 ///// <returns>The LAB equivalent of the RGB color.</returns>
 //public static ColorLAB CreateFromRGB(ColorRGB rgb)
 //{
 //  return CreateFromXYZ(ColorXYZ.CreateFromRGB(rgb));
 //}
 /// <summary>
 /// Create the nearest LAB equivalent of an HSL color.
 /// </summary>
 /// <param name="hsl">Target color in HSL space.</param>
 /// <returns>The LAB equivalent of the HSL color.</returns>
 public static ColorLAB CreateFromHSL(ColorHSL hsl)
 {
     return(CreateFromXYZ(ColorXYZ.CreateFromHSL(hsl)));
 }
Ejemplo n.º 7
0
        ///// <summary>
        ///// Create the nearest XYZ equivalent of an RGB color.
        ///// </summary>
        ///// <param name="rgb">Target color in RGB space.</param>
        ///// <returns>The XYZ equivalent of the RGB color.</returns>
        //public static ColorXYZ CreateFromRGB(ColorRGB rgb)
        //{
        //  ColorXYZ newColor = new ColorXYZ();
        //  double r = ((double)rgb.m_r / 255.0);        //R from 0 to 255
        //  double g = ((double)rgb.m_g / 255.0);        //G from 0 to 255
        //  double b = ((double)rgb.m_b / 255.0);        //B from 0 to 255
        //  double a = ((double)rgb.m_a / 255.0);        //A from 0 to 255

        //  if (r > 0.04045)
        //  {
        //    r = Math.Pow(((r + 0.055) / 1.055), 2.4);
        //  }
        //  else
        //  {
        //    r /= 12.92;
        //  }

        //  if (g > 0.04045)
        //  {
        //    g = Math.Pow(((g + 0.055) / 1.055), 2.4);
        //  }
        //  else
        //  {
        //    g /= 12.92;
        //  }

        //  if (b > 0.04045)
        //  {
        //    b = Math.Pow(((b + 0.055) / 1.055), 2.4);
        //  }
        //  else
        //  {
        //    b /= 12.92;
        //  }

        //  r *= 100.0;
        //  g *= 100.0;
        //  b *= 100.0;

        //  //Observer. = 2°, Illuminant = D65
        //  newColor.m_x = r * 0.4124 + g * 0.3576 + b * 0.1805;
        //  newColor.m_y = r * 0.2126 + g * 0.7152 + b * 0.0722;
        //  newColor.m_z = r * 0.0193 + g * 0.1192 + b * 0.9505;
        //  newColor.m_a = a;

        //  return newColor;
        //}
        /// <summary>
        /// Create the nearest XYZ equivalent of an HSL color.
        /// </summary>
        /// <param name="hsl">Target color in HSL space.</param>
        /// <returns>The XYZ equivalent of the HSL color.</returns>
        public static ColorXYZ CreateFromHSL(ColorHSL hsl)
        {
            return(new ColorXYZ(hsl));
        }
Ejemplo n.º 8
0
 /// <summary>
 /// Constructs the nearest CMYK equivalent of an HSL color.
 /// </summary>
 /// <param name="hsl">Target color in HSL space.</param>
 /// <returns>The CMYK equivalent of the HSL color.</returns>
 public static ColorCMYK CreateFromHSL(ColorHSL hsl)
 {
     return(new ColorCMYK(hsl));
 }