public static VisualAARectangle Create(RectangleAA2 rect, Pen pen = null, Brush brush = null) { return(new VisualAARectangle(rect) { Pen = pen, FillBrush = brush }); }
public void Constructor(string locationStr, string sizeStr) { var location = Vector2.Parse(locationStr); var size = SizeD.Parse(sizeStr); var rect = new RectangleAA2(location, size); Assert.AreEqual(location, rect.Location); Assert.AreEqual(size.Width, rect.Width); Assert.AreEqual(size.Height, rect.Height); }
[TestCase("40, 50", "10, 10", "(10, 20),(60, 70)", true)] // Above the line public void CollisionWithLine2(string locationStr, string sizeStr, string lineStr, bool expectedCollision) { var location = Vector2.Parse(locationStr); var size = SizeD.Parse(sizeStr); var rect = new RectangleAA2(location, size); var line = LineSegment2.Parse(lineStr); var hasCollision = rect.HasCollision(line); Assert.AreEqual(expectedCollision, hasCollision); }
public void ToLinesTest() { var rect = new RectangleAA2(new Vector2(10, 10), new SizeD(20, 20)); var lines = rect.ToLines(); var bottom = new LineSegment2(new Vector2(10, 10), new Vector2(30, 10)); var top = new LineSegment2(new Vector2(30, 30), new Vector2(10, 30)); var right = new LineSegment2(new Vector2(30, 10), new Vector2(30, 30)); var left = new LineSegment2(new Vector2(10, 30), new Vector2(10, 10)); Assert.True((from l in lines where l.Equals(bottom) select l).Any()); Assert.True((from l in lines where l.Equals(top) select l).Any()); Assert.True((from l in lines where l.Equals(right) select l).Any()); Assert.True((from l in lines where l.Equals(left) select l).Any()); }
public VisualAARectangle(RectangleAA2 geometry) { _rectangle = geometry; }
public VisualImage(Vector2 location, Image image) { _imageRect = new RectangleAA2(location.X, location.Y, 0, 0); Image = image; }