/// <inheritdoc /> public void DrawGeometry(IBrush brush, IPen pen, IGeometryImpl geometry) { var impl = (GeometryImpl)geometry; var size = geometry.Bounds.Size; using (var fill = brush != null ? CreatePaint(_fillPaint, brush, size) : default(PaintWrapper)) using (var stroke = pen?.Brush != null ? CreatePaint(_strokePaint, pen, size) : default(PaintWrapper)) { if (fill.Paint != null) { Canvas.DrawPath(impl.EffectivePath, fill.Paint); } if (stroke.Paint != null) { Canvas.DrawPath(impl.EffectivePath, stroke.Paint); } } }
/// <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, IGeometryImpl geometry) { var impl = geometry 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(); } } }
public bool TryGetSegment(double startDistance, double stopDistance, bool startOnBeginFigure, out IGeometryImpl segmentGeometry) { if (EffectivePath is null) { segmentGeometry = null; return(false); } segmentGeometry = null; var _skPathSegment = new SKPath(); var res = CachedPathMeasure.GetSegment((float)startDistance, (float)stopDistance, _skPathSegment, startOnBeginFigure); if (res) { segmentGeometry = new StreamGeometryImpl(_skPathSegment); } return(res); }
private void TransformChanged(object sender, EventArgs e) { var transform = ((Transform)sender)?.Value; if (_platformImpl is ITransformedGeometryImpl t) { if (transform == null || transform == Matrix.Identity) { _platformImpl = t.SourceGeometry; } else if (transform != t.Transform) { _platformImpl = t.SourceGeometry.WithTransform(transform.Value); } } else if (_platformImpl != null && transform != null && transform != Matrix.Identity) { _platformImpl = PlatformImpl.WithTransform(transform.Value); } Changed?.Invoke(this, EventArgs.Empty); }
private static IGeometryImpl CreateLayerGeometryClip(VisualNode node) { IGeometryImpl result = null; for (;;) { node = (VisualNode)node.Parent; if (node == null || (node.GeometryClip == null && !node.HasAncestorGeometryClip)) { break; } if (node?.GeometryClip != null) { var transformed = node.GeometryClip.WithTransform(node.Transform); result = result == null ? transformed : result.Intersect(transformed); } } return(result); }
/// <inheritdoc /> public IGeometryImpl Intersect(IGeometryImpl geometry) { var result = EffectivePath.Op(((GeometryImpl)geometry).EffectivePath, SKPathOp.Intersect); return(result == null ? null : new StreamGeometryImpl(result)); }
public abstract IGeometryImpl Intersect(IGeometryImpl geometry);
/// <inheritdoc /> public void PushGeometryClip(IGeometryImpl clip) { Canvas.Save(); Canvas.ClipPath(((GeometryImpl)clip).EffectivePath, SKClipOperation.Intersect, true); }
public void PushGeometryClip(IGeometryImpl clip) { }
/// <summary> /// Initializes a new instance of the <see cref="GeometryClipNode"/> class that represents a /// geometry clip push. /// </summary> /// <param name="transform">The current transform.</param> /// <param name="clip">The clip to push.</param> public GeometryClipNode(Matrix transform, IGeometryImpl clip) { Transform = transform; Clip = clip; }
public bool TryGetSegment(double startDistance, double stopDistance, bool startOnBeginFigure, out IGeometryImpl segmentGeometry) { throw new NotImplementedException(); }
public bool TryGetSegment(double startDistance, double stopDistance, bool startOnBeginFigure, out IGeometryImpl segmentGeometry) { segmentGeometry = null; return(false); }
public IGeometryImpl Intersect(IGeometryImpl geometry) { return(new MockStreamGeometryImpl(Transform)); }
/// <inheritdoc /> public void PushGeometryClip(IGeometryImpl clip) { Canvas.Save(); Canvas.ClipPath(((GeometryImpl)clip).EffectivePath); }
public void PushGeometryClip(IGeometryImpl clip) { _context.Save(); _context.AppendPath(((StreamGeometryImpl)clip).Path); _context.Clip(); }
/// <summary> /// Determines if this draw operation equals another. /// </summary> /// <param name="transform">The transform of the other draw operation.</param> /// <param name="clip">The clip of the other draw operation.</param> /// <returns>True if the draw operations are the same, otherwise false.</returns> /// <remarks> /// The properties of the other draw operation are passed in as arguments to prevent /// allocation of a not-yet-constructed draw operation object. /// </remarks> public bool Equals(Matrix transform, IGeometryImpl clip) => Transform == transform && Clip == clip;
private StreamGeometry(IGeometryImpl impl) { this.PlatformImpl = impl; }
public bool TryGetSegment(double startDistance, double stopDistance, bool startOnBeginFigure, out IGeometryImpl segmentGeometry) { // Direct2D doesnt have this too sadly. Logger.TryGet(LogEventLevel.Warning, LogArea.Visual)?.Log(this, "TryGetSegment is not available in Direct2D."); segmentGeometry = null; return(false); }
/// <summary> /// Invalidates the platform implementation of the geometry. /// </summary> protected void InvalidateGeometry() { _isDirty = true; _platformImpl = null; Changed?.Invoke(this, EventArgs.Empty); }
public IGeometryImpl Intersect(IGeometryImpl geometry) { throw new NotImplementedException(); }
/// <summary> /// Initializes a new instance of the <see cref="StreamGeometry"/> class. /// </summary> /// <param name="impl">The platform-specific implementation.</param> private StreamGeometry(IGeometryImpl impl) { PlatformImpl = impl; }
public IGeometryImpl Intersect(IGeometryImpl geometry) => new HeadlessGeometryStub(geometry.Bounds.Intersect(Bounds));
/// <summary> /// Initializes a new instance of the <see cref="GeometryClipNode"/> class that represents a /// geometry clip push. /// </summary> /// <param name="clip">The clip to push.</param> public GeometryClipNode(IGeometryImpl clip) { Clip = clip; }
public HeadlessTransformedGeometryStub(IGeometryImpl b, Matrix transform) : this(Fix(b, transform)) { }
/// <summary> /// Determines if this draw operation equals another. /// </summary> /// <param name="clip">The clip of the other draw operation.</param> /// <returns>True if the draw operations are the same, otherwise false.</returns> /// <remarks> /// The properties of the other draw operation are passed in as arguments to prevent /// allocation of a not-yet-constructed draw operation object. /// </remarks> public bool Equals(IGeometryImpl clip) => Clip == clip;
public void DrawGeometry(IBrush brush, IPen pen, IGeometryImpl geometry) { }
public PlatformGeometry(IGeometryImpl geometryImpl) { _geometryImpl = geometryImpl; }