Example #1
0
 def test_extent(self):
     s = Point(3, 9)
     e = Point(5, 1)
     tobj = Rectangle(s, e)
     self.assertEqual((2, 8), tobj.extent)
Example #2
0
 def test_height(self):
     s = Point(3, 9)
     e = Point(5, 1)
     tobj = Rectangle(s, e)
     self.assertEqual(8, tobj.height)
Example #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)
Example #4
0
 def on_drag(self, newPos):
     newPos = Point(newPos)
     logger.debug(f'Drag to pos={newPos}')
Example #5
0
 def test_width(self):
     s = Point(3, 9)
     e = Point(5, 1)
     tobj = Rectangle(s, e)
     self.assertEqual(2, tobj.width)
Example #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)
Example #7
0
 def f2():
     return Point((1, 2, 3))
Example #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))
Example #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)
Example #10
0
 def __init__(self, owner, startPos):
     self.owner = owner
     self.startPos = Point(startPos)
     logger.debug(f'Start Drp on pos={startPos}')
Example #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)))
Example #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()
Example #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)
Example #14
0
 def on_drop(self, dropPos):
     dropPos = Point(dropPos)
     rPos = self.owner.transposeBack(dropPos)
     logger.debug(f'Drop on pos={dropPos}  rPos={rPos}')
Example #15
0
 def test_center(self):
     tobj = Rectangle([100, 100], [300, 300])
     center = tobj.center()
     self.assertEqual(Point(200, 200), center)
Example #16
0
 def test_init(self):
     tobj = Point(5, 9)
     self.assertIsNotNone(tobj)
     self.assertEqual(5, tobj.x)
     self.assertEqual(9, tobj.y)
Example #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)
Example #18
0
 def test_ng(self):
     p1 = Point(1, 3)
     tobj = -p1
     self.assertEqual(Point(1, 3), p1)
     self.assertEqual(Point(-1, -3), tobj)
Example #19
0
 def f1():
     return Point({'x': 3, 'y': 4})
Example #20
0
 def test_init_Rectangle(self):
     oRect = Rectangle((1, 3, 5, 9))
     tobj = Rectangle(oRect)
     self.assertEqual(tobj.start, Point(1, 3))
Example #21
0
 def test_xy(self):
     tobj = Point(5, 9)
     self.assertEqual((5, 9), tobj.xy)
Example #22
0
 def __init__(self, start, end):
     super().__init__()
     self.start = Point(start)
     self.end = Point(end)