Пример #1
0
        public static sd.Geometry ToGeometry(this IGraphicsPath path)
        {
            var handler = path.ToHandler();

            handler.CloseSink();
            return(handler.Control);
        }
Пример #2
0
        /// <summary>
        ///     Draws this object to the <see cref="T:EscherTiler.Graphics.IGraphics" /> provided.
        /// </summary>
        /// <param name="graphics">The graphics object to use to draw this object.</param>
        public override void Draw(IGraphics graphics)
        {
            if (_resourceManager == null)
            {
                throw new ObjectDisposedException(nameof(ShapeController));
            }

            graphics.ResourceManager = _resourceManager;

            foreach (Shape shape in Shapes)
            {
                using (IGraphicsPath path = graphics.CreatePath())
                {
                    bool first = true;
                    foreach (Vertex vertex in shape.Vertices)
                    {
                        if (first)
                        {
                            path.Start(vertex.Location);
                        }
                        else
                        {
                            path.AddLine(vertex.Location);
                        }
                        first = false;
                    }

                    path.End();

                    graphics.DrawPath(path);
                }
            }
        }
Пример #3
0
 public void FillPath(IBrushCollection brushCollection, IGraphicsPath path)
 {
     foreach (var brush in brushCollection.Brushes)
     {
         _canvas?.DrawPath((SKPath)path.EngineElement, GetSKPaint(brush));
     }
 }
Пример #4
0
        public void FillPath(IDisplay display, IGraphicsPath path)
        {
            if (_outlineSymbol == null || this.OutlineColor.IsTransparent)
            {
                display.Canvas.SmoothingMode = (SmoothingMode)this.SmoothingMode;
            }

            if (!_color.IsTransparent)
            {
                display.Canvas.FillPath(_brush, path);
            }

            display.Canvas.SmoothingMode = GraphicsEngine.SmoothingMode.None;

            //if (_outlineSymbol != null)
            //{
            //    if (_outlineSymbol is ILineSymbol)
            //    {
            //        ((ILineSymbol)_outlineSymbol).DrawPath(display, path);
            //    }
            //    else if (_outlineSymbol is SymbolCollection)
            //    {
            //        foreach (SymbolCollectionItem item in ((SymbolCollection)_outlineSymbol).Symbols)
            //        {
            //            if (!item.Visible) continue;
            //            if (item.Symbol is ILineSymbol)
            //            {
            //                ((ILineSymbol)item.Symbol).DrawPath(display, path);
            //            }
            //        }
            //    }
            //}
        }
Пример #5
0
 public void FillPath(Brush brush, IGraphicsPath path)
 {
     SaveTransform();
     TranslateTransform(-fillOffset, -fillOffset);
     Control.FillGeometry(path.ToGeometry(), brush.ToDx(Control));
     RestoreTransform();
 }
Пример #6
0
        public override void AddToPath(IGraphicsPath graphicsPath)
        {
            var pathData = graphicsPath.PathData;
            var points   = pathData.Points;

            if (points.Length <= 0)
            {
                return;
            }

            // Important for custom line caps. Force the path the close with an explicit line, not just an implicit close of the figure.
            var last = points.Length - 1;

            if (!points[0].Equals(points[last]))
            {
                var i = last;
                while (i > 0 && pathData.Types[i] > 0)
                {
                    --i;
                }
                graphicsPath.AddLine(points[last], points[i]);
            }

            graphicsPath.CloseFigure();
        }
Пример #7
0
 public void SetClip(IGraphicsPath path)
 {
     ResetClip();
     clipPath   = path;
     clipBounds = path.Bounds;
     ApplyClip();
 }
Пример #8
0
        XmlElement DrawPathElement(IPen pen, IBrush brush, IGraphicsPath path)
        {
            var element = Dom.CreateElement("path");

            element.SetAttribute("d", ((SvgGraphicsPath)path).Render(element));

            if (brush is SvgBrush)
            {
                element.SetAttribute("fill", ((SvgBrush)brush).Render(element));
            }
            else
            {
                element.SetAttribute("fill", "none");
            }

            if (pen is SvgPen)
            {
                element.SetAttribute("stroke", ((SvgPen)pen).Render(element));
            }
            else
            {
                element.SetAttribute("stroke", "none");
            }

            AppendElement(element);
            return(element);
        }
