/// <summary> /// Initializes a new instance of the <see cref="NGraphics.Custom.Models.Pen"/> class. /// </summary> /// <param name="color">Color.</param> /// <param name="width">Width.</param> public Pen(Color color, double width = 1.0) { Color = color; Width = width; LineJoin = SvgStrokeLineJoin.Miter; LineCap = SvgStrokeLineCap.Square; }
/// <summary> /// Initializes a new instance of the <see cref="NGraphics.Custom.Models.Pen"/> class. /// </summary> public Pen() { Color = Colors.Black; Width = 1; LineJoin = SvgStrokeLineJoin.Miter; LineCap = SvgStrokeLineCap.Square; }
public IImage CreateImage(Color[] colors, int width, double scale = 1.0) { var pixelWidth = width; var pixelHeight = colors.Length/width; var acolors = new int[pixelWidth*pixelHeight]; for (var i = 0; i < colors.Length; i++) { acolors[i] = colors[i].Argb; } var bitmap = Bitmap.CreateBitmap(acolors, pixelWidth, pixelHeight, Bitmap.Config.Argb8888); return new BitmapImage(bitmap, scale); }
public static bool TryParse(string colorString, out Color color) { if (string.IsNullOrWhiteSpace(colorString)) { color = Clear; return false; } var s = colorString.Trim(); if (s.Length == 7 && s[0] == '#') { var icult = CultureInfo.InvariantCulture; var r = int.Parse(s.Substring(1, 2), NumberStyles.HexNumber, icult); var g = int.Parse(s.Substring(3, 2), NumberStyles.HexNumber, icult); var b = int.Parse(s.Substring(5, 2), NumberStyles.HexNumber, icult); color = new Color(r/255.0, g/255.0, b/255.0, 1); return true; } if (s.Length == 9 && s[0] == '#') { var icult = CultureInfo.InvariantCulture; var r = int.Parse(s.Substring(1, 2), NumberStyles.HexNumber, icult); var g = int.Parse(s.Substring(3, 2), NumberStyles.HexNumber, icult); var b = int.Parse(s.Substring(5, 2), NumberStyles.HexNumber, icult); var a = int.Parse(s.Substring(7, 2), NumberStyles.HexNumber, icult); color = new Color(r/255.0, g/255.0, b/255.0, a/255.0); return true; } Color nc; if (names.TryGetValue(s.ToLowerInvariant(), out nc)) { color = nc; return true; } color = Clear; return false; }
public IImage CreateImage(Color[] colors, int width, double scale = 1.0) { return new NullImage(); }
/// <summary> /// Withs the color. /// </summary> /// <returns>The color.</returns> /// <param name="color">Color.</param> public Pen WithColor(Color color) { return new Pen(color, Width); }
public static Color4 ToColor4(this Color color) { return(new Color4(color.Argb)); }
public static System.Drawing.Color GetColor(this Color color) { return(System.Drawing.Color.FromArgb(color.A, color.R, color.G, color.B)); }