StreamGeometry combine

后端 未结 2 1069
谎友^
谎友^ 2021-01-24 05:01

I have complex StreamGeometry and I want to clip it. Unfortunately, it looks like StreamGeometry doesn\'t supports combine.

Here is a

2条回答
  •  無奈伤痛
    2021-01-24 05:33

    Solution is simple: do not use StreamGeometry.

    To example, this will work (using PathGeometry instead):

    var clip = new RectangleGeometry(new Rect(50, 50, 10, 10));
    var geometry = new PathGeometry(new[] { new PathFigure(new Point(0, 0), new[] {
        new LineSegment(new Point(0, 100), true),
        new LineSegment(new Point(100, 100), true),
        new LineSegment(new Point(100, 0), true),
    }, true) });
    path.Data = Geometry.Combine(clip, geometry, GeometryCombineMode.Intersect, null);
    

    Result:

    Very important!

    It looks like UIElement.Clip still render invisible parts (mayhap only with StreamGeometry) ! Never use it! Clip geometry before assigning it.

提交回复
热议问题