コード例 #1
0
        public void CorrectlySetsBrushRectangleAndOptions()
        {
            this.operations.Fill(this.noneDefault, this.brush, this.rectangle);
            FillRegionProcessor processor = this.Verify <FillRegionProcessor>();

            Assert.Equal(this.noneDefault, processor.Options);

            ShapeRegion region = Assert.IsType <ShapeRegion>(processor.Region);

            Shapes.RectangularPolygon rect = Assert.IsType <Shapes.RectangularPolygon>(region.Shape);
            Assert.Equal(rect.Location.X, this.rectangle.X);
            Assert.Equal(rect.Location.Y, this.rectangle.Y);
            Assert.Equal(rect.Size.Width, this.rectangle.Width);
            Assert.Equal(rect.Size.Height, this.rectangle.Height);

            Assert.Equal(this.brush, processor.Brush);
        }
コード例 #2
0
        public void CorrectlySetsBrushAndRectangle()
        {
            this.operations.Fill(this.brush, this.rectangle);
            FillRegionProcessor processor = this.Verify <FillRegionProcessor>();

            Assert.Equal(new GraphicsOptions(), processor.Options, graphicsOptionsComparer);

            ShapeRegion region = Assert.IsType <ShapeRegion>(processor.Region);

            Shapes.RectangularPolygon rect = Assert.IsType <Shapes.RectangularPolygon>(region.Shape);
            Assert.Equal(rect.Location.X, this.rectangle.X);
            Assert.Equal(rect.Location.Y, this.rectangle.Y);
            Assert.Equal(rect.Size.Width, this.rectangle.Width);
            Assert.Equal(rect.Size.Height, this.rectangle.Height);

            Assert.Equal(this.brush, processor.Brush);
        }
コード例 #3
0
        public void CorrectlySetsColorPathAndOptions()
        {
            this.operations.Draw(this.noneDefault, this.color, 1, this.pathCollection);

            for (int i = 0; i < 2; i++)
            {
                FillRegionProcessor <Rgba32> processor = this.Verify <FillRegionProcessor <Rgba32> >(i);

                Assert.Equal(this.noneDefault, processor.Options);

                ShapePath      region  = Assert.IsType <ShapePath>(processor.Region);
                ComplexPolygon polygon = Assert.IsType <ComplexPolygon>(region.Shape);

                SolidBrush <Rgba32> brush = Assert.IsType <SolidBrush <Rgba32> >(processor.Brush);
                Assert.Equal(this.color, brush.Color);
            }
        }
コード例 #4
0
        public void CorrectlySetsBrushAndPath()
        {
            img.Fill(brush, path);

            Assert.NotEmpty(img.ProcessorApplications);
            FillRegionProcessor <Rgba32> processor = Assert.IsType <FillRegionProcessor <Rgba32> >(img.ProcessorApplications[0].processor);

            Assert.Equal(GraphicsOptions.Default, processor.Options);

            ShapeRegion region = Assert.IsType <ShapeRegion>(processor.Region);

            // path is converted to a polygon before filling
            Polygon           polygon  = Assert.IsType <Polygon>(region.Shape);
            LinearLineSegment segments = Assert.IsType <LinearLineSegment>(polygon.LineSegments[0]);

            Assert.Equal(brush, processor.Brush);
        }
コード例 #5
0
        public void CorrectlySetsBrushRectangleAndOptions()
        {
            this.operations.Fill(brush, rectangle, noneDefault);
            FillRegionProcessor <Rgba32> processor = this.Verify <FillRegionProcessor <Rgba32> >();

            Assert.Equal(noneDefault, processor.Options);

            ShapeRegion region = Assert.IsType <ShapeRegion>(processor.Region);

            SixLabors.Shapes.RectangularePolygon rect = Assert.IsType <SixLabors.Shapes.RectangularePolygon>(region.Shape);
            Assert.Equal(rect.Location.X, rectangle.X);
            Assert.Equal(rect.Location.Y, rectangle.Y);
            Assert.Equal(rect.Size.Width, rectangle.Width);
            Assert.Equal(rect.Size.Height, rectangle.Height);

            Assert.Equal(brush, processor.Brush);
        }
