Example #1
0
 public Pen(Color color, double width = 1.0)
 {
     Color = color;
     Width = width;
     LineJoin = SvgStrokeLineJoin.Miter;
     LineCap = SvgStrokeLineCap.Square;
 }
Example #2
0
        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;
            }

            Color nc;
            if (names.TryGetValue(s.ToLowerInvariant(), out nc))
            {
                color = nc;
                return true;
            }

            color = Clear;
            return false;
        }
Example #3
0
 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 IImage CreateImage(Color[] colors, int width, double scale = 1.0)
 {
     var pixelWidth = width;
       var pixelHeight = colors.Length/width;
       var format = PixelFormat.Format32bppArgb;
       Bitmap bitmap;
       unsafe
       {
     fixed (Color* c = colors)
     {
       bitmap = new Bitmap(pixelWidth, pixelHeight, pixelWidth*4, format, new IntPtr(c));
     }
       }
       return new ImageImage(bitmap);
 }
Example #6
0
 public Pen WithColor(Color color)
 {
     return new Pen(color, Width);
 }
Example #7
0
 public IImage CreateImage(Color[] colors, int width, double scale = 1.0)
 {
     return new NullImage();
 }