Пример #9
0
        public void DrawPath(Pen pen, IGraphicsPath path)
        {
            SetOffset(false);
            var pd = pen.ToPenData();

            Control.DrawGeometry(path.ToGeometry(), pd.GetBrush(Control), pd.Width, pd.StrokeStyle);
        }
Пример #10
0
 public void SetClip(RectangleF rectangle)
 {
     ResetClip();
     clipBounds = rectangle;
     clipPath   = null;
     ApplyClip();
 }
Пример #11
0
 public void SetClip(IGraphicsPath path)
 {
     // NOTE: This may not work with hardware acceleration.
     // See http://developer.android.com/guide/topics/graphics/hardware-accel.html#drawing-support
     // See http://stackoverflow.com/questions/16889815/canvas-clippath-only-works-on-android-emulator
     Control.ClipPath(path.ToAndroid(), ag.Region.Op.Replace);
 }
Пример #12
0
 public void SetClip(IGraphicsPath path)
 {
     ResetClip();
     clipPath   = path.Clone();           // require a clone so changes to path don't affect current clip
     clipBounds = clipPath.ToWpf().Bounds.ToEtoF();
     ApplyClip();
 }
Пример #13
0
        public void FillPath(IDisplay display, IGraphicsPath path)
        {
            //display.GraphicsContext.SmoothingMode = (SmoothingMode)this.Smoothingmode;

            if (_gradient != null)
            {
                CanvasRectangleF rect =
                    (_rectType == GradientRectType.Feature ?
                     path.GetBounds() :
                     new CanvasRectangleF(0, 0, display.iWidth, display.iHeight));

                using (var brush = _gradient.CreateNewLinearGradientBrush(rect))
                {
                    display.Canvas.FillPath(brush, path);
                }
            }
            //if (_outlineSymbol != null)
            //{
            //    if (_outlineSymbol is ILineSymbol)
            //        ((ILineSymbol)_outlineSymbol).DrawPath(display, path);
            //    else if (_outlineSymbol is SymbolCollection)
            //    {
            //        foreach (SymbolCollectionItem item in ((SymbolCollection)_outlineSymbol).Symbols)
            //        {
            //            if (!item.Visible) continue;
            //            if (item.Symbol is ILineSymbol)
            //            {
            //                ((ILineSymbol)item.Symbol).DrawPath(display, path);
            //            }
            //        }
            //    }
            //}
        }
Пример #14
0
 public void AddPath(IGraphicsPath path, bool connect = false)
 {
     if (path != null && !path.IsEmpty)             // avoid throwing an exception if the path is empty - consistent across platforms.
     {
         Control.AddPath(path.ToSD(), connect);
     }
 }
Пример #15
0
 public void DrawPath(Pen pen, IGraphicsPath path)
 {
     SetOffset(false);
     Control.Save();
     path.Apply(Control);
     pen.Apply(this);
     Control.Restore();
 }
 public void ResetClip()
 {
     RewindTransform();
     RewindClip();
     clipBounds = null;
     clipPath   = null;
     ApplyTransform();
 }
Пример #17
0
        public void FillPath(Brush brush, IGraphicsPath path)
        {
            var old = Control.PixelOffsetMode;

            Control.PixelOffsetMode = old == sdd.PixelOffsetMode.Half ? sdd.PixelOffsetMode.None : sdd.PixelOffsetMode.Half;
            Control.FillPath(brush.ToSD(), path.ToSD());
            Control.PixelOffsetMode = old;
        }
Пример #18
0
 public void DrawPath(Pen pen, IGraphicsPath path)
 {
     Control.Save();
     Control.Translate(offset, offset);
     path.Apply(Control);
     Control.Restore();
     pen.Apply(this);
 }
