def test_fade_out_with_label(self): bob = Text('bob', text='Bob', pos=(640, 320)) studio = Stage() studio.add_actor(bob) studio.add_action(actions.FadeOut(bob, 10, 40)) for frame in range(75): studio.draw(frame)
def test_colorize_on_pygame(self): engine = PyGameEngine() stage = Stage(engine) stage.num_frames = 75 for row in range(50, 780, 100): for col in range(50, 1280, 100): name = 'bob{}x{}'.format(col, row) actor = Square( name, color=colors.random_color(), pos=(col, row), side=90, ) stage.add_actor(actor) stage.add_action( actions.Colorize(actor, 5, 70, colors.random_color())) for frame in range(stage.num_frames): stage.draw(frame)
def test(self): t = Text('timer', pos=(1000, 700), color='navy') e1 = Label('e1', text='Enter on 75', width=190, color='gold') bg = Rect('bg', width=30, height=600, pos=(620, 320), color='orange') fg = Rect('fg', width=30, height=600, pos=(660, 320), color='navy') e = Label('exit', text="I'll go on 2s", pos=(200, 200)) sch = Scheduler() sch.add_action(actions.Timer(t, 0, 150)) sch.add_action(actions.Enter(e1, 75, 76, (640, 320))) sch.add_action(actions.Background(bg, 100, 101)) sch.add_action(actions.Foreground(fg, 125, 126)) sch.add_action(actions.Exit(e, 50, 51)) engine = PyGameEngine() studio = Stage(engine) studio.add_actors(t, fg, e, e1, bg) for frame in range(150): studio.draw(frame) sch.next()
def test_easing(): move = Label('Move', width=190, pos=(100, 30), color='gold') fall = Label('Fall', width=190, pos=(300, 30), color='gold') land = Label('Land', width=190, pos=(500, 30), color='gold') ease_in = Label('EaseIn', width=190, pos=(700, 30), color='gold') ease_out = Label('EaseOut', width=190, pos=(900, 30), color='gold') swing = Label('Swing', width=190, pos=(1100, 30), color='gold') sch = Scheduler() sch.add_action(actions.Move(move, 5, 70, (100, 700))) sch.add_action(actions.Fall(fall, 5, 70, (300, 700))) sch.add_action(actions.Land(land, 5, 70, (500, 700))) sch.add_action(actions.EaseIn(ease_in, 5, 70, (700, 700))) sch.add_action(actions.EaseOut(ease_out, 5, 70, (900, 700))) sch.add_action(actions.Swing(swing, 5, 70, (1100, 700))) engine = PyGameEngine() stage = Stage(engine) stage.add_actors(move, fall, land, ease_in, ease_out, swing) for frame in range(75): stage.draw(frame) sch.next()
def test_fade_in_in_pygame(self): sch = Scheduler() engine = PyGameEngine() studio = Stage(engine) for row in range(50, 780, 100): for col in range(50, 1280, 100): from_frame = random.randint(5, 30) size = random.randint(10, 70) to_frame = from_frame + size name = 'bob{}x{}'.format(col, row) actor = Square( name, color=colors.random_color(), pos=(col, row), side=90, alpha=0.1, ) sch.add_action(actions.FadeIn(actor, from_frame, to_frame)) studio.add_actor(actor) for frame in range(75): studio.draw(frame) sch.next()
opts = config.get_options() if opts.script: parser = language.get_parser() try: tree = parser.parseFile(opts.script) except language.ParseException as err: logger.error('Error de parseo en {}'.format(opts.script)) logger.error(err) logger.error('num línea: {}'.format(err.lineno)) logger.error('>>> {}'.format(err.line)) logger.error('---' + '-'*err.col + '^') sys.exit() actors = [language.get_actor(_) for _ in language.actors_list()] engine = SVGEngine(output_dir=opts.output_dir) stage = Stage(engine, options=opts) stage.add_actors(*actors) for t in language.get_actions(): interval, action_name, actor_name, *args = t from_frame, to_frame = interval actor = language.get_actor(actor_name) action = actions.create_action( action_name, actor, from_frame, to_frame, *args ) stage.add_action(action) for frame in range(stage.num_frames): stage.draw(frame)
def test_sequence(self): sch = Scheduler() s = Stage(PyGameEngine()) s.num_frames = 80 middle = s.height // 2 dice1 = Dice('D1', num=1) dice1.place(1 * s.width // 7, middle) sch.add_action( Land(dice1, 0, 60, Vector(1 * s.width // 7, s.height - 50))) sch.add_action(Swing(dice1, 60, 80, dice1.initial_state['pos'])) s.add_actor(dice1) dice2 = Dice('D2', num=2) dice2.place(2 * s.width // 7, middle) sch.add_action( Fall(dice2, 0, 60, Vector(2 * s.width // 7, s.height - 50))) sch.add_action(Swing(dice2, 60, 80, dice2.initial_state['pos'])) s.add_actor(dice2) dice3 = Dice('D3', num=3) dice3.place(3 * s.width // 7, middle) sch.add_action(Fall(dice3, 0, 60, Vector(3 * s.width // 7, 50))) sch.add_action(Swing(dice3, 60, 80, dice3.initial_state['pos'])) s.add_actor(dice3) dice4 = Dice('D4', num=4) dice4.place(4 * s.width // 7, middle) sch.add_action(Land(dice4, 0, 60, Vector(4 * s.width // 7, 50))) sch.add_action(Swing(dice4, 60, 80, dice4.initial_state['pos'])) s.add_actor(dice4) dice5 = Dice('D5', num=5) dice5.place(5 * s.width // 7, middle) sch.add_action( Move(dice5, 0, 60, Vector(5 * s.width // 7, s.height - 50))) sch.add_action(Swing(dice5, 60, 80, dice5.initial_state['pos'])) s.add_actor(dice5) dice6 = Dice('D6', num=6) dice6.place(6 * s.width // 7, middle) sch.add_action(Move(dice6, 0, 60, Vector(6 * s.width // 7, 50))) sch.add_action(Swing(dice6, 60, 80, dice6.initial_state['pos'])) s.add_actor(dice6) t1 = Label( 'Texto1', pos=(s.width // 2, 50), color='gold', width=200, height=100, ) for i in range(0, 81, 20): fall_pos = vectors.get_random_position_vector(s.width, s.height) land_pos = vectors.get_random_position_vector(s.width, s.height) sch.add_action(Land(t1, i, i + 25, fall_pos)) sch.add_action(Fall(t1, i, i + 25, land_pos)) s.add_actors(t1) for frame in range(0, 100): s.draw(frame) sch.next()
def test_create_sequence(self): s = Stage(PyGameEngine()) s.num_frames = 100 star = Star('star', color='gold', pos=(1280, 720), radius=20) s.add_actor(star) bob = Square('bob', pos=(0, s.height // 2)) s.add_actor(bob) dice = Dice('D1', pos=(400, 400)) s.add_actor(dice) mf = Bitmap('mf', 'mf.png', pos=(200, 200)) s.add_actor(mf) sch = Scheduler() sch.add_action(Move(star, 0, 100, (0, 0))) sch.add_action(Swing(mf, 0, 100, (1080, 520))) sch.add_action(Land(bob, 0, 100, Vector(s.width, s.height // 2))) for frame in range(0, 100): s.draw(frame) sch.next()
def test_create(self): Stage(PyGameEngine())
def test_create_sequence(self): stage = Stage() stage.num_frames = 100 star = Star('star', color='red', pos=(0, 0)) stage.add_actor(star) stage.add_action(Move(star, 0, 100, stage.refs['bottom_right'])) bob = Square('bob', pos=stage.refs['center']) stage.add_actor(bob) stage.add_action(Land(bob, 0, 100, (stage.width, stage.height // 2))) for frame in range(0, stage.num_frames): stage.draw(frame)
def test_create_frame(self): s = Stage(SVGEngine(output_dir='./tmp')) star = Star('star', color='red', pos=(0, 0)) s.add_actor(star) s.add_actor(Square('bob')) s.draw(0)