public ColorRGB32Bit(byte a, ColorRGB32Bit c) { _a = a; _r = c.R; _g = c.G; _b = c.B; }
public ColorRGB(ColorRGB32Bit color) { var temp = FromColor(color); this._alpha = temp._alpha; this._r = temp._r; this._g = temp._g; this._b = temp._b; }
private static ColorRGB FromColor(ColorRGB32Bit color) { var c = new ColorRGB(color.Alpha / 255.0, color.R / 255.0, color.G / 255.0, color.B / 255.0); return(c); }
private bool Equals(ColorRGB32Bit other) { return(this._a == other._a && this._r == other._r && this._g == other._g && this._b == other._b); }
public void WriteNodeOption(string name, ColorRGB32Bit color) { this.write("{0}=\"{1}\" ", name, color.ToWebColorString()); }
public ColorRGB32Bit(byte alpha, ColorRGB32Bit c) : this(alpha, c.R, c.G, c.B) { }
/// <summary> /// /// </summary> /// <example> /// Sample usage: /// /// System.Drawing.Color c; /// bool result = TryParseRGBWebColorString("#ffffff", ref c); /// if (result) /// { /// //it was correctly parsed /// } /// else /// { /// //it was not correctly parsed /// } /// /// </example> /// <param name="webcolor"></param> ///<returns></returns> public static ColorRGB32Bit?TryParseWebColorString(string webcolor) { // fail if string is null if (webcolor == null) { return(null); } // fail if string is empty if (webcolor.Length < 1) { return(null); } // clean any leading or trailing whitespace webcolor = webcolor.Trim(); // fail if string is empty if (webcolor.Length < 1) { return(null); } // strip leading # if it is there while (webcolor.StartsWith("#")) { webcolor = webcolor.Substring(1); } // clean any leading or trailing whitespace webcolor = webcolor.Trim(); // fail if string is empty if (webcolor.Length < 1) { return(null); } // fail if string doesn't have exactly 6 digits (this means alpha was not provided) if (webcolor.Length != 6) { return(null); } int current_color = 0; bool result = System.Int32.TryParse(webcolor, System.Globalization.NumberStyles.HexNumber, null, out current_color); if (webcolor.Length == 6) { // only six digits were given so add alpha current_color = (int)(((uint)current_color) | ((uint)0xff000000)); } if (!result) { // fail if parsing didn't work return(null); } // at this point parsing worked // the integer value is converted directly to an rgb value var the_color = new ColorRGB32Bit(current_color); return(the_color); }
private bool Equals(ColorRGB32Bit other) { return (this._a == other._a && this._r == other._r && this._g == other._g && this._b == other._b); }