def rocketFlyAnimationTransition(progress: float) -> float: p: float = progress * 2 if p < 1: t: float = AnimationTransition.out_expo(p) / 2 else: t: float = AnimationTransition.in_quint(p) / 2 return t
def on_progress(self, t): oquad = AnimationTransition.out_quad iquad = AnimationTransition.in_quad #t = t * 10 if t < .1 else 1 #t = .7 #t = AnimationTransition.out_quad(t) self.cy_x = funcLinear(AnimationTransition.in_out_cubic(t), self.screen_in.width, self.screen_in.width / 2. + 10) d = 0.7 if t < d: self.cy_radius = funcLinear(oquad(t / d), 10., 50.) self.c_backshadow['opacity'] = 1 else: t2 = (t - d) / (1. - d) self.cy_radius = funcLinear(iquad(t2), 50., 0.01) d = 0.9 if t > d: t2 = (t - d) / (1. - d) self.c_backshadow['opacity'] = funcLinear(t2, 1., 0.) d1 = 0.3 d2 = 0.5 f1 = AnimationTransition.in_out_sine f2 = AnimationTransition.in_sine if t < d1: d = d1 di = f1(t / d) self.cy_dir = pi / 2. - di / 2. elif t < d2: pass else: d = d2 t2 = (t - d) / (1. - d) di = f2(1 - t2) self.cy_dir = pi / 2. - di / 2. self.update_glsl() return # old flip d = 0.8 if t < d: dt = t / d self.cy_dir = funcLinear(AnimationTransition.out_circ(dt), 0, 1.55) else: self.cy_dir = 1.5 self.cy_x = funcLinear(t, self.screen_in.width, -self.screen_in.width / 2.0) self.update_glsl()
def on_progress(self, t): d = 0.8 if t < d: dt = t / d self.cy_dir = funcLinear(AnimationTransition.out_circ(dt), 0, 1.55) else: self.cy_dir = 1.5 self.cy_x = funcLinear(t, self.screen_in.width, -self.screen_in.width / 2.0) self.update_glsl()
def on_time(self, instance, t): t = self.time d = 0.8 if t < d: dt = t / d self.cy_dir = funcLinear(AnimationTransition.out_circ(dt), 0, 1.55) else: self.cy_dir = 1.55 self.cy_x = funcLinear(t, self.width, -self.width / 2.0)
def comes_and_go(points, alpha): x = AnimationTransition.in_out_quad(alpha) x0, y0, x1, y1 = points h = (y1 - y0) * (1 - 2 * abs(x - .5)) center_y = (y0 + y1) / 2 w = (x1 - x0) * (1 - 2 * abs(x - .5)) center_x = (x0 + x1) / 2 return (center_x - w / 2, center_y - h / 2, center_x + w / 2, center_y - h / 2, center_x + w / 2, center_y + h / 2, center_x - w / 2, center_y + h / 2)
def on_progress(self, progression: float) -> NoReturn: progression = AnimationTransition.out_quad(progression) if self._direction == "up": self.screen_in.y = (self.manager.y + self.manager.height * progression) - self.screen_in.height self.screen_in.opacity = progression if self._direction == "down": self.screen_out.y = (self.manager.y - self.manager.height * progression) self.screen_out.opacity = 1 - progression
def bouncey(points, alpha): x = AnimationTransition.out_elastic(alpha) x0, y0, x1, y1 = points h = (y1 - y0) * x # tend to correct height, from 0 w = (x1 - x0) * (2 - x) return ( x0 + w * (1 - alpha * alpha), y0, x0 + w * (1 - alpha * alpha) + w, y0, x0 + w * (1 - alpha * alpha) + w, y0 + h, x0 + w * (1 - alpha * alpha), y0 + h, )
def pop_in(points, alpha): x = AnimationTransition.out_elastic(alpha) x0, y0, x1, y1 = points h = (y1 - y0) * x # tend to correct height, from 0 w = (x1 - x0) * x cx = (x0 + x1) / 2 return ( cx - w * .5, y0, cx + w * .5, y0, cx + w * .5, y0 + h, cx - w * .5, y0 + h, )
def sky_down(points, alpha): x = AnimationTransition.out_quad(alpha) x0, y0, x1, y1 = points h = (y1 - y0) * (4 - 3 * x) # tend to correct height, from 0 w = (x1 - x0) * (x) cx = (x0 + x1) / 2 return ( cx - w * .5, y0, cx + w * .5, y0, cx + w * .5, y0 + h, cx - w * .5, y0 + h, )
def comes_and_go(points, alpha): x = AnimationTransition.in_out_quad(alpha) x0, y0, x1, y1 = points h = (y1 - y0) * (1 - 2 * abs(x - .5)) center_y = (y0 + y1) / 2 w = (x1 - x0) * (1 - 2 * abs(x - .5)) center_x = (x0 + x1) / 2 return ( center_x - w / 2, center_y - h / 2, center_x + w / 2, center_y - h / 2, center_x + w / 2, center_y + h / 2, center_x - w / 2, center_y + h / 2 )
def roll_in(points, alpha): x0, y0, x1, y1 = points x = AnimationTransition.out_quad(alpha) H = (y1 - y0) W = (x1 - x0) h = H * x w = W * x h2 = h / 2 w2 = w / 2 cx = (x0 + x1) / 2 + H * (1 - x) cy = (y0 + y1) / 2 - H * .4 * (1 - x) a = pi * x pi4 = pi / 4 return ( cx + cos(a + 1 * pi4) * w2, cy + sin(a + 1 * pi4) * h2, cx + cos(a + 3 * pi4) * w2, cy + sin(a + 3 * pi4) * h2, cx + cos(a + 5 * pi4) * w2, cy + sin(a + 5 * pi4) * h2, cx + cos(a + 7 * pi4) * w2, cy + sin(a + 7 * pi4) * h2, )
stop_property(widget, 'x') #para e remove a propriedade da animacao do widget cancel_property(widget, 'y') #para e remove a propriedade da animacao do widget anim.duration = 2.0 # tempo duracao de animacao anim.transition = 'in_quad' # funcao de transicao, pode ser da propeia classe que vc criou anim.step = 1.0 / 30.0 # 30 FPS na animacao anim.have_properties_to_animate #retona true se widget tem uma animacao #EVENTOS anim.on_start #dispara quando a niamacaoe iniciada anim.on_complete #dispara quandoa animacao termina anim.on_progress #dispara euqnato a animcao seta sendo executada # OBJETO DE TRANSICAO DE COMO A ANIMACAO E FEITA from kivy.animation import AnimationTransition at = AnimationTransition() #transicao padrao do KIVY anim.transition = 'linear' anim.transition = 'in_back' anim.transition = 'in_bounce' anim.transition = 'in_circ' anim.transition = 'in_cubic' anim.transition = 'in_elastic' anim.transition = 'in_expo' anim.transition = 'in_quad' anim.transition = 'in_quart' anim.transition = 'in_quint' anim.transition = 'in_sine'