コード例 #1
0
		public async Task Icon ()
		{
			var size = new Size (64);
			var canvas = Platforms.Current.CreateImageCanvas (size, scale: 2);
			canvas.SaveState ();
			canvas.Scale (size);
			canvas.Translate (1 / 8.0, 0);

			var p = new Path ();
			p.MoveTo (0, 1,false);
			p.LineTo (0, 0, false);
			p.LineTo (0.5, 1, false);
			p.LineTo (0.5, 0,false);

			var colors = new [] {
				"#DCDCDD",
				"#C5C3C6",
				"#46494C",
				"#4C5C68",
				"#68A5E2",
			};
			foreach (var c in colors) {
				p.Pen = new Pen (c, 1 / 4.0);
				p.Draw (canvas);
				canvas.Translate (1 / 16.0, 0);
			}
      await SaveImage (canvas, "Icon.png");
		}
コード例 #2
0
ファイル: Drawing.cs プロジェクト: JoshuaNovak919/NGraphics
 public Drawing(Size size, DrawingFunc func)
 {
     if (func == null)
     {
         throw new ArgumentNullException("func");
     }
     this.size = size;
     this.func = func;
 }
コード例 #3
0
 public IImageCanvas CreateImageCanvas(Size size, double scale = 1.0, bool transparency = true)
 {
     var pixelWidth = (int) Math.Ceiling(size.Width*scale);
       var pixelHeight = (int) Math.Ceiling(size.Height*scale);
       var bitmap = Bitmap.CreateBitmap(pixelWidth, pixelHeight, Bitmap.Config.Argb8888);
       if (!transparency)
       {
     bitmap.EraseColor(Colors.Black.Argb);
       }
       return new BitmapCanvas(bitmap, scale);
 }
コード例 #4
0
 public WICBitmapCanvas(WIC.Bitmap bmp, D2D1.RenderTargetProperties properties, Direct2DFactories factories = null)
     : base(new D2D1.WicRenderTarget ((factories ?? Direct2DFactories.Shared).D2DFactory, bmp, properties), factories)
 {
     this.Bmp = bmp;
     this.scale = properties.DpiX / 96.0;
     var bmpSize = bmp.Size;
     this.size = new Size (bmpSize.Width / scale, bmpSize.Height / scale);
 }
コード例 #5
0
        public WICBitmapCanvas(Size size, double scale = 1.0, bool transparency = true, Direct2DFactories factories = null)
            : this(// DIPs = pixels / (DPI/96.0)
				new WIC.Bitmap ((factories ?? Direct2DFactories.Shared).WICFactory, (int)(Math.Ceiling (size.Width * scale)), (int)(Math.Ceiling (size.Height * scale)), transparency ? WIC.PixelFormat.Format32bppPBGRA : WIC.PixelFormat.Format32bppBGR, WIC.BitmapCreateCacheOption.CacheOnLoad),
				new D2D1.RenderTargetProperties (D2D1.RenderTargetType.Default, new D2D1.PixelFormat (DXGI.Format.Unknown, D2D1.AlphaMode.Unknown), (float)(96.0 * scale), (float)(96.0 * scale), D2D1.RenderTargetUsage.None, D2D1.FeatureLevel.Level_DEFAULT))
        {
        }
コード例 #6
0
 public void DrawImage(IImage image, Rect frame, double alpha = 1.0)
 {
     var ii = image as BitmapImage;
       if (ii != null)
       {
     var paint = GetImagePaint(alpha);
     var isize = new Size(ii.Bitmap.Width, ii.Bitmap.Height);
     var scale = frame.Size/isize;
     var m = new Matrix();
     m.PreTranslate((float) frame.X, (float) frame.Y);
     m.PreScale((float) scale.Width, (float) scale.Height);
     graphics.DrawBitmap(ii.Bitmap, m, paint);
       }
 }
コード例 #7
0
 public IImageCanvas CreateImageCanvas(Size size, double scale = 1.0, bool transparency = true)
 {
     var pixelWidth = (int) Math.Ceiling(size.Width*scale);
       var pixelHeight = (int) Math.Ceiling(size.Height*scale);
       var format = transparency ? PixelFormat.Format32bppPArgb : PixelFormat.Format24bppRgb;
       var bitmap = new Bitmap(pixelWidth, pixelHeight, format);
       return new BitmapCanvas(bitmap, scale);
 }
コード例 #8
0
ファイル: SvgReader.cs プロジェクト: JoshuaNovak919/NGraphics
        private void Read(XDocument doc)
        {
            var svg = doc.Root;
              var ns = svg.Name.Namespace;

              //
              // Find the defs (gradients)
              //
              foreach (var d in svg.Descendants())
              {
            var idA = d.Attribute("id");
            if (idA != null)
            {
              defs[ReadString(idA).Trim()] = d;
            }
              }

              //
              // Get the dimensions
              //
              var widthA = svg.Attribute("width");
              var heightA = svg.Attribute("height");
              var width = _valuesParser.ReadNumber(widthA);
              var height = _valuesParser.ReadNumber(heightA);
              var size = new Size(width, height);

              var viewBox = new Rect(size);
              var viewBoxA = svg.Attribute("viewBox") ?? svg.Attribute("viewPort");
              if (viewBoxA != null)
              {
            viewBox = ReadRectangle(viewBoxA.Value);
              }

              if (widthA != null && widthA.Value.Contains("%"))
              {
            size.Width *= viewBox.Width;
              }
              if (heightA != null && heightA.Value.Contains("%"))
              {
            size.Height *= viewBox.Height;
              }

              //
              // Add the elements
              //
              Graphic = new Graphic(size, viewBox);

              AddElements(Graphic.Children, svg.Elements(), null, null);
        }
コード例 #9
0
ファイル: Rect.cs プロジェクト: JoshuaNovak919/NGraphics
 public void Inflate(Size padding)
 {
     Inflate(padding.Width, padding.Height);
 }
コード例 #10
0
ファイル: Rect.cs プロジェクト: JoshuaNovak919/NGraphics
 public Rect(Size size)
     : this(0, 0, size.Width, size.Height)
 {
 }
コード例 #11
0
ファイル: Rect.cs プロジェクト: JoshuaNovak919/NGraphics
 public Rect(Point position, Size size)
     : this(position.X, position.Y, size.Width, size.Height)
 {
 }
コード例 #12
0
 public IImageCanvas CreateImageCanvas(Size size, double scale = 1.0, bool transparency = true)
 {
     return new NullImageSurface();
 }