Пример #19
0
        public void FillPath(IBrushCollection brushCollection, IGraphicsPath path)
        {
            CheckUsability();

            foreach (var brush in brushCollection.Brushes)
            {
                _graphics.FillPath((Brush)brush.EngineElement, (System.Drawing.Drawing2D.GraphicsPath)path.EngineElement);
            }
        }
Пример #20
0
 public void SetClip(IGraphicsPath path)
 {
     TransformStack.PopAll();
     ResetClip();
     clipPath   = path.Clone().ToWpf();           // require a clone so changes to path don't affect current clip
     clipBounds = clipPath.Bounds.ToEtoF();
     ApplyClip();
     TransformStack.PushAll();
 }
Пример #21
0
 public void SetClip(RectangleF rectangle)
 {
     ReverseTransform();
     ResetClip();
     clipBounds = currentTransform.ToEto().TransformRectangle(rectangle);
     clipPath   = null;
     ApplyClip();
     ApplyTransform();
 }
Пример #22
0
        public static void FillPath(this IGraphics graphics, IBrush brush, IGraphicsPath path)
        {
            if (graphics == null)
            {
                throw new NullReferenceException();
            }

            graphics.DrawPath(null, brush, path);
        }
Пример #23
0
        public static void DrawPath(this IGraphics graphics, IPen pen, IGraphicsPath path)
        {
            if (graphics == null)
            {
                throw new NullReferenceException();
            }

            graphics.DrawPath(pen, null, path);
        }
Пример #24
0
 public void DrawPath(IDisplay display, IGraphicsPath path)
 {
     if (path != null)
     {
         display.Canvas.SmoothingMode = (SmoothingMode)this.Smoothingmode;
         display.Canvas.DrawPath(_pen, path);
         display.Canvas.SmoothingMode = SmoothingMode.None;
     }
 }
Пример #25
0
 public void ResetClip()
 {
     if (clipBounds != null)
     {
         Control.Pop();
         clipBounds = null;
         clipPath   = null;
     }
 }
Пример #26
0
 public void FillPath(Brush brush, IGraphicsPath path)
 {
     SetOffset(true);
     Control.Save();
     path.Apply(Control);
     Control.FillRule = path.FillMode.ToCairo();
     brush.Apply(this);
     Control.Restore();
 }
 public void SetClip(RectangleF rectangle)
 {
     RewindTransform();
     RewindClip();
     clipPath   = null;
     clipBounds = currentTransform.TransformRect(rectangle.ToNS());
     ApplyClip();
     ApplyTransform();
 }
Пример #28
0
        public void DrawPath(Pen pen, IGraphicsPath path)
        {
            var pd = pen.ToPenData();

            SaveTransform();
            TranslateTransform(offset, offset);
            Control.DrawGeometry(path.ToGeometry(), pd.GetBrush(Control), pd.Width, pd.StrokeStyle);
            RestoreTransform();
        }
 public void SetClip(IGraphicsPath path)
 {
     RewindTransform();
     RewindClip();
     clipBounds = null;
     clipPath   = path.Clone();
     clipPath.Transform(currentTransform.ToEto());
     ApplyClip();
     ApplyTransform();
 }
Пример #30
0
 public void SetClip(IGraphicsPath path)
 {
     ReverseTransform();
     ResetClip();
     path = path.Clone();
     path.Transform(currentTransform.ToEto());
     clipPath   = path;
     clipBounds = path.Bounds;
     ApplyClip();
     ApplyTransform();
 }
Пример #31
0
		/// <summary>
		/// Sets the clip region to the specified <paramref name="path"/>
		/// </summary>
		/// <remarks>
		/// The previous clipping region will be cleared after this call
		/// </remarks>
		/// <param name="path">Path to specify the clip region</param>
		public void SetClip (IGraphicsPath path)
		{
			Handler.SetClip (path);
		}
Пример #32
0
		public void AddPath (IGraphicsPath path, bool connect)
		{
			var handler = path.ToHandler ();
			Add (exec => {
				if (connect && !handler.firstFigureClosed) {
					exec.ForceConnect = true;
					handler.Connect (exec);
				} else
					handler.Apply (exec.Context);
			}, handler.Points.ToArray ());
		}
