def do_fatetell_anim(self): self.ft_anim = True self.question_scale = ChainInterp( SineInterp(0.0, 1.0, 0.1), CosineInterp(1.0, 0.0, 0.1), FixedInterp(0.0, 0.2), SineInterp(0.0, 1.0, 0.1), CosineInterp(1.0, 0.0, 0.1), FixedInterp(0.0, 0.2), SineInterp(0.0, 1.0, 0.1) ) self.back_scale = ChainInterp( FixedInterp(0.0, 0.2), SineInterp(0.0, 1.0, 0.1), CosineInterp(1.0, 0.0, 0.1), FixedInterp(0.0, 0.2), SineInterp(0.0, 1.0, 0.1), CosineInterp(1.0, 0.0, 0.1), ) self.ftanim_alpha = ChainInterp( FixedInterp(1.0, 1.0), LinearInterp(1.0, 0.0, 2.0), on_done=self._end_ft_anim, ) self.ftanim_cardalpha = ChainInterp( FixedInterp(0.0, 1.0), FixedInterp(1.0, 0.0), )
def update(self): fsz = self.fold_size n = len(self.control_list) width = min(fsz*35.0, n*35.0) step = int((width - 34) / (n - 1)) if n > 1 else 0 for i, c in enumerate(self.control_list): c.zindex = i c.x = SineInterp(c.x, 2 + step * i, 0.4) c.y = SineInterp(c.y, 0, 0.4)
def update(self): for j, l in enumerate(reversed(self.sprites)): for i, cs in enumerate(l): nx, ny = self._to_loc(i, j) cs.x = SineInterp(cs.x, nx, 0.3) cs.y = SineInterp(cs.y, ny, 0.3) self.update_sprite(cs, i, j) self.dispatch_event('on_update')
def update(self): csl = self.control_list if not csl: return n = len(csl) w, h, = self.width, self.height offs = 20 csw = offs * (n-1) + 93 cor_x, cor_y = (w - csw)/2, (h - 125)/2 for i, cs in enumerate(csl): cs.x = SineInterp(cs.x, i*offs + cor_x, 0.6) cs.y = SineInterp(cs.y, cor_y, 0.6)
def update(self): fsz = self.fold_size n = len(self.control_list) width = min(fsz * 93.0 + 42, n * 93.0) step = (width - 91)/(n - 1) if n > 1 else 0 for i, c in enumerate(self.control_list): c.zindex = i try: sel = c.hca_selected except AttributeError: sel = c.hca_selected = False c.x = SineInterp(c.x, 2 + int(step * i), 0.6) c.y = SineInterp(c.y, 20 if sel else 0, 0.6)
def arrange(self): csl = self.control_list if not csl: return n = len(csl) w, h, = self.width, self.height offs = 20 csw = offs * (n-1) + 93 cor_x, cor_y = (w - csw)/2, (h - 125)/2 for i, cs in enumerate(csl): if isinstance(getinterp(cs, 'x'), AbstractInterp): cs.x = SineInterp(cs.x, i*offs + cor_x, 0.6) cs.y = SineInterp(cs.y, cor_y, 0.6) else: cs.x, cs.y = i*offs + cor_x, cor_y
def update(self): fsz = self.fold_size n = len(self.control_list) width = min(fsz*93.0, n*93.0) step = (width - 91)/(n-1) if n > 1 else 0 if step < 30: step = 30 width = (n-1)*30 + 93 ox = (self.width - width) // 2 for i, c in enumerate(self.control_list): c.zindex = i c.x = SineInterp(c.x, 2 + ox + int(step * i), 0.5) c.y = SineInterp(c.y, 0, 0.5)
def animate_to(self, x, y): tx = SineInterp(self.x, x, 1) ty = SineInterp(self.y, y, 1) pca = self.portcard_area def _update(dt): if tx.finished: pyglet.clock.unschedule(_update) self.identity_btn.update() return pca.x = x pca.y = y self.set_position(tx.value, ty.value) pyglet.clock.schedule_interval_soft(_update, 1 / 60.0)
def __init__(self, x0, y0, x1, y1, *args, **kwargs): Control.__init__(self, *args, **kwargs) from math import sqrt, atan2, pi self.x, self.y = x0, y0 dx, dy = x1 - x0, y1 - y0 scale = sqrt(dx * dx + dy * dy) / L('c-ray').width self.angle = atan2(dy, dx) / pi * 180 self.scale = SineInterp(0.0, scale, 0.4) self.alpha = ChainInterp(FixedInterp(1.0, 1), CosineInterp(1.0, 0.0, 0.5), on_done=lambda self, desc: self.delete())
def toggle(self, c, t): s = c.hca_selected = not c.hca_selected c.y = SineInterp(c.y, 20 if s else 0, t) self.view.selection_change.notify()
def on_mouse_leave(self, x, y): self.shine_alpha = SineInterp(1.0, 0.0, 0.3)
def toggle(self, c, t): s = c.hca_selected = not c.hca_selected c.y = SineInterp(c.y, 20 if s else 0, t) self.dispatch_event('on_selection_change')