コード例 #6
0
        public void CorrectlySetsBrushPathOptions()
        {
            this.operations.Fill(this.noneDefault, this.brush, this.pathCollection);

            for (int i = 0; i < 2; i++)
            {
                FillRegionProcessor processor = this.Verify <FillRegionProcessor>(i);

                Assert.Equal(this.noneDefault, processor.Options);

                ShapeRegion       region   = Assert.IsType <ShapeRegion>(processor.Region);
                Polygon           polygon  = Assert.IsType <Polygon>(region.Shape);
                LinearLineSegment segments = Assert.IsType <LinearLineSegment>(polygon.LineSegments[0]);

                Assert.Equal(this.brush, processor.Brush);
            }
        }
コード例 #7
0
        public void CorrectlySetsColorAndPath()
        {
            this.operations.Draw(this.color, 1, this.pathCollection);

            for (int i = 0; i < 2; i++)
            {
                FillRegionProcessor processor = this.Verify <FillRegionProcessor>(i);

                Assert.Equal(GraphicsOptions.Default, processor.Options);

                ShapePath region = Assert.IsType <ShapePath>(processor.Region);
                Assert.IsType <ComplexPolygon>(region.Shape);

                SolidBrush brush = Assert.IsType <SolidBrush>(processor.Brush);
                Assert.Equal(this.color, brush.Color);
            }
        }
コード例 #8
0
        public void CorrectlySetsColorShapeAndOptions()
        {
            img.Fill(color, shape, noneDefault);

            Assert.NotEmpty(img.ProcessorApplications);
            FillRegionProcessor <Color> processor = Assert.IsType <FillRegionProcessor <Color> >(img.ProcessorApplications[0].processor);

            Assert.Equal(noneDefault, processor.Options);

            ShapeRegion region = Assert.IsType <ShapeRegion>(processor.Region);

            Assert.Equal(shape, region.Shape);

            SolidBrush <Color> brush = Assert.IsType <SolidBrush <Color> >(processor.Brush);

            Assert.Equal(color, brush.Color);
        }
コード例 #9
0
        public void CorrectlySetsColorPathAndOptions()
        {
            img.Fill(color, path, noneDefault);

            Assert.NotEmpty(img.ProcessorApplications);
            FillRegionProcessor <Rgba32> processor = Assert.IsType <FillRegionProcessor <Rgba32> >(img.ProcessorApplications[0].processor);

            Assert.Equal(noneDefault, processor.Options);

            ShapeRegion       region   = Assert.IsType <ShapeRegion>(processor.Region);
            Polygon           polygon  = Assert.IsType <Polygon>(region.Shape);
            LinearLineSegment segments = Assert.IsType <LinearLineSegment>(polygon.LineSegments[0]);

            SolidBrush <Rgba32> brush = Assert.IsType <SolidBrush <Rgba32> >(processor.Brush);

            Assert.Equal(color, brush.Color);
        }
コード例 #10
0
        public void CorrectlySetsColorAndPath()
        {
            this.operations.FillPolygon(this.color, this.path);
            FillRegionProcessor processor = this.Verify <FillRegionProcessor>();


            Assert.Equal(new GraphicsOptions(), processor.Options, graphicsOptionsComparer);

            ShapeRegion region  = Assert.IsType <ShapeRegion>(processor.Region);
            Polygon     polygon = Assert.IsType <Polygon>(region.Shape);

            Assert.IsType <LinearLineSegment>(polygon.LineSegments[0]);

            SolidBrush brush = Assert.IsType <SolidBrush>(processor.Brush);

            Assert.Equal(this.color, brush.Color);
        }
