def test_animationgroup_with_wait(using_opengl_renderer): sqr = Square() sqr_anim = FadeIn(sqr) wait = Wait() animation_group = AnimationGroup(wait, sqr_anim, lag_ratio=1) animation_group.begin() timings = animation_group.anims_with_timings assert timings == [(wait, 0.0, 1.0), (sqr_anim, 1.0, 2.0)]
def generate_squares(self, iteration): squares = [] for a in range(-iteration-1, iteration+1): b1 = iteration - math.floor(abs(a + 0.5)) b2 = -iteration + math.floor(abs(a + 0.5)) - 1 squares.append(self._generate_open_square([(a+0.5) * self.scale, (b1+0.5) * self.scale, 0])) squares.append(self._generate_open_square([(a+0.5) * self.scale, (b2+0.5) * self.scale, 0])) if self.SQUARE_CREATE_ANIM is not None and self.SQUARE_CREATE_RUNTIME > 0: return LaggedStart(*(self.SQUARE_CREATE_ANIM(v, rate_func=self.SQUARE_CREATE_RATE_FUNC) for v in squares), lag_ratio=self.SQUARE_LAG_RATIO) else: # Instantly show. return LaggedStart(*(FadeIn(v, rate_func=lambda t: 1) for v in squares), lag_ratio=self.SQUARE_LAG_RATIO)
def test_succession_timing(): """Test timing of animations in a succession.""" line = Line() animation_1s = FadeIn(line, shift=UP, run_time=1.0) animation_4s = FadeOut(line, shift=DOWN, run_time=4.0) succession = Succession(animation_1s, animation_4s) assert succession.get_run_time() == 5.0 succession.begin() assert succession.active_index == 0 # The first animation takes 20% of the total run time. succession.interpolate(0.199) assert succession.active_index == 0 succession.interpolate(0.2) assert succession.active_index == 1 succession.interpolate(0.8) assert succession.active_index == 1 # At 100% and more, no animation must be active anymore. succession.interpolate(1.0) assert succession.active_index == 2 assert succession.active_animation is None succession.interpolate(1.2) assert succession.active_index == 2 assert succession.active_animation is None