Example #1
0
        public void ClipIteratorHasCorrectRects()
        {
            var rectA = SKRectI.Create(10, 10, 100, 100);
            var rectB = SKRectI.Create(50, 50, 100, 100);

            using var region = new SKRegion(rectA);
            region.Op(rectB, SKRegionOperation.Union);

            using var iterator = region.CreateClipIterator(SKRectI.Create(5, 5, 65, 65));

            Assert.True(iterator.Next(out var rect));
            Assert.Equal(SKRectI.Create(10, 10, 100, 40), rect);

            Assert.True(iterator.Next(out rect));
            Assert.Equal(SKRectI.Create(10, 50, 140, 60), rect);

            Assert.False(iterator.Next(out rect));
            Assert.Equal(SKRect.Empty, rect);

            Assert.False(iterator.Next(out rect));
            Assert.Equal(SKRect.Empty, rect);
        }