コード例 #11
0
        [InlineData(false, 16, 4)] // we always do 4 sub=pixels when antialising is off.
        public void MinimumAntialiasSubpixelDepth(bool antialias, int antialiasSubpixelDepth, int expectedAntialiasSubpixelDepth)
        {
            var bounds = new Rectangle(0, 0, 1, 1);

            var brush  = new Mock <IBrush <Rgba32> >();
            var region = new MockRegion2(bounds);

            var options = new GraphicsOptions(antialias)
            {
                AntialiasSubpixelDepth = 1
            };
            var processor = new FillRegionProcessor <Rgba32>(brush.Object, region, options);
            var img       = new Image <Rgba32>(1, 1);

            processor.Apply(img, bounds);

            Assert.Equal(4, region.ScanInvocationCounter);
        }
コード例 #12
0
        public void CorrectlySetsBrushPathOptions()
        {
            img.Fill(brush, pathCollection, noneDefault);

            Assert.Equal(2, img.ProcessorApplications.Count);
            for (var i = 0; i < 2; i++)
            {
                FillRegionProcessor <Rgba32> processor = Assert.IsType <FillRegionProcessor <Rgba32> >(img.ProcessorApplications[i].processor);

                Assert.Equal(noneDefault, processor.Options);

                ShapeRegion       region   = Assert.IsType <ShapeRegion>(processor.Region);
                Polygon           polygon  = Assert.IsType <Polygon>(region.Shape);
                LinearLineSegment segments = Assert.IsType <LinearLineSegment>(polygon.LineSegments[0]);

                Assert.Equal(brush, processor.Brush);
            }
        }
コード例 #13
0
        public void CorrectlySetsColorAndPath()
        {
            this.operations.Fill(this.color, this.pathCollection);

            for (int i = 0; i < 2; i++)
            {
                FillRegionProcessor <Rgba32> processor = this.Verify <FillRegionProcessor <Rgba32> >(i);

                Assert.Equal(GraphicsOptions.Default, processor.Options);

                ShapeRegion       region   = Assert.IsType <ShapeRegion>(processor.Region);
                Polygon           polygon  = Assert.IsType <Polygon>(region.Shape);
                LinearLineSegment segments = Assert.IsType <LinearLineSegment>(polygon.LineSegments[0]);

                SolidBrush <Rgba32> brush = Assert.IsType <SolidBrush <Rgba32> >(processor.Brush);
                Assert.Equal(this.color, brush.Color);
            }
        }
コード例 #14
0
        public void CorrectlySetsColorPathAndOptions()
        {
            this.operations.Fill(this.nonDefault, this.color, this.pathCollection);

            for (int i = 0; i < 2; i++)
            {
                FillRegionProcessor processor = this.Verify <FillRegionProcessor>(i);

                Assert.Equal(this.nonDefault, processor.Options, graphicsOptionsComparer);

                ShapeRegion region  = Assert.IsType <ShapeRegion>(processor.Region);
                Polygon     polygon = Assert.IsType <Polygon>(region.Shape);
                Assert.IsType <LinearLineSegment>(polygon.LineSegments[0]);

                SolidBrush brush = Assert.IsType <SolidBrush>(processor.Brush);
                Assert.Equal(this.color, brush.Color);
            }
        }
コード例 #15
0
        public void CorrectlySetsBrushAndPath()
        {
            this.operations.Draw(this.pen, this.pathCollection);

            for (int i = 0; i < 2; i++)
            {
                FillRegionProcessor processor = this.Verify <FillRegionProcessor>(i);

                Assert.Equal(GraphicsOptions.Default, processor.Options);

                ShapePath region = Assert.IsType <ShapePath>(processor.Region);

                // path is converted to a polygon before filling
                Assert.IsType <ComplexPolygon>(region.Shape);

                Assert.Equal(this.pen.StrokeFill, processor.Brush);
            }
        }
コード例 #16
0
        public void CorrectlySetsBrushAndPath()
        {
            this.operations.Fill(this.brush, this.pathCollection);

            for (int i = 0; i < 2; i++)
            {
                FillRegionProcessor processor = this.Verify <FillRegionProcessor>(i);

                Assert.Equal(new GraphicsOptions(), processor.Options, graphicsOptionsComparer);

                ShapeRegion region = Assert.IsType <ShapeRegion>(processor.Region);

                // path is converted to a polygon before filling
                Polygon polygon = Assert.IsType <Polygon>(region.Shape);
                Assert.IsType <LinearLineSegment>(polygon.LineSegments[0]);

                Assert.Equal(this.brush, processor.Brush);
            }
        }
