public static sd.Geometry ToGeometry(this IGraphicsPath path) { var handler = path.ToHandler(); handler.CloseSink(); return(handler.Control); }
/// <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); } } }
public void FillPath(IBrushCollection brushCollection, IGraphicsPath path) { foreach (var brush in brushCollection.Brushes) { _canvas?.DrawPath((SKPath)path.EngineElement, GetSKPaint(brush)); } }
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); // } // } // } //} }
public void FillPath(Brush brush, IGraphicsPath path) { SaveTransform(); TranslateTransform(-fillOffset, -fillOffset); Control.FillGeometry(path.ToGeometry(), brush.ToDx(Control)); RestoreTransform(); }
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(); }
public void SetClip(IGraphicsPath path) { ResetClip(); clipPath = path; clipBounds = path.Bounds; ApplyClip(); }
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); }
public void DrawPath(Pen pen, IGraphicsPath path) { SetOffset(false); var pd = pen.ToPenData(); Control.DrawGeometry(path.ToGeometry(), pd.GetBrush(Control), pd.Width, pd.StrokeStyle); }
public void SetClip(RectangleF rectangle) { ResetClip(); clipBounds = rectangle; clipPath = null; ApplyClip(); }
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); }
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(); }
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); // } // } // } //} }
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); } }
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(); }
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; }
public void DrawPath(Pen pen, IGraphicsPath path) { Control.Save(); Control.Translate(offset, offset); path.Apply(Control); Control.Restore(); pen.Apply(this); }
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); } }
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(); }
public void SetClip(RectangleF rectangle) { ReverseTransform(); ResetClip(); clipBounds = currentTransform.ToEto().TransformRectangle(rectangle); clipPath = null; ApplyClip(); ApplyTransform(); }
public static void FillPath(this IGraphics graphics, IBrush brush, IGraphicsPath path) { if (graphics == null) { throw new NullReferenceException(); } graphics.DrawPath(null, brush, path); }
public static void DrawPath(this IGraphics graphics, IPen pen, IGraphicsPath path) { if (graphics == null) { throw new NullReferenceException(); } graphics.DrawPath(pen, null, path); }
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; } }
public void ResetClip() { if (clipBounds != null) { Control.Pop(); clipBounds = null; clipPath = null; } }
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(); }
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(); }
public void SetClip(IGraphicsPath path) { ReverseTransform(); ResetClip(); path = path.Clone(); path.Transform(currentTransform.ToEto()); clipPath = path; clipBounds = path.Bounds; ApplyClip(); ApplyTransform(); }
/// <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); }
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 ()); }
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; }
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(); }
public void ResetClip() { RewindClip(); clipBounds = null; clipPath = null; }
public GraphicsPath (Generator g) : base(g, typeof(IGraphicsPath)) { inner = (IGraphicsPath)Handler; }
public void SetClip(RectangleF rectangle) { RewindTransform(); RewindClip(); clipPath = null; clipBounds = currentTransform.TransformRect(rectangle.ToNS()); ApplyClip(); ApplyTransform(); }
public void FillPath(Brush brush, IGraphicsPath path) { throw new NotImplementedException(); }
public void DrawPath(Pen pen, IGraphicsPath path) { throw new NotImplementedException(); }
public void SetClip(IGraphicsPath path) { throw new NotImplementedException(); }
/// <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); }
/// <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)); }
public void SetClip(IGraphicsPath path) { RewindTransform(); RewindClip(); clipBounds = null; clipPath = path.Clone(); clipPath.Transform(currentTransform.ToEto()); ApplyClip(); ApplyTransform(); }
/// <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); }
/// <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); }
public void DrawPath(Pen pen, IGraphicsPath path) { SetOffset(false); StartDrawing(); pen.Apply(this); Control.BeginPath(); Control.AddPath(path.ToCG()); Control.StrokePath(); EndDrawing(); }
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; }
public void ResetClip() { RewindTransform(); RewindClip(); clipBounds = null; clipPath = null; ApplyTransform(); }
/// <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); }
/// <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); }
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); }
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(); }
/// <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); }
public void SetClip(IGraphicsPath path) { ResetClip(); clipPath = path.Clone(); ReplayClip(); }
public void AddPath(IGraphicsPath path, bool connect) { throw new NotImplementedException(); }
public void DrawPath(Pen pen, IGraphicsPath path) { StartDrawing(); Control.TranslateCTM(offset, offset); pen.Apply(this); Control.BeginPath(); Control.AddPath(path.ToCG()); Control.StrokePath(); EndDrawing(); }
/// <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; }
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; }
/// <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); }
/// <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); }