Пример #33
0
		public void AddPath (IGraphicsPath path, bool connect = false)
		{
			if (path.IsEmpty)
				return;

			var handler = path.ToHandler ();
			if (connect && handler.startPoint != null && !handler.firstFigureClosed) {
				var first = true;
				handler.Control.Apply (element => {
					switch (element.Type) {
					case CGPathElementType.AddCurveToPoint:
						if (first)
							ConnectTo (element.Point3.ToEto());
						this.AddCurveToPoint(element.Point1.ToEto(), element.Point2.ToEto(), element.Point3.ToEto());
						break;
					case CGPathElementType.AddLineToPoint:
						if (first)
							ConnectTo (element.Point1.ToEto());
						Control.AddLineToPoint(element.Point1);
						break;
					case CGPathElementType.AddQuadCurveToPoint:
						if (first)
							ConnectTo (element.Point2.ToEto());
						Control.AddQuadCurveToPoint (element.Point1.X, element.Point1.Y, element.Point2.X, element.Point2.Y);
						break;
					case CGPathElementType.CloseSubpath:
						Control.CloseSubpath ();
						break;
					case CGPathElementType.MoveToPoint:
						if (first)
							ConnectTo (element.Point1.ToEto());
						else
							Control.MoveToPoint (element.Point1);
						break;
					}
					first = false;
				});
			}
			else {
				Control.AddPath(handler.Control);
			}
			startFigure = handler.startFigure;
		}
Пример #34
0
		public void FillPath(Brush brush, IGraphicsPath path)
		{
			StartDrawing();

			Control.TranslateCTM(inverseoffset, inverseoffset);
			Control.BeginPath();
			Control.AddPath(path.ToCG());
			Control.ClosePath();
			brush.Apply(this);
			switch (path.FillMode)
			{
				case FillMode.Alternate:
					Control.EOFillPath();
					break;
				case FillMode.Winding:
					Control.FillPath();
					break;
				default:
					throw new NotSupportedException();
			}
			EndDrawing();
		}
Пример #35
0
		public void ResetClip()
		{
			RewindClip();
			clipBounds = null;
			clipPath = null;
		}
Пример #36
0
		public GraphicsPath (Generator g)
			: base(g, typeof(IGraphicsPath))
		{
			inner = (IGraphicsPath)Handler;
		}
Пример #37
0
		public void SetClip(RectangleF rectangle)
		{
			RewindTransform();
			RewindClip();
			clipPath = null;
			clipBounds = currentTransform.TransformRect(rectangle.ToNS());
			ApplyClip();
			ApplyTransform();
		}
Пример #38
0
		public void FillPath(Brush brush, IGraphicsPath path)
		{
			throw new NotImplementedException();
		}
Пример #39
0
		public void DrawPath(Pen pen, IGraphicsPath path)
		{
			throw new NotImplementedException();
		}
Пример #40
0
		public void SetClip(IGraphicsPath path)
		{
			throw new NotImplementedException();
		}
Пример #41
0
		/// <summary>
		/// Adds the specified <paramref name="path"/> to the current path, optionally connecting the current figure to the start of the path
		/// </summary>
		/// <remarks>
		/// The <paramref name="connect"/> parameter only specifies that the path should be connected to the current path
		/// at the beginning. The end of the specified path will always be connected to the next segment added to this path,
		/// unlesss <see cref="CloseFigure"/> or <see cref="StartFigure"/> are called after this.
		/// </remarks>
		/// <param name="path">Child path to add to this instance</param>
		/// <param name="connect">True to connect the current figure to the first figure of the specified path, if it is not closed</param>
		public void AddPath (IGraphicsPath path, bool connect = false)
		{
			Handler.AddPath (path, connect);
		}
