/// <summary> /// Draws a geometry. /// </summary> /// <param name="brush">The fill brush.</param> /// <param name="pen">The stroke pen.</param> /// <param name="geometry">The geometry.</param> public void DrawGeometry(IBrush brush, Pen pen, Avalonia.Media.Geometry geometry) { if (brush != null) { using (var d2dBrush = CreateBrush(brush, geometry.Bounds.Size)) { if (d2dBrush.PlatformBrush != null) { var impl = (GeometryImpl)geometry.PlatformImpl; _renderTarget.FillGeometry(impl.Geometry, d2dBrush.PlatformBrush); } } } if (pen != null) { using (var d2dBrush = CreateBrush(pen.Brush, geometry.GetRenderBounds(pen.Thickness).Size)) using (var d2dStroke = pen.ToDirect2DStrokeStyle(_renderTarget)) { if (d2dBrush.PlatformBrush != null) { var impl = (GeometryImpl)geometry.PlatformImpl; _renderTarget.DrawGeometry(impl.Geometry, d2dBrush.PlatformBrush, (float)pen.Thickness, d2dStroke); } } } }
public override void UpdateGeometry() { ScaleThickness = Path.State.HasFlag(ShapeStateFlags.Thickness); ScaleSize = Path.State.HasFlag(ShapeStateFlags.Size); Geometry = PathGeometryConverter.ToGeometry(Path.Geometry); Center = Geometry.Bounds.Center; }
public override void UpdateGeometry() { ScaleThickness = QuadraticBezier.State.Flags.HasFlag(ShapeStateFlags.Thickness); ScaleSize = QuadraticBezier.State.Flags.HasFlag(ShapeStateFlags.Size); Geometry = PathGeometryConverter.ToGeometry(QuadraticBezier); Center = Geometry.Bounds.Center; }
/// <summary> /// Initializes a new instance of the <see cref="StreamGeometryImpl"/> class. /// </summary> public CombinedGeometryImpl( AM.GeometryCombineMode combineMode, AM.Geometry geometry1, AM.Geometry geometry2) : base(CreateGeometry(combineMode, geometry1, geometry2)) { }
public override void UpdateGeometry() { ScaleThickness = Ellipse.State.HasFlag(ShapeStateFlags.Thickness); ScaleSize = Ellipse.State.HasFlag(ShapeStateFlags.Size); Geometry = PathGeometryConverter.ToGeometry(Ellipse); Rect = Geometry.Bounds; Center = Geometry.Bounds.Center; }
private static Geometry CreateGeometry( AM.GeometryCombineMode combineMode, AM.Geometry geometry1, AM.Geometry geometry2) { var g1 = ((GeometryImpl)geometry1.PlatformImpl).Geometry; var g2 = ((GeometryImpl)geometry2.PlatformImpl).Geometry; var dest = new PathGeometry(Direct2D1Platform.Direct2D1Factory); using var sink = dest.Open(); g1.Combine(g2, (CombineMode)combineMode, sink); sink.Close(); return(dest); }
/// <summary> /// Push a geometry clip change info. /// </summary> /// <param name="clip"></param> public void PushGeometryClip(Avalonia.Media.Geometry clip) { var parameters = new LayerParameters { ContentBounds = PrimitiveExtensions.RectangleInfinite, MaskTransform = PrimitiveExtensions.Matrix3x2Identity, Opacity = 1, GeometricMask = ((GeometryImpl)clip.PlatformImpl).Geometry }; var layer = _layerPool.Count != 0 ? _layerPool.Pop() : new Layer(_renderTarget); _renderTarget.PushLayer(ref parameters, layer); _layers.Push(layer); }
public void DrawGeometry(IBrush brush, Pen pen, Geometry geometry) { var impl = ((StreamGeometryImpl)geometry.PlatformImpl); var size = geometry.Bounds.Size; using (var fill = brush != null ? CreatePaint(brush, size) : default(PaintWrapper)) using (var stroke = pen?.Brush != null ? CreatePaint(pen, size) : default(PaintWrapper)) { if (fill.Paint != null) { Canvas.DrawPath(impl.EffectivePath, fill.Paint); } if (stroke.Paint != null) { Canvas.DrawPath(impl.EffectivePath, stroke.Paint); } } }
public override void DrawGeometry(Brush brush, Pen pen, Geometry geometry) { Direct2D1StreamGeometry platformGeometry = (Direct2D1StreamGeometry)geometry.PlatformImpl; PathGeometry d2dGeometry = platformGeometry.Direct2DGeometry; if (brush != null) { this.target.FillGeometry(d2dGeometry, brush.ToSharpDX(this.target)); } if (pen != null) { this.target.DrawGeometry( d2dGeometry, pen.Brush.ToSharpDX(this.target), (float)pen.Thickness); } }
public override void DrawGeometry(Brush brush, Pen pen, Geometry geometry, Avalonia.Media.Matrix transform) { Direct2D1StreamGeometry platformGeometry = (Direct2D1StreamGeometry)geometry.PlatformImpl; using (TransformedGeometry d2dGeometry = new TransformedGeometry( this.factory, platformGeometry.Direct2DGeometry, transform.ToSharpDX())) { if (brush != null) { this.target.FillGeometry(d2dGeometry, brush.ToSharpDX(this.target)); } if (pen != null) { this.target.DrawGeometry( d2dGeometry, pen.Brush.ToSharpDX(this.target), (float)pen.Thickness); } } }
public abstract void DrawGeometry(Brush brush, Pen pen, Geometry geometry);
public void PushGeometryClip(Geometry clip) { Canvas.Save(); Canvas.ClipPath(((StreamGeometryImpl)clip.PlatformImpl).EffectivePath); }
public void PushGeometryClip(Geometry clip) { _context.Save(); _context.AppendPath(((StreamGeometryImpl)clip.PlatformImpl).Path); _context.Clip(); }
/// <summary> /// Draws a geometry. /// </summary> /// <param name="brush">The fill brush.</param> /// <param name="pen">The stroke pen.</param> /// <param name="geometry">The geometry.</param> public void DrawGeometry(IBrush brush, Pen pen, Geometry geometry) { var impl = geometry.PlatformImpl as StreamGeometryImpl; var oldMatrix = Transform; Transform = impl.Transform * Transform; if (brush != null) { _context.AppendPath(impl.Path); using (var b = SetBrush(brush, geometry.Bounds.Size)) { _context.FillRule = impl.FillRule == FillRule.EvenOdd ? Cairo.FillRule.EvenOdd : Cairo.FillRule.Winding; if (pen != null) _context.FillPreserve(); else _context.Fill(); } } Transform = oldMatrix; if (pen != null) { _context.AppendPath(impl.Path); using (var p = SetPen(pen, geometry.Bounds.Size)) { _context.Stroke(); } } }
/// <summary> /// Draws a geometry. /// </summary> /// <param name="brush">The fill brush.</param> /// <param name="pen">The stroke pen.</param> /// <param name="geometry">The geometry.</param> public void DrawGeometry(IBrush brush, Pen pen, Geometry geometry) => _impl.DrawGeometry(brush, pen, geometry);
/// <summary> /// Pushes a clip geometry. /// </summary> /// <param name="clip">The clip geometry.</param> /// <returns>A disposable used to undo the clip geometry.</returns> public PushedState PushGeometryClip(Geometry clip) { Contract.Requires<ArgumentNullException>(clip != null); _impl.PushGeometryClip(clip); return new PushedState(this, PushedState.PushedStateType.GeometryClip); }
public abstract void DrawGeometry(Brush brush, Pen pen, Geometry geometry, Matrix transform);
/// <summary> /// Pushes a clip geometry. /// </summary> /// <param name="clip">The clip geometry.</param> /// <returns>A disposable used to undo the clip geometry.</returns> public PushedState PushGeometryClip(Geometry clip) { Contract.Requires <ArgumentNullException>(clip != null); PlatformImpl.PushGeometryClip(clip.PlatformImpl); return(new PushedState(this, PushedState.PushedStateType.GeometryClip)); }