def __call__( self, duration, var, v1, v2 = None, **params ): kw = self.params.copy() kw.update( params ) type = var.type now = anim.get(var) if kw.has_key('rel') and kw['rel']: if v2 is None: start, end = now, now+v1 else: start, end = now+v1, now+v2 else: if v2 is None: start, end = now, v1 else: start, end = v1, v2 if not kw.has_key('style'): style = _LinearTransition else: try: style = Transition.styles[kw['style']] except KeyError: raise ValueError, "unknown transition style \"%s\"" % kw['style'] starttime = anim.current_time() interp = style( starttime, duration, start, end, kw, type ) if duration > 0.0: var.add_span( starttime, starttime+duration, interp ) var.add_span( starttime+duration, None, end ) anim.advance_clock( duration )
def __call__(self, duration, var, v1, v2=None, **params): kw = self.params.copy() kw.update(params) type = var.type now = anim.get(var) if kw.has_key('rel') and kw['rel']: if v2 is None: start, end = now, now + v1 else: start, end = now + v1, now + v2 else: if v2 is None: start, end = now, v1 else: start, end = v1, v2 if not kw.has_key('style'): style = _LinearTransition else: try: style = Transition.styles[kw['style']] except KeyError: raise ValueError, "unknown transition style \"%s\"" % kw[ 'style'] starttime = anim.current_time() interp = style(starttime, duration, start, end, kw, type) if duration > 0.0: var.add_span(starttime, starttime + duration, interp) var.add_span(starttime + duration, None, end) anim.advance_clock(duration)
def __init__(self): super(RenderShipEcsComponent, self).__init__() self.spr = pyglet.sprite.Sprite(img.get(img.IMG_SHIP)) self.thrust_spr = pyglet.sprite.Sprite(anim.get(anim.ANIM_THRUST)) self.thrust_cooldown = 0
def __init__(self, x, y, name): super(RenderAnimationEcsComponent, self).__init__() self.anim = pyglet.sprite.Sprite(anim.get(name)) self.anim.x = x self.anim.y = y self.anim.on_animation_end = self.on_animation_end self.ended = False
def remove_item( self, duration = 0.0, trans = transition.default ): if anim.defining_animation(): before = anim.get( self.items ) if not before: return if duration: trans( duration, self.show, len(before)-1 ) anim.set( self.items, before[:-1] ) else: self._startitemlist.pop()
def remove_item(self, duration=0.0, trans=transition.default): if anim.defining_animation(): before = anim.get(self.items) if not before: return if duration: trans(duration, self.show, len(before) - 1) anim.set(self.items, before[:-1]) else: self._startitemlist.pop()
def add_item( self, level, text, duration = 0.0, trans = transition.default ): if anim.defining_animation(): before = anim.get( self.items ) after = before + [(level,text)] anim.set( self.items, after ) if duration: trans( duration, self.show, len(after) ) else: anim.set( self.show, len(after) ) else: self._startitemlist.append( (level, text) )
def add_item(self, level, text, duration=0.0, trans=transition.default): if anim.defining_animation(): before = anim.get(self.items) after = before + [(level, text)] anim.set(self.items, after) if duration: trans(duration, self.show, len(after)) else: anim.set(self.show, len(after)) else: self._startitemlist.append((level, text))
def parse_dictionary( self, kw ): if not kw.has_key( 'style' ): # the default style style = _SineWave else: try: style = Undulation.styles[kw['style']] except KeyError: raise ValueError, "unknown undulation style \"%s\"" % kw['style'] d = kw.has_key( 'duration' ) p = kw.has_key( 'period' ) c = kw.has_key( 'cycles' ) if d: duration = kw['duration'] if p and not c: period = kw['period'] elif c and not p: period = duration / kw['cycles'] else: raise ValueError, "undulation must specify exactly two of {period,duration,cycles} or period only" elif p and c: period = kw['period'] duration = period * kw['cycles'] elif p: period = kw['period'] duration = None else: raise ValueError, "undulation must specify exactly two of {period,duration,cycles} or period only" n = kw.has_key( 'min' ) x = kw.has_key( 'max' ) m = kw.has_key( 'mean' ) a = kw.has_key( 'amplitude' ) if n + x + m + a != 2: raise ValueError, "undulation must specify exactly two of {min,max,mean,amplitude}" if n: min = kw['min'] if x: max = kw['max'] elif m: max = 2 * kw['mean'] - min else: max = min + 2 * kw['amplitude'] elif x: max = kw['max'] if m: min = 2 * kw['mean'] - max else: min = max - 2 * kw['amplitude'] else: min = kw['mean'] - kw['amplitude'] max = kw['mean'] + kw['amplitude'] if kw.has_key( 'relative' ) and kw['relative']: min += anim.get(var) return style, period, duration, min, max
def parse_dictionary(self, kw): if not kw.has_key('style'): # the default style style = _SineWave else: try: style = Undulation.styles[kw['style']] except KeyError: raise ValueError, "unknown undulation style \"%s\"" % kw[ 'style'] d = kw.has_key('duration') p = kw.has_key('period') c = kw.has_key('cycles') if d: duration = kw['duration'] if p and not c: period = kw['period'] elif c and not p: period = duration / kw['cycles'] else: raise ValueError, "undulation must specify exactly two of {period,duration,cycles} or period only" elif p and c: period = kw['period'] duration = period * kw['cycles'] elif p: period = kw['period'] duration = None else: raise ValueError, "undulation must specify exactly two of {period,duration,cycles} or period only" n = kw.has_key('min') x = kw.has_key('max') m = kw.has_key('mean') a = kw.has_key('amplitude') if n + x + m + a != 2: raise ValueError, "undulation must specify exactly two of {min,max,mean,amplitude}" if n: min = kw['min'] if x: max = kw['max'] elif m: max = 2 * kw['mean'] - min else: max = min + 2 * kw['amplitude'] elif x: max = kw['max'] if m: min = 2 * kw['mean'] - max else: min = max - 2 * kw['amplitude'] else: min = kw['mean'] - kw['amplitude'] max = kw['mean'] + kw['amplitude'] if kw.has_key('relative') and kw['relative']: min += anim.get(var) return style, period, duration, min, max