Exemplo n.º 1
0
 def test_ctor2i(self):
     b = d.BBox2i(d.ivec2(0, 1))
     self.assertEqual(b.min, d.ivec2(0, 1))
     self.assertEqual(b.max, d.ivec2(0, 1))
     b = d.BBox2i(d.ivec2(0, 1), d.ivec2(2, 3))
     self.assertEqual(b.min, d.ivec2(0, 1))
     self.assertEqual(b.max, d.ivec2(2, 3))
     b = d.BBox2i(0, 1, 2, 3)
     self.assertEqual(b.min, d.ivec2(0, 1))
     self.assertEqual(b.max, d.ivec2(1, 3))
Exemplo n.º 2
0
 def test_components2i(self):
     b = d.BBox2i(0, 1, 2, 3)
     self.assertEqual(b.x(), 0)
     self.assertEqual(b.y(), 1)
     self.assertEqual(b.w(), 2)
     self.assertEqual(b.h(), 3)
     self.assertTrue(b.isValid())
     b.max = d.ivec2(0, 0)
     self.assertFalse(b.isValid())
     b = d.BBox2i(0, 1, 2, 4)
     self.assertEqual(d.ivec2(2, 4), b.getSize())
     self.assertEqual(d.ivec2(1, 3), b.getCenter())
     self.assertEqual(8, b.getArea())
     self.assertEqual(0.5, b.getAspect())
     b.zero()
     self.assertEqual(d.ivec2(0, 0), b.min)
     self.assertEqual(d.ivec2(0, 0), b.max)
Exemplo n.º 3
0
 def test_ivec2(self):
     v = d.ivec2(1, 2)
     self.assertTrue(v.x, 1)
     self.assertTrue(v.y, 2)
     v.x = 3
     v.y = 4
     self.assertTrue(v.x, 3)
     self.assertTrue(v.y, 4)
Exemplo n.º 4
0
 def test_BBox2i(self):
     bb = d.BBox2i(d.ivec2(1, 2))
     self.assertEqual(bb.min, d.ivec2(1, 2))
     self.assertEqual(bb.max, d.ivec2(1, 2))
     bb = d.BBox2i(d.ivec2(1, 2), d.ivec2(3, 4))
     self.assertEqual(bb.min, d.ivec2(1, 2))
     self.assertEqual(bb.max, d.ivec2(3, 4))
     bb = d.BBox2i(1, 2, 3, 4)
     self.assertEqual(bb.min, d.ivec2(1, 2))
     self.assertEqual(bb.max, d.ivec2(3, 5))
     self.assertTrue(bb.isValid())
     bb.min = d.ivec2(3, 4)
     bb.max = d.ivec2(1, 2)
     self.assertEqual(bb, d.BBox2i(d.ivec2(3, 4), d.ivec2(1, 2)))
     self.assertFalse(bb.isValid())
     bb = d.BBox2i(1, 2, 3, 4)
     self.assertEqual(bb.x(), 1)
     self.assertEqual(bb.y(), 2)
     self.assertEqual(bb.w(), 3)
     self.assertEqual(bb.h(), 4)
     self.assertEqual(bb.getSize().x, 3)
     self.assertEqual(bb.getSize().y, 4)
     self.assertEqual(bb.getCenter().x, 2)
     self.assertEqual(bb.getCenter().y, 3)
     self.assertEqual(bb.getArea(), 12)
     print("Aspect =", bb.getAspect())
     bb.zero()
     self.assertEqual(bb, d.BBox2i(d.ivec2(0, 0), d.ivec2(0, 0)))
     self.assertTrue(d.BBox2i(1, 2, 3, 4).intersects(d.BBox2i(2, 3, 3, 4)))
     self.assertFalse(d.BBox2i(1, 2, 3, 4).intersects(d.BBox2i(5, 6, 3, 4)))