def main(time): top_layer = Layer(relative_anchor=(0.5, 0.5)) clock = RealtimeClock() Window(top_layer, fullscreen=True) text_layer = Layer(top_layer, scale=(1, top_layer.scale_x/top_layer.scale_y)) text = Countdown(text_layer, '', scale=0.001, font_size=256, relative_anchor=(0.5, 0.8), position=(0.5, 0.5), time=time) def game_over(): def easing(power): return lambda x: 1 - (math.sin(x * TAU) / 2 + 0.5) ** power rect = Rectangle(top_layer, color=(1, 0, 0), opacity=0) clock.schedule(Animation(rect, 'color', 1, 1, 0, timing='infinite', easing=easing(1), time=0.1)) clock.schedule(Animation(rect, 'opacity', 0.5, time=1)) clock.schedule(Animation(text, 'time', 0, time=time, timing='infinite')) clock.schedule(game_over, dt=time) run()
from gillcup_graphics import Layer, Rectangle, Window, run, RealtimeClock from gillcup import Animation from gillcup.actions import process_generator root_layer = Layer() rect = Rectangle(root_layer, size=(0.5, 0.5), position=(0.25, 0.25), relative_anchor=(0.5, 0.5), ) Window(root_layer, width=400, height=400) clock = RealtimeClock() @process_generator def process(): while not rect.dead: for prop, value in ( ('x', 0.75), ('y', 0.75), ('x', 0.25), ('y', 0.25)): print('Animating {0} towards {1}'.format(prop, value)) yield Animation(rect, prop, value, time=0.5, easing='sine.in_out') clock.schedule(process()) run()
from gillcup_graphics import Layer, Rectangle, Window, run, RealtimeClock from gillcup import Animation root_layer = Layer() rect = Rectangle(root_layer, size=(0.5, 0.5), position=(0.5, 0.5), relative_anchor=(0.5, 0.5), rotation=45, ) Window(root_layer, width=400, height=400) clock = RealtimeClock() def blink(on): if on: clock.schedule(Animation(rect, 'opacity', 1, time=0.3)) else: clock.schedule(Animation(rect, 'opacity', 0, time=0.3)) if not rect.dead: clock.schedule(lambda: blink(not on), 0.5) blink(True) clock.schedule(Animation(rect, 'rotation', 0, time=1, timing='infinite')) clock.schedule(Animation(rect, 'color', 1, 0.5, 0, time=5))
from gillcup_graphics import Layer, Rectangle, Window, run, RealtimeClock from gillcup import Animation root_layer = Layer() rect = Rectangle(root_layer, size=(0.5, 0.5), position=(0.25, 0.25), relative_anchor=(0.5, 0.5), ) Window(root_layer, width=400, height=400) clock = RealtimeClock() def announce_end(): print 'done' animation = Animation(rect, 'x', 0.75, time=1) clock.schedule(animation) animation = animation.chain(Animation(rect, 'y', 0.75, time=1)) animation = animation.chain(Animation(rect, 'x', 0.25, time=1)) animation = animation.chain(Animation(rect, 'y', 0.25, time=1)) animation.chain(announce_end) run()