public void Intersections_0() { IPath shape = new RectangularePolygon(1, 1, 10, 10); IEnumerable <PointF> intersections = shape.FindIntersections(new PointF(0, 5), new PointF(-5, 5)); Assert.Equal(0, intersections.Count()); }
public void SizeF() { RectangularePolygon shape = new RectangularePolygon(10, 11, 12, 13); Assert.Equal(12, shape.Size.Width); Assert.Equal(13, shape.Size.Height); }
public void TransformIdnetityReturnsSahpeObject() { IPath shape = new RectangularePolygon(0, 0, 200, 60); IPath transformdShape = shape.Transform(Matrix3x2.Identity); Assert.Same(shape, transformdShape); }
public void DistanceFromPath_Path(TestPoint point, float expectecDistance, float alongPath) { IPath shape = new RectangularePolygon(0, 0, 10, 10).AsPath(); PointInfo info = shape.Distance(point); Assert.Equal(expectecDistance, info.DistanceFromPath); Assert.Equal(alongPath, info.DistanceAlongPath); }
private static void OutputClippedRectangle() { var rect1 = new RectangularePolygon(10, 10, 40, 40); var rect2 = new RectangularePolygon(20, 0, 20, 20); var paths = rect1.Clip(rect2); paths.SaveImage("Clipping", "RectangleWithTopClipped.png"); }
public void ClippingEdgefromInside() { IPath simplePath = new RectangularePolygon(10, 10, 100, 100).Clip(new RectangularePolygon(20, 0, 20, 20)); IEnumerable <PointF> intersections = simplePath.FindIntersections(new PointF(float.MinValue, 20), new PointF(float.MaxValue, 20)); // returns an even number of points Assert.Equal(4, intersections.Count()); }
public void Bounds_Path() { IPath shape = new RectangularePolygon(10, 11, 12, 13).AsPath(); Assert.Equal(10, shape.Bounds.Left); Assert.Equal(22, shape.Bounds.Right); Assert.Equal(11, shape.Bounds.Top); Assert.Equal(24, shape.Bounds.Bottom); }
[InlineData(620, 150, 50, Pi)] // wrap about end of path public void PointOnPath(float distance, float expectedX, float expectedY, float expectedAngle) { IPath shape = new RectangularePolygon(50, 50, 200, 60); var point = shape.PointAlongPath(distance); Assert.Equal(expectedX, point.Point.X); Assert.Equal(expectedY, point.Point.Y); Assert.Equal(expectedAngle, point.Angle); }
public void ClippingRectanglesCreateCorrectNumberOfPoints() { IEnumerable <ISimplePath> paths = new RectangularePolygon(10, 10, 40, 40).Clip(new RectangularePolygon(20, 0, 20, 20)).Flatten(); Assert.Equal(1, paths.Count()); var points = paths.First().Points; Assert.Equal(8, points.Count); }
public void Transform() { IPath shape = new RectangularePolygon(0, 0, 200, 60); IPath newShape = shape.Transform(new Matrix3x2(0, 1, 1, 0, 20, 2)); Assert.Equal(new PointF(20, 2), newShape.Bounds.Location); Assert.Equal(new SizeF(60, 200), newShape.Bounds.Size); }
public void LienearSegements() { IPath shape = new RectangularePolygon(10, 11, 12, 13).AsPath(); var segemnts = shape.Flatten().ToArray()[0].Points; Assert.Equal(new PointF(10, 11), segemnts[0]); Assert.Equal(new PointF(22, 11), segemnts[1]); Assert.Equal(new PointF(22, 24), segemnts[2]); Assert.Equal(new PointF(10, 24), segemnts[3]); }
public static IPathCollection BuildCorners(int imageWidth, int imageHeight, float cornerRadius) { var rect = new RectangularePolygon(-0.5f, -0.5f, cornerRadius, cornerRadius); IPath cornerToptLeft = rect.Clip(new EllipsePolygon(cornerRadius - 0.5f, cornerRadius - 0.5f, cornerRadius)); var center = new Vector2(imageWidth / 2F, imageHeight / 2F); float rightPos = imageWidth - cornerToptLeft.Bounds.Width + 1; float bottomPos = imageHeight - cornerToptLeft.Bounds.Height + 1; IPath cornerTopRight = cornerToptLeft.RotateDegree(90).Translate(rightPos, 0); IPath cornerBottomLeft = cornerToptLeft.RotateDegree(-90).Translate(0, bottomPos); IPath cornerBottomRight = cornerToptLeft.RotateDegree(180).Translate(rightPos, bottomPos); return(new PathCollection(cornerToptLeft, cornerBottomLeft, cornerTopRight, cornerBottomRight)); }
public static IPathCollection BuildCorners(int imageWidth, int imageHeight, float cornerRadius) { // first create a square var rect = new RectangularePolygon(-0.5f, -0.5f, cornerRadius, cornerRadius); // then cut out of the square a circle so we are left with a corner var cornerToptLeft = rect.Clip(new EllipsePolygon(cornerRadius - 0.5f, cornerRadius - 0.5f, cornerRadius)); // corner is now a corner shape positions top left //lets make 3 more positioned correctly, we can do that by translating the orgional around the center of the image var center = new Vector2(imageWidth / 2, imageHeight / 2); float rightPos = imageWidth - cornerToptLeft.Bounds.Width + 1; float bottomPos = imageHeight - cornerToptLeft.Bounds.Height + 1; // move it across the width of the image - the width of the shape var cornerTopRight = cornerToptLeft.RotateDegree(90).Translate(rightPos, 0); var cornerBottomLeft = cornerToptLeft.RotateDegree(-90).Translate(0, bottomPos); var cornerBottomRight = cornerToptLeft.RotateDegree(180).Translate(rightPos, bottomPos); return(new PathCollection(cornerToptLeft, cornerBottomLeft, cornerTopRight, cornerBottomRight)); }
public void Center() { RectangularePolygon shape = new RectangularePolygon(50, 50, 200, 60); Assert.Equal(new PointF(150, 80), shape.Center); }
public void Distance(TestPoint location, TestSize size, TestPoint point, float expectecDistance) { IPath shape = new RectangularePolygon(location, size); Assert.Equal(expectecDistance, shape.Distance(point).DistanceFromPath); }
public void ShapePaths() { IPath shape = new RectangularePolygon(10, 11, 12, 13); Assert.Equal(shape, shape.AsClosedPath()); }
public void PointInPolygon(TestPoint location, TestSize size, TestPoint point, bool isInside) { RectangularePolygon shape = new RectangularePolygon(location, size); Assert.Equal(isInside, shape.Contains(point)); }
private static IPath GetClippedRect(int imageWidth, int imageHeight, float cornerRadius) { var rect = new RectangularePolygon(-0.5f, -0.5f, imageWidth + 0.5f, imageHeight + 0.5f); return(rect.Clip(new EllipsePolygon(imageWidth * 0.5f, imageHeight * 0.5f, cornerRadius))); }
public void Left() { RectangularePolygon shape = new RectangularePolygon(10, 11, 12, 13); Assert.Equal(10, shape.Left); }
public void Right() { RectangularePolygon shape = new RectangularePolygon(10, 11, 12, 13); Assert.Equal(22, shape.Right); }
public void Bottom() { RectangularePolygon shape = new RectangularePolygon(10, 11, 12, 13); Assert.Equal(24, shape.Bottom); }
public void Top() { RectangularePolygon shape = new RectangularePolygon(10, 11, 12, 13); Assert.Equal(11, shape.Top); }
public void MaxIntersections_Shape() { IPath shape = new RectangularePolygon(10, 11, 12, 13); Assert.Equal(4, shape.MaxIntersections); }
public static IPath AsPath(this RectangularePolygon rect) { return((IPath)rect); }