Ejemplo n.º 1
0
 public static VisualAARectangle Create(RectangleAA2 rect, Pen pen = null, Brush brush = null)
 {
     return(new VisualAARectangle(rect)
     {
         Pen = pen,
         FillBrush = brush
     });
 }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
0
        [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);
        }
Ejemplo n.º 4
0
        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;
 }
Ejemplo n.º 6
0
 public VisualImage(Vector2 location, Image image)
 {
     _imageRect = new RectangleAA2(location.X, location.Y, 0, 0);
     Image      = image;
 }