Esempio n. 1
0
    def next_state(self, state: MouseState) -> ResultE[MouseState]:
        i = mouse.activeInputs

        pos = Point2D.from_tuple(mouse.position)
        buttons = set(filter(lambda b: b.event in i and KX_INPUT_ACTIVE in i[b.event].status, MouseButton))

        return Result.from_value(MouseState(pos, buttons))
Esempio n. 2
0
 def moved_to(x, y):
     return MouseMoveEvent(comp, MouseState(Point2D(x, y), set()))
Esempio n. 3
0
 def state_of(x, y, *args):
     return Result.from_value(MouseState(Point2D(x, y), set(args)))
Esempio n. 4
0
 def clicked_at(x, y, button, buttons):
     return MouseUpEvent(comp, MouseState(Point2D(x, y), buttons), button)
Esempio n. 5
0
 def init_state(self) -> ResultE[MouseState]:
     return Result.from_value(MouseState(Point2D(0.5, 0.5), set()))
Esempio n. 6
0
def test_point2d_iter():
    components = [p for p in Point2D(20, 5)]
    assert components == [20, 5]
Esempio n. 7
0
def test_point2d_copy():
    assert Point2D(3, 2) == Point2D(1, 5).copy(x=3, y=2)
    assert Point2D(3, 5) == Point2D(1, 5).copy(x=3)
    assert Point2D(1, 2) == Point2D(1, 5).copy(y=2)
    assert Point2D(1, 5) == Point2D(1, 5).copy()
Esempio n. 8
0
def test_point2d_from_tuple():
    assert Point2D.from_tuple((3, 2)) == Point2D(3, 2)
Esempio n. 9
0
def test_point2d_init():
    point = Point2D(10.5, -20.2)

    assert point.x == 10.5
    assert point.y == -20.2
Esempio n. 10
0
def test_point2d_to_tuple():
    assert Point2D(3, 2).tuple == (3, 2)
Esempio n. 11
0
def test_point2d_operations():
    assert Point2D(-10, 6) + Point2D(5, 2) == Point2D(-5, 8)
    assert Point2D(6.3, 0) - Point2D(2.3, 2.5) == Point2D(4., -2.5)
    assert Point2D(3, 5) * -2 == Point2D(-6, -10)
    assert Point2D(10.4, -3) / 2 == Point2D(5.2, -1.5)

    assert -Point2D(3, -6) == Point2D(-3, 6)
Esempio n. 12
0
def test_point2d_unpack():
    (x, y) = Point2D(20.2, 15.3)

    assert x == 20.2
    assert y == 15.3