public static C64Colors ToC64Color(this Color color) { if (!ColorMap.DictRgb.ContainsKey(color.ToRgb())) { throw new ArgumentException($"Pixel color {color.ToRgb()} not a valid C64 color."); } return(ColorMap.DictRgb[color.ToRgb()]); }
public void ToString_HexColor_ReturnRGB() { var heyColor = new Color("7BFF14"); var result = heyColor.ToRgb(); Assert.Equal(result, "123 255 20"); }
/// <summary> /// Constructor /// </summary> /// <param name="value">The value that the element should wrap.</param> /// <param name="outputAttribute">The output attribute for the value.</param> public ValueElement(object value, OutputAttribute outputAttribute) { bool gotValue = false; this.RealValue = value; if (value is bool b) { Keyword keyword = b ? (outputAttribute.TrueKeyword == Keyword.Undefined ? Keyword.On : outputAttribute.TrueKeyword) : (outputAttribute.FalseKeyword == Keyword.Undefined ? Keyword.Off : outputAttribute.FalseKeyword); if (keyword == Keyword.Null) { this.active = false; return; } value = keyword; } if (outputAttribute.Rgb && value is Color color) { value = Color.ToRgb(color); } switch (value) { case Enum _: KeywordAttribute attr = value.GetType().GetField(value.ToString() !).GetCustomAttributeFast <KeywordAttribute>(); if (attr != null) { this.Value = KeywordAttribute.ToString(attr.Keyword); if (string.IsNullOrEmpty(this.Value)) { this.Value = null; } gotValue = true; } break; case IValue v: if (!v.HasValue) { this.Value = null; gotValue = true; } break; } if (!gotValue) { this.Value = value.ToString(); } }
private void CovnertFrom(Color color) { int from = color.ToRgb(); int to = 0; RGBXYZ.ToXYZ((byte *)&from, (byte *)&to); FromXyz(to); }
private void CovnertFrom(Color color) { int from = color.ToRgb(); int to = 0; RGBLAB.ToLAB((byte *)&from, (byte *)&to); FromLab(to); }
public void TestColorSerialization(Color value) { const string Name = "ColorValue"; var element = XElementSerializer.ToXml(Name, value); Check.That(element.Name.LocalName).IsEqualTo(Name); Check.That(XElementSerializer.ToColor(element).ToRgb()).IsEqualTo(value.ToRgb()); }
protected Excel.Shape AddShape(MsoAutoShapeType shapeType, Rect rect, Color color) { Excel.Shape shape = Chart.Shapes.AddShape(shapeType, (float)rect.Left, (float)rect.Top, (float)rect.Width, (float)rect.Height); shape.Fill.ForeColor.RGB = color.ToRgb(); shape.Fill.Transparency = color.GetAlpha(); Shapes.Add(shape); return(shape); }
public JToken JsonSave() { var result = new JObject() { new JProperty(JsonNames.Id, m_id), new JProperty(JsonNames.Sku, m_sku), new JProperty(JsonNames.AreaSize, m_areaSize.ToString()), new JProperty(JsonNames.Quantity, m_quantity), new JProperty(JsonNames.Color, m_color.ToRgb()) }; return(result); }
/// <summary> /// Returns a string that can be used to embed color in strings. /// </summary> /// <param name="color">Color to format and return.</param> /// <returns>Embeddable color string for chat messages.</returns> public static string Embed(this Color color) { return($"{{{color.ToRgb():X6}}}"); }
/// <summary> /// Gets a string representation of the current state. /// </summary> /// <returns>The stringified state, for example, "Tetrads of #123456."</returns> public override string ToString() { return(string.Format("{0} of {1}", SchemeType.ToString(), Color.ToRgb().ToHtml())); }
public static string ToRgbString(this Color color) { return(color.ToRgb().ToString("X6")); }
public static int ToRgb(Color color) { return(color.ToRgb()); }
public void WriteXml(XmlWriter writer) { writer.WriteString(color.ToRgb().ToString()); }
/// <summary> /// Returns the color in the form it would be in a file. /// </summary> /// <returns>The color in a "R G B[tab]Name" form.</returns> public override string ToString() { var rgb = Color.ToRgb(); return(string.Format("{0} {1} {2}\t{3}", rgb.R8, rgb.G8, rgb.B8, Name)); }
public PaletteColor(Color color, string stylePrefix) { this.Color = color; this.StyleColors = new[] { new StyleColor() { Key = stylePrefix + ".hex", Value = color.ToHex() }, new StyleColor() { Key = stylePrefix + ".rgb", Value = color.ToRgb() }, new StyleColor() { Key = stylePrefix + ".rgbp", Value = color.ToRgbPartial() }, new StyleColor() { Key = stylePrefix + ".rgba", Value = color.ToRgba() }, new StyleColor() { Key = stylePrefix + ".rgbap", Value = color.ToRgbaPartial() }, }; }
/// <summary> /// Translates the specified <see cref="Color"/> structure to an HTML string /// color representation. /// </summary> /// <param name="color"> /// The <see cref="Color"/> structure to translate. /// </param> /// <param name="alpha"> /// <see langword="true"/> to translate also the alpha value; otherwise, /// <see langword="false"/>. /// </param> public static string ToHtml(Color color, bool alpha = false) => color == default ? null : ToHtml(alpha ? color.ToArgb() : color.ToRgb(), alpha);
/// <summary> /// Sets the LED color at the specified position. /// </summary> /// <param name="pos">The position in the list.</param> /// <param name="color">The color to set</param> public void SetColor(int pos, Color color) { rpi_ws281x.ws2811_led_set(_channel, pos, color.ToRgb()); }
public static XElement ToXml(string name, Color value) => new XElement(name, $"{value.ToRgb():X6}");
protected Excel.Shape AddShape(MsoAutoShapeType shapeType, Rect rect, Color color) { Excel.Shape shape = Chart.Shapes.AddShape(shapeType, (float)rect.Left, (float)rect.Top, (float)rect.Width, (float)rect.Height); shape.Fill.ForeColor.RGB = color.ToRgb(); shape.Fill.Transparency = color.GetAlpha(); Shapes.Add(shape); return shape; }