public void FillOffCanvas() { var bounds = new Rectangle(-100, -10, 10, 10); // Specifically not using RectangularPolygon here to ensure the FillPathProcessor is used. var points = new LinearLineSegment[] { new LinearLineSegment(new PointF(bounds.Left, bounds.Top), new PointF(bounds.Right, bounds.Top)), new LinearLineSegment(new PointF(bounds.Right, bounds.Top), new PointF(bounds.Right, bounds.Bottom)), new LinearLineSegment(new PointF(bounds.Right, bounds.Bottom), new PointF(bounds.Left, bounds.Bottom)), new LinearLineSegment(new PointF(bounds.Left, bounds.Bottom), new PointF(bounds.Left, bounds.Top)) }; var path = new Path(points); var brush = new Mock <IBrush>(); var options = new GraphicsOptions { Antialias = true }; var processor = new FillPathProcessor(new DrawingOptions() { GraphicsOptions = options }, brush.Object, path); var img = new Image <Rgba32>(10, 10); processor.Execute(img.GetConfiguration(), img, bounds); }
public void Execute() { // performa any processing logic you wan here, in this case we are going to // clone the source image then apply the changes requested before cropping // down and using an image brush to draw that portion the the original image // so clone out our source image so we can apply // various effects to it without mutating the origional yet. using (var clone = source.Clone(recursiveImageProcessor.InnerProcessingOperations)) { // crop it down to just the size of the shape clone.Mutate(x => x.Crop((Rectangle)recursiveImageProcessor.Path.Bounds)); // use an image brush to apply cloned image as the source for filling the shape var brush = new ImageBrush(clone); // grab hold of an inbox image processor that can fill paths with a brush to allow it to do the hard pixel pushing for us var processor = new FillPathProcessor(recursiveImageProcessor.Options, brush, recursiveImageProcessor.Path); using (var p = processor.CreatePixelSpecificProcessor <TPixel>(configuration, source, sourceRectangle)) { // fill the shape using the image brush p.Execute(); } } }
public void BrushDefaultOptions() { this.operations.Clear(this.brush, this.rectangle); FillPathProcessor processor = this.Verify <FillPathProcessor>(); Assert.Equal(this.shapeOptions, processor.Options.ShapeOptions); Assert.True(RectangularPolygonValueComparer.Equals(this.RectanglePolygon, processor.Region)); Assert.Equal(this.brush, processor.Brush); }
public void Brush() { this.operations.Fill(new ShapeGraphicsOptions(), this.brush, this.rectangle); FillPathProcessor processor = this.Verify <FillPathProcessor>(); Assert.NotEqual(this.shapeOptions, processor.Options.ShapeOptions); Assert.Equal(this.rectanglePolygon, processor.Shape); Assert.Equal(this.brush, processor.Brush); }
public void Brush() { this.operations.Fill(new ShapeGraphicsOptions(), this.brush, this.builder); FillPathProcessor processor = this.Verify <FillPathProcessor>(); Assert.NotEqual(this.shapeOptions, processor.Options.ShapeOptions); this.VerifyPoints(this.path, processor.Shape); Assert.Equal(this.brush, processor.Brush); }
public void BrushDefaultOptions() { this.operations.FillPolygon(this.brush, this.path); FillPathProcessor processor = this.Verify <FillPathProcessor>(); Assert.Equal(this.shapeOptions, processor.Options.ShapeOptions); this.VerifyPoints(this.path, processor.Shape); Assert.Equal(this.brush, processor.Brush); }
public void BrushDefaultOptions() { this.operations.Clear(this.brush, this.rectangle); FillPathProcessor processor = this.Verify <FillPathProcessor>(); Assert.Equal(this.shapeOptions, processor.Options.ShapeOptions); Assert.Equal(this.rectanglePolygon, processor.Shape); Assert.Equal(this.brush, processor.Brush); }
public void Brush() { this.operations.FillPolygon(new DrawingOptions(), this.brush, this.path); FillPathProcessor processor = this.Verify <FillPathProcessor>(); Assert.NotEqual(this.shapeOptions, processor.Options.ShapeOptions); this.VerifyPoints(this.path, processor.Region); Assert.Equal(this.brush, processor.Brush); }
public void ColorAndThicknessDefaultOptions() { this.operations.FillPolygon(Color.Red, this.path); FillPathProcessor processor = this.Verify <FillPathProcessor>(); Assert.Equal(this.shapeOptions, processor.Options.ShapeOptions); this.VerifyPoints(this.path, processor.Shape); Assert.NotEqual(this.brush, processor.Brush); var brush = Assert.IsType <SolidBrush>(processor.Brush); Assert.Equal(Color.Red, brush.Color); }
public void ColorSet() { this.operations.Fill(new ShapeGraphicsOptions(), Color.Red, this.builder); FillPathProcessor processor = this.Verify <FillPathProcessor>(); Assert.NotEqual(this.shapeOptions, processor.Options.ShapeOptions); this.VerifyPoints(this.path, processor.Shape); Assert.NotEqual(this.brush, processor.Brush); var brush = Assert.IsType <SolidBrush>(processor.Brush); Assert.Equal(Color.Red, brush.Color); }
public void ColorSet() { this.operations.Clear(new DrawingOptions(), Color.Red, this.rectangle); FillPathProcessor processor = this.Verify <FillPathProcessor>(); Assert.NotEqual(this.shapeOptions, processor.Options.ShapeOptions); Assert.True(RectangularPolygonValueComparer.Equals(this.RectanglePolygon, processor.Region)); Assert.NotEqual(this.brush, processor.Brush); SolidBrush brush = Assert.IsType <SolidBrush>(processor.Brush); Assert.Equal(Color.Red, brush.Color); }
public void ColorSet() { this.operations.Clear(new ShapeGraphicsOptions(), Color.Red, this.rectangle); FillPathProcessor processor = this.Verify <FillPathProcessor>(); Assert.NotEqual(this.shapeOptions, processor.Options.ShapeOptions); Assert.Equal(this.rectanglePolygon, processor.Shape); Assert.NotEqual(this.brush, processor.Brush); var brush = Assert.IsType <SolidBrush>(processor.Brush); Assert.Equal(Color.Red, brush.Color); }
public void ColorSet() { this.operations.FillPolygon(new DrawingOptions(), Color.Red, this.path); FillPathProcessor processor = this.Verify <FillPathProcessor>(); Assert.NotEqual(this.shapeOptions, processor.Options.ShapeOptions); this.VerifyPoints(this.path, processor.Region); Assert.NotEqual(this.brush, processor.Brush); SolidBrush brush = Assert.IsType <SolidBrush>(processor.Brush); Assert.Equal(Color.Red, brush.Color); }
public void ColorAndThicknessDefaultOptions() { this.operations.Clear(Color.Red, this.rectangle); FillPathProcessor processor = this.Verify <FillPathProcessor>(); Assert.Equal(this.shapeOptions, processor.Options.ShapeOptions); Assert.Equal(this.RectanglePolygon, processor.Shape); Assert.NotEqual(this.brush, processor.Brush); SolidBrush brush = Assert.IsType <SolidBrush>(processor.Brush); Assert.Equal(Color.Red, brush.Color); }
public void OtherShape() { var imageSize = new Rectangle(0, 0, 500, 500); var path = new EllipsePolygon(1, 1, 23); var processor = new FillPathProcessor(new ImageSharp.Drawing.Processing.ShapeGraphicsOptions() { GraphicsOptions = { Antialias = true } }, Brushes.Solid(Color.Red), path); var pixelProcessor = processor.CreatePixelSpecificProcessor <Rgba32>(null, null, imageSize); Assert.IsType <FillRegionProcessor <Rgba32> >(pixelProcessor); }
public void BrushDefaultOptions() { this.operations.Clear(this.brush, this.path); FillPathProcessor processor = this.Verify <FillPathProcessor>(); 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.Shape); Assert.Equal(this.brush, processor.Brush); }
public void RectangleFloatAndAntialias() { var imageSize = new Rectangle(0, 0, 500, 500); var floatRect = new RectangleF(10.5f, 10.5f, 400.6f, 400.9f); var expectedRect = new Rectangle(10, 10, 400, 400); var path = new RectangularPolygon(floatRect); var processor = new FillPathProcessor(new ImageSharp.Drawing.Processing.ShapeGraphicsOptions() { GraphicsOptions = { Antialias = true } }, Brushes.Solid(Color.Red), path); var pixelProcessor = processor.CreatePixelSpecificProcessor <Rgba32>(null, null, imageSize); Assert.IsType <FillRegionProcessor <Rgba32> >(pixelProcessor); }
public void IntRectangle() { var imageSize = new Rectangle(0, 0, 500, 500); var expectedRect = new Rectangle(10, 10, 400, 400); var path = new RectangularPolygon(expectedRect); var processor = new FillPathProcessor(new ImageSharp.Drawing.Processing.ShapeGraphicsOptions() { GraphicsOptions = { Antialias = true } }, Brushes.Solid(Color.Red), path); var pixelProcessor = processor.CreatePixelSpecificProcessor <Rgba32>(null, null, imageSize); var fill = Assert.IsType <FillProcessor <Rgba32> >(pixelProcessor); Assert.Equal(expectedRect, fill.GetProtectedValue <Rectangle>("SourceRectangle")); }
public void ColorSet() { this.operations.Clear(this.nonDefaultOptions, Color.Red, this.path); FillPathProcessor processor = this.Verify <FillPathProcessor>(); ShapeGraphicsOptions expectedOptions = this.nonDefaultOptions; Assert.Equal(expectedOptions.ShapeOptions, 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.Shape); Assert.NotEqual(this.brush, processor.Brush); SolidBrush brush = Assert.IsType <SolidBrush>(processor.Brush); Assert.Equal(Color.Red, brush.Color); }
public void FloatRectAntialiasingOff() { var imageSize = new Rectangle(0, 0, 500, 500); var floatRect = new RectangleF(10.5f, 10.5f, 400.6f, 400.9f); var expectedRect = new Rectangle(10, 10, 400, 400); var path = new RectangularPolygon(floatRect); var processor = new FillPathProcessor( new ShapeGraphicsOptions() { GraphicsOptions = { Antialias = false } }, Brushes.Solid(Color.Red), path); IImageProcessor <Rgba32> pixelProcessor = processor.CreatePixelSpecificProcessor <Rgba32>(null, null, imageSize); FillProcessor <Rgba32> fill = Assert.IsType <FillProcessor <Rgba32> >(pixelProcessor); Assert.Equal(expectedRect, fill.GetProtectedValue <Rectangle>("SourceRectangle")); }