예제 #1
0
        /// <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);
                    }
                }
        }
예제 #2
0
        /// <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();
                }
            }
        }
예제 #3
0
        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);
        }
예제 #4
0
        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);
        }
예제 #5
0
        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);
        }
예제 #6
0
        /// <inheritdoc />
        public IGeometryImpl Intersect(IGeometryImpl geometry)
        {
            var result = EffectivePath.Op(((GeometryImpl)geometry).EffectivePath, SKPathOp.Intersect);

            return(result == null ? null : new StreamGeometryImpl(result));
        }
예제 #7
0
 public abstract IGeometryImpl Intersect(IGeometryImpl geometry);
예제 #8
0
 /// <inheritdoc />
 public void PushGeometryClip(IGeometryImpl clip)
 {
     Canvas.Save();
     Canvas.ClipPath(((GeometryImpl)clip).EffectivePath, SKClipOperation.Intersect, true);
 }
 public void PushGeometryClip(IGeometryImpl clip)
 {
 }
예제 #10
0
 /// <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;
 }
예제 #11
0
 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);
 }
예제 #13
0
 public IGeometryImpl Intersect(IGeometryImpl geometry)
 {
     return(new MockStreamGeometryImpl(Transform));
 }
예제 #14
0
 /// <inheritdoc />
 public void PushGeometryClip(IGeometryImpl clip)
 {
     Canvas.Save();
     Canvas.ClipPath(((GeometryImpl)clip).EffectivePath);
 }
예제 #15
0
 public void PushGeometryClip(IGeometryImpl clip)
 {
     _context.Save();
     _context.AppendPath(((StreamGeometryImpl)clip).Path);
     _context.Clip();
 }
예제 #16
0
 /// <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;
예제 #17
0
 private StreamGeometry(IGeometryImpl impl)
 {
     this.PlatformImpl = impl;
 }
예제 #18
0
        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);
        }
예제 #19
0
 /// <summary>
 /// Invalidates the platform implementation of the geometry.
 /// </summary>
 protected void InvalidateGeometry()
 {
     _isDirty      = true;
     _platformImpl = null;
     Changed?.Invoke(this, EventArgs.Empty);
 }
예제 #20
0
 public IGeometryImpl Intersect(IGeometryImpl geometry)
 {
     throw new NotImplementedException();
 }
예제 #21
0
 /// <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));
예제 #23
0
 /// <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))
 {
 }
예제 #25
0
 /// <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)
 {
 }
예제 #27
0
 public PlatformGeometry(IGeometryImpl geometryImpl)
 {
     _geometryImpl = geometryImpl;
 }