public void Length() { var seg1 = new LinearLineSegment(new Vector2(0, 0), new Vector2(0, 2)); var path = new Path(seg1); Assert.Equal(2, path.Length); }
public void Length_Closed() { var seg1 = new LinearLineSegment(new PointF(0, 0), new PointF(0, 2)); var path = new InternalPath(seg1, true); Assert.Equal(4, path.Length); }
public void Length_Open() { var seg1 = new LinearLineSegment(new PointF(0, 0), new PointF(0, 2)); var path = new InternalPath(seg1, false); Assert.Equal(2, path.Length); }
public static IPath ExtentToPath(float xMin, float yMin, float xMax, float yMax) { PointF[] polyPoints = ExtentToPoints(xMin, yMin, xMax, yMax); ILineSegment lineSegment = new LinearLineSegment(polyPoints); IPath path = new Path(lineSegment); return(path); }
public void SingleSegmentConstructor() { var segment = new LinearLineSegment(new Vector2(0, 0), new Vector2(10, 10)); var flatPath = segment.Flatten(); Assert.Equal(2, flatPath.Length); Assert.Equal(new Vector2(0, 0), flatPath[0]); Assert.Equal(new Vector2(10, 10), flatPath[1]); }
public void SingleSegmentConstructor() { var segment = new LinearLineSegment(new Vector2(0, 0), new Vector2(10, 10)); IReadOnlyList <PointF> flatPath = segment.Flatten(); Assert.Equal(2, flatPath.Count); Assert.Equal(new PointF(0, 0), flatPath[0]); Assert.Equal(new PointF(10, 10), flatPath[1]); }
public LinearLineSegment PolygonToDrawingLine(Geometry place, GeoArea drawingArea, double resolutionX, double resolutionY) { //NOTE: this doesn't handle holes if you add them to the end in the reverse order. Those must be handled by a function in ImageSharp. var typeConvertedPoints = place.Coordinates.Select(o => new SixLabors.ImageSharp.PointF((float)((o.X - drawingArea.WestLongitude) * (1 / resolutionX)), (float)((o.Y - drawingArea.SouthLatitude) * (1 / resolutionY)))); LinearLineSegment part = new LinearLineSegment(typeConvertedPoints.ToArray()); var x = new SixLabors.ImageSharp.Drawing.Path(); return(part); }
public void PointInPolygon_OpenPath() { LinearLineSegment seg1 = new LinearLineSegment(new PointF(0, 0), new PointF(0, 10), new PointF(10, 10), new PointF(10, 0)); InternalPath p = new InternalPath(seg1, false); Assert.False(p.PointInPolygon(new PointF(5, 5))); InternalPath p2 = new InternalPath(seg1, true); Assert.True(p2.PointInPolygon(new PointF(5, 5f))); }
public void Bounds() { LinearLineSegment seg1 = new LinearLineSegment(new PointF(0, 0), new PointF(2, 2)); LinearLineSegment seg2 = new LinearLineSegment(new PointF(4, 4), new PointF(5, 5)); InternalPath path = new InternalPath(new ILineSegment[] { seg1, seg2 }, true); Assert.Equal(0, path.Bounds.Left); Assert.Equal(5, path.Bounds.Right); Assert.Equal(0, path.Bounds.Top); Assert.Equal(5, path.Bounds.Bottom); }
public void Bounds() { var seg1 = new LinearLineSegment(new Vector2(0, 0), new Vector2(2, 2)); var seg2 = new LinearLineSegment(new Vector2(4, 4), new Vector2(5, 5)); var path = new InternalPath(new ILineSegment[] { seg1, seg2 }, true); Assert.Equal(0, path.Bounds.Left); Assert.Equal(5, path.Bounds.Right); Assert.Equal(0, path.Bounds.Top); Assert.Equal(5, path.Bounds.Bottom); }
public void Bounds() { var seg1 = new LinearLineSegment(new PointF(0, 0), new PointF(2, 2)); var seg2 = new LinearLineSegment(new PointF(4, 4), new PointF(5, 5)); var path = new Path(seg1, seg2); Assert.Equal(0, path.Bounds.Left); Assert.Equal(5, path.Bounds.Right); Assert.Equal(0, path.Bounds.Top); Assert.Equal(5, path.Bounds.Bottom); }
public void PointInPolygon_OpenPath() { var seg1 = new LinearLineSegment(new Vector2(0, 0), new Vector2(0, 10), new Vector2(10, 10), new Vector2(10, 0)); var p = new InternalPath(seg1, false); Assert.False(p.PointInPolygon(new Vector2(5, 5))); var p2 = new InternalPath(seg1, true); Assert.True(p2.PointInPolygon(new Vector2(5, 5f))); }
public void MultipleLineSegmentsSimplePathsAreMerged() { var seg1 = new LinearLineSegment(new Vector2(0, 0), new Vector2(2, 2)); var seg2 = new LinearLineSegment(new Vector2(4, 4), new Vector2(5, 5)); var path = new InternalPath(new ILineSegment[] { seg1, seg2 }, true); Assert.Equal(new Vector2(0, 0), path.Points[0]); Assert.Equal(new Vector2(2, 2), path.Points[1]); Assert.Equal(new Vector2(4, 4), path.Points[2]); Assert.Equal(new Vector2(5, 5), path.Points[3]); }
public void MultipleLineSegmentsSimplePathsAreMerged() { var seg1 = new LinearLineSegment(new PointF(0, 0), new PointF(2, 2)); var seg2 = new LinearLineSegment(new PointF(4, 4), new PointF(5, 5)); var path = new InternalPath(new ILineSegment[] { seg1, seg2 }, true); Assert.Contains(new PointF(0, 0), path.Points().ToArray()); Assert.DoesNotContain(new PointF(2, 2), path.Points().ToArray()); Assert.DoesNotContain(new PointF(4, 4), path.Points().ToArray()); Assert.Contains(new PointF(5, 5), path.Points().ToArray()); }
public static IPath ToPath(this PointF[] points) { IPath path = null; if (points == null || points.Length < 2) { return(path); } ILineSegment lineSegment = new LinearLineSegment(points); path = new Path(lineSegment); return(path); }
public void CorrectlySetsBrushPathAndOptions() { this.operations.FillPolygon(this.noneDefault, this.brush, this.path); FillRegionProcessor <Rgba32> processor = this.Verify <FillRegionProcessor <Rgba32> >(); Assert.Equal(this.noneDefault, processor.Options); ShapeRegion region = Assert.IsType <ShapeRegion>(processor.Region); Polygon polygon = Assert.IsType <Polygon>(region.Shape); LinearLineSegment segemnt = Assert.IsType <LinearLineSegment>(polygon.LineSegments[0]); Assert.Equal(this.brush, processor.Brush); }
public static Polygon ToPolygon(this PointF[] points) { Polygon polygon = null; if (points == null || points.Length < 3) { return(polygon); } ILineSegment lineSegment = new LinearLineSegment(points); polygon = new Polygon(lineSegment); return(polygon); }
private void DrawLine(params PointF[] segments) { var prev = segments.First(); var path = new Path(segments.Skip(1).Select(p => { var segment = new LinearLineSegment(prev, p); prev = p; return(segment); })); drawables.Add(new PathDrawer { Path = path }); }
public void CorrectlySetsBrushAndPath() { this.operations.Fill(this.brush, this.path); var processor = this.Verify <FillRegionProcessor <Rgba32> >(); 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(this.brush, processor.Brush); }
public void CorrectlySetsColorPathAndOptions() { this.operations.Fill(this.noneDefault, this.color, this.path); var processor = this.Verify <FillRegionProcessor <Rgba32> >(); 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]); SolidBrush <Rgba32> brush = Assert.IsType <SolidBrush <Rgba32> >(processor.Brush); Assert.Equal(this.color, brush.Color); }
public void CorrectlySetsBrushPathAndOptions() { img.FillPolygon(brush, 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 segemnt = Assert.IsType <LinearLineSegment>(polygon.LineSegments[0]); Assert.Equal(brush, processor.Brush); }
public void CorrectlySetsPenPointsAndOptions() { img.DrawLines(pen, points, noneDefault); Assert.NotEmpty(img.ProcessorApplications); DrawPathProcessor <Rgba32> processor = Assert.IsType <DrawPathProcessor <Rgba32> >(img.ProcessorApplications[0].processor); Assert.Equal(noneDefault, processor.Options); ShapePath path = Assert.IsType <ShapePath>(processor.Path); SixLabors.Shapes.Path vector = Assert.IsType <SixLabors.Shapes.Path>(path.Path); LinearLineSegment segment = Assert.IsType <LinearLineSegment>(vector.LineSegments[0]); Assert.Equal(pen, processor.Pen); }
public void CorrectlySetsPenAndPoints() { img.DrawPolygon(pen, points); Assert.NotEmpty(img.ProcessorApplications); DrawPathProcessor <Rgba32> processor = Assert.IsType <DrawPathProcessor <Rgba32> >(img.ProcessorApplications[0].processor); Assert.Equal(GraphicsOptions.Default, processor.Options); ShapePath path = Assert.IsType <ShapePath>(processor.Path); Polygon vector = Assert.IsType <SixLabors.Shapes.Polygon>(path.Path); LinearLineSegment segment = Assert.IsType <LinearLineSegment>(vector.LineSegments[0]); Assert.Equal(pen, processor.Pen); }
public void CorrectlySetsColorAndPath() { this.operations.FillPolygon(color, path); FillRegionProcessor <Rgba32> processor = this.Verify <FillRegionProcessor <Rgba32> >(); Assert.Equal(GraphicsOptions.Default, processor.Options); ShapeRegion region = Assert.IsType <ShapeRegion>(processor.Region); Polygon polygon = Assert.IsType <Polygon>(region.Shape); LinearLineSegment segemnt = Assert.IsType <LinearLineSegment>(polygon.LineSegments[0]); SolidBrush <Rgba32> brush = Assert.IsType <SolidBrush <Rgba32> >(processor.Brush); Assert.Equal(color, brush.Color); }
public void CorrectlySetsBrushPathOptions() { this.operations.Fill(this.noneDefault, this.brush, this.pathCollection); for (int i = 0; i < 2; i++) { FillRegionProcessor <Rgba32> processor = this.Verify <FillRegionProcessor <Rgba32> >(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); } }
public void CorrectlySetsBrushAndPath() { img.Fill(brush, path); 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); // 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); }
public void CorrectlySetsColorPathAndOptions() { img.Fill(color, path, 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); Polygon polygon = Assert.IsType <Polygon>(region.Shape); LinearLineSegment segments = Assert.IsType <LinearLineSegment>(polygon.LineSegments[0]); SolidBrush <Color> brush = Assert.IsType <SolidBrush <Color> >(processor.Brush); Assert.Equal(color, brush.Color); }
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); } }
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); } }
public void CorrectlySetsBrushThicknessAndPoints() { img.DrawLines(brush, thickness, points); Assert.NotEmpty(img.ProcessorApplications); DrawPathProcessor <Rgba32> processor = Assert.IsType <DrawPathProcessor <Rgba32> >(img.ProcessorApplications[0].processor); Assert.Equal(GraphicsOptions.Default, processor.Options); ShapePath path = Assert.IsType <ShapePath>(processor.Path); SixLabors.Shapes.Path vector = Assert.IsType <SixLabors.Shapes.Path>(path.Path); LinearLineSegment segment = Assert.IsType <LinearLineSegment>(vector.LineSegments[0]); Pen <Rgba32> pen = Assert.IsType <Pen <Rgba32> >(processor.Pen); Assert.Equal(brush, pen.Brush); Assert.Equal(thickness, pen.Width); }