示例#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))
示例#2
0
 def moved_to(x, y):
     return MouseMoveEvent(comp, MouseState(Point2D(x, y), set()))
示例#3
0
 def state_of(x, y, *args):
     return Result.from_value(MouseState(Point2D(x, y), set(args)))
示例#4
0
 def clicked_at(x, y, button, buttons):
     return MouseUpEvent(comp, MouseState(Point2D(x, y), buttons), button)
示例#5
0
 def init_state(self) -> ResultE[MouseState]:
     return Result.from_value(MouseState(Point2D(0.5, 0.5), set()))
示例#6
0
def test_point2d_iter():
    components = [p for p in Point2D(20, 5)]
    assert components == [20, 5]
示例#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()
示例#8
0
def test_point2d_from_tuple():
    assert Point2D.from_tuple((3, 2)) == Point2D(3, 2)
示例#9
0
def test_point2d_init():
    point = Point2D(10.5, -20.2)

    assert point.x == 10.5
    assert point.y == -20.2
示例#10
0
def test_point2d_to_tuple():
    assert Point2D(3, 2).tuple == (3, 2)
示例#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)
示例#12
0
def test_point2d_unpack():
    (x, y) = Point2D(20.2, 15.3)

    assert x == 20.2
    assert y == 15.3