Пример #42
0
 /// <summary>
 ///     Adds the line to the given <paramref name="path" /> after transforming it by the given
 ///     <paramref name="transform" />.
 /// </summary>
 /// <param name="path">The path to add the line to.</param>
 /// <param name="transform">The transform.</param>
 /// <param name="reverse">If set to <see langword="true" />, add the line from <see cref="Start" /> to <see cref="End" />.</param>
 public void AddToPath(IGraphicsPath path, Matrix3x2 transform, bool reverse)
 {
     path.AddQuadraticBezier(
         Vector2.Transform(ControlPoint, transform),
         Vector2.Transform(reverse ? Start : End, transform));
 }
Пример #43
0
		public void SetClip(IGraphicsPath path)
		{
			RewindTransform();
			RewindClip();
			clipBounds = null;
			clipPath = path.Clone();
			clipPath.Transform(currentTransform.ToEto());
			ApplyClip();
			ApplyTransform();
		}
Пример #44
0
		/// <summary>
		/// Fills the specified <paramref name="path"/>
		/// </summary>
		/// <param name="color">Fill color</param>
		/// <param name="path">Path to fill</param>
		public void FillPath (Color color, IGraphicsPath path)
		{
			using (var brush = new SolidBrush(color))
				Handler.FillPath (brush, path);
		}
Пример #45
0
        /// <summary>
        ///     Adds the line to the given <paramref name="path" /> after transforming it by the given
        ///     <paramref name="transform" />.
        /// </summary>
        /// <param name="path">The path to add the line to.</param>
        /// <param name="transform">The transform.</param>
        public void AddToPath(IGraphicsPath path, Matrix3x2 transform)
        {
            Vector2 zero = Vector2.Transform(Vector2.Zero, transform);
            Vector2 rad = Vector2.Transform(Radius, transform);
            rad = Radius * (Vector2.Distance(zero, rad) / Radius.Length());

            Vector2 angVec = Vector2.Transform(new Vector2(0, 1), Matrix3x2.CreateRotation(Angle) * transform);
            float ang = AngleBetween(new Vector2(0, 1), angVec - zero);

            path.AddArc(
                Vector2.Transform(End, transform),
                rad,
                ang,
                Clockwise /* TODO probably need to work this out somehow */,
                IsLarge);
        }
Пример #46
0
		public void DrawPath(Pen pen, IGraphicsPath path)
		{
			SetOffset(false);
			StartDrawing();
			
			pen.Apply(this);
			Control.BeginPath();
			Control.AddPath(path.ToCG());
			Control.StrokePath();
			
			EndDrawing();
		}
Пример #47
0
		public void AddPath(IGraphicsPath path, bool connect)
		{
			var inputGeometry = path.ToHandler();
			if (connect)
			{
				// TODO: how do we attach to the existing sink?  throws an exception otherwise
				StartFigure();
				inputGeometry.Control.Simplify(sd.GeometrySimplificationOption.CubicsAndLines, Sink);
			}
			else
			{
				CloseSink();
				geometries.Add(inputGeometry.Control);
			}
			control = null;
		}
Пример #48
0
		public void ResetClip()
		{
			RewindTransform();
			RewindClip();
			clipBounds = null;
			clipPath = null;
			ApplyTransform();
		}
Пример #49
0
		/// <summary>
		/// Fills the specified <paramref name="path"/>
		/// </summary>
		/// <param name="brush">Brush to fill the path</param>
		/// <param name="path">Path to fill</param>
		public void FillPath (Brush brush, IGraphicsPath path)
		{
			Handler.FillPath (brush, path);
		}
Пример #50
0
		/// <summary>
		/// Draws a 1 pixel outline of the specified <paramref name="path"/>
		/// </summary>
		/// <param name="color">Draw color</param>
		/// <param name="path">Path to draw</param>
		public void DrawPath (Color color, IGraphicsPath path)
		{
			using (var pen = new Pen(color))
				Handler.DrawPath (pen, path);
		}
Пример #51
0
		public void AddPath (IGraphicsPath path, bool connect = false)
		{
			if (path != null && !path.IsEmpty) // avoid throwing an exception if the path is empty - consistent across platforms.
				Control.AddPath(path.ToSD(), connect);
		}
