Exemplo n.º 1
0
 def test_extent(self):
     s = Point(3, 9)
     e = Point(5, 1)
     tobj = Rectangle(s, e)
     self.assertEqual((2, 8), tobj.extent)
Exemplo n.º 2
0
 def test_height(self):
     s = Point(3, 9)
     e = Point(5, 1)
     tobj = Rectangle(s, e)
     self.assertEqual(8, tobj.height)
Exemplo n.º 3
0
 def test_init_tuple(self):
     tobj = Point((5, 9), 27)
     self.assertIsNotNone(tobj)
     self.assertEqual(5, tobj.x)
     self.assertEqual(9, tobj.y)
Exemplo n.º 4
0
 def on_drag(self, newPos):
     newPos = Point(newPos)
     logger.debug(f'Drag to pos={newPos}')
Exemplo n.º 5
0
 def test_width(self):
     s = Point(3, 9)
     e = Point(5, 1)
     tobj = Rectangle(s, e)
     self.assertEqual(2, tobj.width)
Exemplo n.º 6
0
 def test_init_Point(self):
     pt = Point(7.0, 13.78)
     tobj = Point(pt)
     self.assertIsNotNone(tobj)
     self.assertEqual(7, tobj.x)
     self.assertEqual(13.78, tobj.y)
Exemplo n.º 7
0
 def f2():
     return Point((1, 2, 3))
Exemplo n.º 8
0
    def test_transpose_back(self):
        src = Rectangle([100, 100, 300, 200])
        dst = Rectangle([10, 10, 210, 110])
        ctx = DrawingContext(src, dst, border=0)
        self.assertEqual(Point(100, 100), ctx.transposeBack(Point(10, 10)))
        self.assertEqual(Point(300, 200), ctx.transposeBack(Point(210, 110)))

        for src in [Point(100, 100), Point(300, 200)]:
            self.assertEqual(src, ctx.transposeBack(ctx.transpose(src)))

        ctx = DrawingContext(src, dst, border=0.1)
        for src in [Point(100, 100), Point(300, 200)]:
            self.assertEqual(src, ctx.transposeBack(ctx.transpose(src)))

        ctx = DrawingContext(src, dst, border=0.5)
        for src in [Point(100, 100), Point(300, 200)]:
            self.assertEqual(src, ctx.transposeBack(src))

        ctx = DrawingContext(src, dst, border=1)
        for src in [Point(100, 100), Point(300, 200)]:
            p = ctx.transposeBack(ctx.transpose(src))
            x, y = round(p.x), round(p.y)
            self.assertEqual(src, Point(x, y))
Exemplo n.º 9
0
 def test_div(self):
     p1 = Point(1, 3)
     tobj = p1 / 2
     self.assertEqual(Point(0.5, 1.5), tobj)
     tobj = p1 / Point(3, 2)
     self.assertEqual(Point(1 / 3, 3 / 2), tobj)
Exemplo n.º 10
0
 def __init__(self, owner, startPos):
     self.owner = owner
     self.startPos = Point(startPos)
     logger.debug(f'Start Drp on pos={startPos}')
Exemplo n.º 11
0
    def test_transpose(self):
        src = Rectangle([100, 100, 300, 200])
        dst = Rectangle([10, 10, 210, 110])
        ctx = DrawingContext(src, dst, border=0)
        self.assertEqual(Point(10, 10), ctx.transpose(Point(100, 100)))
        self.assertEqual(Point(210, 110), ctx.transpose(Point(300, 200)))

        ctx = DrawingContext(src, dst, border=0.1)
        self.assertEqual(Point(30, 20), ctx.transpose(Point(100, 100)))
        self.assertEqual(Point(190, 100), ctx.transpose(Point(300, 200)))

        ctx = DrawingContext(src, dst, border=0.5)
        self.assertEqual(Point(110, 60), ctx.transpose(Point(100, 100)))
        self.assertEqual(Point(110, 60), ctx.transpose(Point(300, 200)))

        ctx = DrawingContext(src, dst, border=1)
        self.assertEqual(Point(210, 110), ctx.transpose(Point(100, 100)))
        self.assertEqual(Point(10, 10), ctx.transpose(Point(300, 200)))
Exemplo n.º 12
0
 def on_drop(self, dropPos):
     dropPos = Point(dropPos)
     rPos = self.owner.transposeBack(dropPos)
     logger.debug(f'Drop on pos={dropPos}  rPos={rPos}')
     self.lineObj.end = rPos
     self.owner.redraw()
Exemplo n.º 13
0
 def on_drag(self, newPos):
     newPos = Point(newPos)
     sx, sy = self.startPos.xy
     ex, ey = newPos.xy
     self.owner.coords(self.lineObj.widget, sx, sy, ex, ey)
Exemplo n.º 14
0
 def on_drop(self, dropPos):
     dropPos = Point(dropPos)
     rPos = self.owner.transposeBack(dropPos)
     logger.debug(f'Drop on pos={dropPos}  rPos={rPos}')
Exemplo n.º 15
0
 def test_center(self):
     tobj = Rectangle([100, 100], [300, 300])
     center = tobj.center()
     self.assertEqual(Point(200, 200), center)
Exemplo n.º 16
0
 def test_init(self):
     tobj = Point(5, 9)
     self.assertIsNotNone(tobj)
     self.assertEqual(5, tobj.x)
     self.assertEqual(9, tobj.y)
Exemplo n.º 17
0
 def test_init_float(self):
     tobj = Point(5.0, 3)
     self.assertIsNotNone(tobj)
     self.assertEqual(5, tobj.x)
     self.assertEqual(3, tobj.y)
Exemplo n.º 18
0
 def test_ng(self):
     p1 = Point(1, 3)
     tobj = -p1
     self.assertEqual(Point(1, 3), p1)
     self.assertEqual(Point(-1, -3), tobj)
Exemplo n.º 19
0
 def f1():
     return Point({'x': 3, 'y': 4})
Exemplo n.º 20
0
 def test_init_Rectangle(self):
     oRect = Rectangle((1, 3, 5, 9))
     tobj = Rectangle(oRect)
     self.assertEqual(tobj.start, Point(1, 3))
Exemplo n.º 21
0
 def test_xy(self):
     tobj = Point(5, 9)
     self.assertEqual((5, 9), tobj.xy)
Exemplo n.º 22
0
 def __init__(self, start, end):
     super().__init__()
     self.start = Point(start)
     self.end = Point(end)