コード例 #17
0
        public void CorrectlySetsColorRectangleAndOptions()
        {
            this.operations.Fill(this.nonDefault, this.color, this.rectangle);
            FillRegionProcessor processor = this.Verify <FillRegionProcessor>();

            Assert.Equal(this.nonDefault, processor.Options, graphicsOptionsComparer);

            ShapeRegion        region = Assert.IsType <ShapeRegion>(processor.Region);
            RectangularPolygon rect   = Assert.IsType <RectangularPolygon>(region.Shape);

            Assert.Equal(rect.Location.X, this.rectangle.X);
            Assert.Equal(rect.Location.Y, this.rectangle.Y);
            Assert.Equal(rect.Size.Width, this.rectangle.Width);
            Assert.Equal(rect.Size.Height, this.rectangle.Height);

            SolidBrush brush = Assert.IsType <SolidBrush>(processor.Brush);

            Assert.Equal(this.color, brush.Color);
        }
コード例 #18
0
        public void CorrectlySetsBrushRectangleAndOptions()
        {
            img.Fill(brush, rectangle, noneDefault);

            Assert.NotEmpty(img.ProcessorApplications);
            FillRegionProcessor <Color> processor = Assert.IsType <FillRegionProcessor <Color> >(img.ProcessorApplications[0].processor);

            Assert.Equal(noneDefault, processor.Options);

            ShapeRegion region = Assert.IsType <ShapeRegion>(processor.Region);

            SixLabors.Shapes.Rectangle rect = Assert.IsType <SixLabors.Shapes.Rectangle>(region.Shape);
            Assert.Equal(rect.Location.X, rectangle.X);
            Assert.Equal(rect.Location.Y, rectangle.Y);
            Assert.Equal(rect.Size.Width, rectangle.Width);
            Assert.Equal(rect.Size.Height, rectangle.Height);

            Assert.Equal(brush, processor.Brush);
        }
コード例 #19
0
        public void ColorAndThicknessDefaultOptions()
        {
            this.operations.Clear(Color.Red, this.path);

            FillRegionProcessor processor = this.Verify <FillRegionProcessor>();

            ShapeOptions expectedOptions = this.shapeOptions;

            Assert.Equal(expectedOptions, processor.Options.ShapeOptions);
            Assert.Equal(1, processor.Options.GraphicsOptions.BlendPercentage);
            Assert.Equal(PixelFormats.PixelAlphaCompositionMode.Src, processor.Options.GraphicsOptions.AlphaCompositionMode);
            Assert.Equal(PixelFormats.PixelColorBlendingMode.Normal, processor.Options.GraphicsOptions.ColorBlendingMode);

            Assert.Equal(this.path, processor.Region);
            Assert.NotEqual(this.brush, processor.Brush);
            SolidBrush brush = Assert.IsType <SolidBrush>(processor.Brush);

            Assert.Equal(Color.Red, brush.Color);
        }
コード例 #20
0
ファイル: FillRectangle.cs プロジェクト: zxshinxz/ImageSharp
        public void CorrectlySetsBrushAndRectangle()
        {
            img.Fill(brush, rectangle);

            Assert.NotEmpty(img.ProcessorApplications);
            FillRegionProcessor <Rgba32> processor = Assert.IsType <FillRegionProcessor <Rgba32> >(img.ProcessorApplications[0].processor);

            Assert.Equal(GraphicsOptions.Default, processor.Options);

            ShapeRegion region = Assert.IsType <ShapeRegion>(processor.Region);

            SixLabors.Shapes.RectangularePolygon rect = Assert.IsType <SixLabors.Shapes.RectangularePolygon>(region.Shape);
            Assert.Equal(rect.Location.X, rectangle.X);
            Assert.Equal(rect.Location.Y, rectangle.Y);
            Assert.Equal(rect.Size.Width, rectangle.Width);
            Assert.Equal(rect.Size.Height, rectangle.Height);

            Assert.Equal(brush, processor.Brush);
        }
