public void CorrectlySetsColorThicknessAndRectangle() { img.Draw(color, thickness, rectangle); Assert.NotEmpty(img.ProcessorApplications); DrawPathProcessor <Rgba32> processor = Assert.IsType <DrawPathProcessor <Rgba32> >(img.ProcessorApplications[0].processor); Assert.Equal(GraphicsOptions.Default, processor.Options); ShapePath shapepath = Assert.IsType <ShapePath>(processor.Path); SixLabors.Shapes.Rectangle rect = Assert.IsType <SixLabors.Shapes.Rectangle>(shapepath.Path); 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); Pen <Rgba32> pen = Assert.IsType <Pen <Rgba32> >(processor.Pen); Assert.Equal(thickness, pen.Width); SolidBrush <Rgba32> brush = Assert.IsType <SolidBrush <Rgba32> >(pen.Brush); Assert.Equal(color, brush.Color); }
/// <summary> /// Converts a Shaper2D <see cref="SixLabors.Shapes.Rectangle"/> to an ImageSharp <see cref="Rectangle"/> by creating a <see cref="Rectangle"/> the entirely surrounds the source. /// </summary> /// <param name="source">The image this method extends.</param> /// <returns>A <see cref="Rectangle"/> representation of this <see cref="SixLabors.Shapes.Rectangle"/></returns> public static Rectangle Convert(this SixLabors.Shapes.Rectangle source) { int left = (int)MathF.Floor(source.Left); int right = (int)MathF.Ceiling(source.Right); int top = (int)MathF.Floor(source.Top); int bottom = (int)MathF.Ceiling(source.Bottom); return(new Rectangle(left, top, right - left, bottom - top)); }
public void CorrectlySetsBrushRectangleAndOptions() { img.Fill(brush, 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.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); }
public void CorrectlySetsPenRectangleAndOptions() { img.Draw(pen, rectangle, noneDefault); Assert.NotEmpty(img.ProcessorApplications); DrawPathProcessor <Rgba32> processor = Assert.IsType <DrawPathProcessor <Rgba32> >(img.ProcessorApplications[0].processor); Assert.Equal(noneDefault, processor.Options); ShapePath shapepath = Assert.IsType <ShapePath>(processor.Path); SixLabors.Shapes.Rectangle rect = Assert.IsType <SixLabors.Shapes.Rectangle>(shapepath.Path); 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(pen, processor.Pen); }
public void CorrectlySetsColorAndRectangle() { img.Fill(color, 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.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 <Rgba32> brush = Assert.IsType <SolidBrush <Rgba32> >(processor.Brush); Assert.Equal(color, brush.Color); }