def make_frame(self, time_decimal): """ render frame :param time_decimal: time in seconds :return: 3d numpy array """ time_decimal = time_decimal + self.offset time = time_decimal * 1000 - self.minimum surface = gizeh.Surface(WIDTH + PADDING * 2, HEIGHT + PADDING * 2) cords = get_action_at_time(self.replay, time) left = (.2, 0, 0) right = (.2, 0, 0) click = cords["clicks"] if click in [1, 5, 15]: left = (.9, 0, 0) if click in [2, 10, 15]: right = (.9, 0, 0) size_multiplier = 1.15 if click else 1 mouse = gizeh.circle(10 * size_multiplier, xy=(cords["x pos"] + PADDING, cords["y pos"] + PADDING), fill=(1, 0, 0), stroke=(0, 1, 0), stroke_width=2) sqrl = gizeh.square(l=30, fill=left, xy=(surface.width - 60, surface.height - 24)) sqrr = gizeh.square(l=30, fill=right, xy=(surface.width - 25, surface.height - 24)) clicks = gizeh.Group([sqrl, sqrr]) render_objects = list() for i in self.objects: if i.appear <= time: i.visable = True if i.disappear <= time: i.visable = False if i.visable: render_objects.extend(i.render(time)) hit_objects = gizeh.Group(render_objects) hit_objects.draw(surface) mouse.draw(surface) clicks.draw(surface) return surface.get_npimage()
def test_largest_equals(self): test = get_action_at_time(self.data, 300) self.assertEqual((test == self.data.iloc[-1]).all(), True)
def test_smallest_equals(self): test = get_action_at_time(self.data, -123) self.assertEqual((test == self.data.iloc[0]).all(), True)
def test_bigger_then(self): test = get_action_at_time(self.data, 400) self.assertEqual((test == self.data.iloc[8]).all(), True)
def test_round_down(self): test = get_action_at_time(self.data, 140) self.assertEqual((test == self.data.iloc[7]).all(), True)
def test_smaller_then(self): test = get_action_at_time(self.data, -200) self.assertEqual((test == self.data.iloc[0]).all(), True)