コード例 #21
0
ファイル: FillRectangle.cs プロジェクト: woutware/ImageSharp
        public void CorrectlySetsColorAndRectangle()
        {
            this.operations.Fill(this.color, this.rectangle);
            FillRegionProcessor <Rgba32> processor = this.Verify <FillRegionProcessor <Rgba32> >();

            Assert.Equal(GraphicsOptions.Default, processor.Options);

            ShapeRegion region = Assert.IsType <ShapeRegion>(processor.Region);

            Shapes.RectangularPolygon rect = Assert.IsType <Shapes.RectangularPolygon>(region.Shape);
            Assert.Equal(rect.Location.X, this.rectangle.X);
            Assert.Equal(rect.Location.Y, this.rectangle.Y);
            Assert.Equal(rect.Size.Width, this.rectangle.Width);
            Assert.Equal(rect.Size.Height, this.rectangle.Height);

            SolidBrush <Rgba32> brush = Assert.IsType <SolidBrush <Rgba32> >(processor.Brush);

            Assert.Equal(this.color, brush.Color);
        }
コード例 #22
0
        public void CorrectlySetsColorAndPath()
        {
            img.Fill(color, pathCollection);

            Assert.Equal(2, img.ProcessorApplications.Count);
            for (var i = 0; i < 2; i++)
            {
                FillRegionProcessor <Rgba32> processor = Assert.IsType <FillRegionProcessor <Rgba32> >(img.ProcessorApplications[i].processor);

                Assert.Equal(GraphicsOptions.Default, processor.Options);

                ShapeRegion       region   = Assert.IsType <ShapeRegion>(processor.Region);
                Polygon           polygon  = Assert.IsType <Polygon>(region.Shape);
                LinearLineSegment segments = Assert.IsType <LinearLineSegment>(polygon.LineSegments[0]);

                SolidBrush <Rgba32> brush = Assert.IsType <SolidBrush <Rgba32> >(processor.Brush);
                Assert.Equal(color, brush.Color);
            }
        }
コード例 #23
0
        public void CorrectlySetsBrushAndPath()
        {
            this.operations.Fill(brush, pathCollection);

            for (var i = 0; i < 2; i++)
            {
                FillRegionProcessor <Rgba32> processor = this.Verify <FillRegionProcessor <Rgba32> >(i);

                Assert.Equal(GraphicsOptions.Default, processor.Options);

                ShapeRegion region = Assert.IsType <ShapeRegion>(processor.Region);

                // path is converted to a polygon before filling
                Polygon           polygon  = Assert.IsType <Polygon>(region.Shape);
                LinearLineSegment segments = Assert.IsType <LinearLineSegment>(polygon.LineSegments[0]);

                Assert.Equal(brush, processor.Brush);
            }
        }
コード例 #24
0
        [InlineData(false, 16, 4)] // we always do 4 sub=pixels when antialiasing is off.
        public void MinimumAntialiasSubpixelDepth(bool antialias, int antialiasSubpixelDepth, int expectedAntialiasSubpixelDepth)
        {
            var bounds = new Rectangle(0, 0, 1, 1);

            var brush  = new Mock <IBrush>();
            var region = new MockRegion2(bounds);

            var options = new GraphicsOptions
            {
                Antialias = antialias,
                AntialiasSubpixelDepth = 1
            };
            var processor = new FillRegionProcessor(options, brush.Object, region);
            var img       = new Image <Rgba32>(1, 1);

            processor.Execute(img.GetConfiguration(), img, bounds);

            Assert.Equal(4, region.ScanInvocationCounter);
        }