Пример #52
0
		public void FillPath(Brush brush, IGraphicsPath path)
		{
			SetOffset(true);
			StartDrawing();

			Control.BeginPath();
			Control.AddPath(path.ToCG());
			Control.ClosePath();
			switch (path.FillMode)
			{
				case FillMode.Alternate:
					Control.EOClip();
					break;
				case FillMode.Winding:
					Control.Clip();
					break;
				default:
					throw new NotSupportedException();
			}
			brush.Draw(this, path.Bounds);
			EndDrawing();
		}
Пример #53
0
		/// <summary>
		/// Draws the specified <paramref name="path"/>
		/// </summary>
		/// <param name="pen">Pen to outline the path</param>
		/// <param name="path">Path to draw</param>
		public void DrawPath (Pen pen, IGraphicsPath path)
		{
			Handler.DrawPath (pen, path);
		}
Пример #54
0
		public void SetClip(IGraphicsPath path)
		{
			ResetClip();
			clipPath = path.Clone();
			ReplayClip();
		}
Пример #55
0
		public void AddPath(IGraphicsPath path, bool connect)
		{
			throw new NotImplementedException();
		}
Пример #56
0
		public void DrawPath(Pen pen, IGraphicsPath path)
		{
			StartDrawing();
			
			Control.TranslateCTM(offset, offset);
			pen.Apply(this);
			Control.BeginPath();
			Control.AddPath(path.ToCG());
			Control.StrokePath();
			
			EndDrawing();
		}
Пример #57
0
		/// <summary>
		/// Initializes a new instance of the <see cref="Eto.Drawing.GraphicsPath"/> class.
		/// </summary>
		/// <param name="handler">Handler for the graphics path</param>
		public GraphicsPath (IGraphicsPath handler)
		{
			Handler = handler;
		}
Пример #58
0
		public void AddPath (IGraphicsPath path, bool connect = false)
		{
			if (path.IsEmpty)
				return;

			var wpfPath = path.ToWpf ();
			if (!wpfPath.Transform.Value.IsIdentity) {
				var newpath = new swm.PathGeometry ();
				newpath.AddGeometry (wpfPath);
				wpfPath = newpath;
			}
			var en = wpfPath.Figures.GetEnumerator ();
			if (connect) {
				// merge current figure (if any) and first figure of new path, if they are not closed paths
				if (figure != null && !figure.IsClosed && en.MoveNext ()) {
					var firstFigure = en.Current;
					if (!firstFigure.IsClosed) {
						figure.Segments.Add (new swm.LineSegment (firstFigure.StartPoint, true));
						foreach (var seg in firstFigure.Segments)
							figure.Segments.Add (seg);
					} else {
						Control.Figures.Add (firstFigure);
					}
				}
			}
			swm.PathFigure pathFigure = null;
			while (en.MoveNext ()) {
				pathFigure = en.Current;
				Control.Figures.Add (pathFigure);
			}
			
			// continue with last figure of new path if not closed
			if (pathFigure != null && !pathFigure.IsClosed)
				figure = pathFigure;
			else
				figure = null;
		}
Пример #59
0
        /// <summary>
        ///     Draws a path.
        /// </summary>
        /// <param name="path">The path to draw.</param>
        public void DrawPath(IGraphicsPath path)
        {
            if (path == null) throw new ArgumentNullException(nameof(path));
            GraphicsPath gp = path as GraphicsPath;
            if (gp == null)
                throw new ArgumentException("The path must be a path returned by CreatePath", nameof(path));

            _graphics.DrawPath(LinePen, gp.PathGeometry);
        }
Пример #60
0
        /// <summary>
        ///     Fills the inside of a path.
        /// </summary>
        /// <param name="path">The path to fill.</param>
        public void FillPath(IGraphicsPath path)
        {
            if (path == null) throw new ArgumentNullException(nameof(path));
            GraphicsPath gp = path as GraphicsPath;
            if (gp == null)
                throw new ArgumentException("The path must be a path returned by CreatePath", nameof(path));

            _renderTarget.FillGeometry(gp.PathGeometry, FillBrush);
        }