コード例 #25
0
        [InlineData(false, 16, 4)] // we always do 4 sub=pixels when antialising is off.
        public void MinimumAntialiasSubpixelDepth(bool antialias, int antialiasSubpixelDepth, int expectedAntialiasSubpixelDepth)
        {
            ImageSharp.Rectangle bounds = new ImageSharp.Rectangle(0, 0, 1, 1);

            Mock <IBrush <Rgba32> > brush  = new Mock <IBrush <Rgba32> >();
            Mock <Region>           region = new Mock <Region>();

            region.Setup(x => x.Bounds).Returns(bounds);

            GraphicsOptions options = new GraphicsOptions(antialias)
            {
                AntialiasSubpixelDepth = 1
            };
            FillRegionProcessor <Rgba32> processor = new FillRegionProcessor <Rgba32>(brush.Object, region.Object, options);
            Image <Rgba32> img = new Image <Rgba32>(1, 1);

            processor.Apply(img, bounds);

            region.Verify(x => x.Scan(It.IsAny <float>(), It.IsAny <Span <float> >()), Times.Exactly(4));
        }
コード例 #26
0
        [InlineData(false, 16, 4)] // we always do 4 sub=pixels when antialising is off.
        public void MinimumAntialiasSubpixelDepth(bool antialias, int antialiasSubpixelDepth, int expectedAntialiasSubpixelDepth)
        {
            var bounds = new SixLabors.Primitives.Rectangle(0, 0, 1, 1);

            var brush  = new Mock <IBrush <Rgba32> >();
            var region = new Mock <Region>();

            region.Setup(x => x.Bounds).Returns(bounds);

            var options = new GraphicsOptions(antialias)
            {
                AntialiasSubpixelDepth = 1
            };
            var processor = new FillRegionProcessor <Rgba32>(brush.Object, region.Object, options);
            var img       = new Image <Rgba32>(1, 1);

            processor.Apply(img, bounds);

            region.Verify(x => x.Scan(It.IsAny <float>(), It.IsAny <float[]>(), It.IsAny <int>()), Times.Exactly(4));
        }
コード例 #27
0
        public void CorrectlySetsColorAndRectangle()
        {
            img.Fill(color, rectangle);

            Assert.NotEmpty(img.ProcessorApplications);
            FillRegionProcessor <Color> processor = Assert.IsType <FillRegionProcessor <Color> >(img.ProcessorApplications[0].processor);

            Assert.Equal(GraphicsOptions.Default, processor.Options);

            ShapeRegion region = Assert.IsType <ShapeRegion>(processor.Region);

            SixLabors.Shapes.Rectangle rect = Assert.IsType <SixLabors.Shapes.Rectangle>(region.Shape);
            Assert.Equal(rect.Location.X, rectangle.X);
            Assert.Equal(rect.Location.Y, rectangle.Y);
            Assert.Equal(rect.Size.Width, rectangle.Width);
            Assert.Equal(rect.Size.Height, rectangle.Height);

            SolidBrush <Color> brush = Assert.IsType <SolidBrush <Color> >(processor.Brush);

            Assert.Equal(color, brush.Color);
        }
コード例 #28
0
ファイル: FillRectangle.cs プロジェクト: zxshinxz/ImageSharp
        public void CorrectlySetsColorRectangleAndOptions()
        {
            img.Fill(color, rectangle, noneDefault);

            Assert.NotEmpty(img.ProcessorApplications);
            FillRegionProcessor <Rgba32> processor = Assert.IsType <FillRegionProcessor <Rgba32> >(img.ProcessorApplications[0].processor);

            Assert.Equal(noneDefault, processor.Options);

            ShapeRegion region = Assert.IsType <ShapeRegion>(processor.Region);

            SixLabors.Shapes.RectangularePolygon rect = Assert.IsType <SixLabors.Shapes.RectangularePolygon>(region.Shape);
            Assert.Equal(rect.Location.X, rectangle.X);
            Assert.Equal(rect.Location.Y, rectangle.Y);
            Assert.Equal(rect.Size.Width, rectangle.Width);
            Assert.Equal(rect.Size.Height, rectangle.Height);

            SolidBrush <Rgba32> brush = Assert.IsType <SolidBrush <Rgba32> >(processor.Brush);

            Assert.Equal(color, brush.Color);
        }