<commit_before>=head1 TITLE

anim_image.pir - animate an image in a Parrot SDL window

=head1 SYNOPSIS

To run this file, run the following command from the Parrot directory:

	$ ./parrot examples/sdl/anim_image.pir
	Drew 1080 frames in 0.948230 seconds (1138.964142 fps)
	$ 

=cut

.sub _main :main
	load_bytecode "library/SDL/App.pir"
	load_bytecode "library/SDL/Color.pir"
	load_bytecode "library/SDL/Rect.pir"
	load_bytecode "library/SDL/Image.pir"
	load_bytecode "library/SDL/Sprite.pir"


	.local pmc args
	args           = new .Hash
	args['height'] = 480
	args['width']  = 640
	args['bpp']    =   0
	args['flags']  =   1

	.local pmc app
	.local int app_type

	find_type app_type, 'SDL::App'
	app = new app_type, args

	.local pmc main_screen
	main_screen = app.'surface'()

	.local int rect_type
	find_type rect_type, 'SDL::Rect'

	args['height'] = 100
	args['width']  = 100
	args['x']      =   0
	args['y']      = 190

	.local pmc dest_rect
	dest_rect   = new rect_type, args

	args['width']  = 101
	.local pmc prev_rect
	prev_rect   = new rect_type, args

	args['height'] =  56
	args['width']  = 100
	args['x']      =   0
	args['y']      =   0

	.local pmc source_rect
	source_rect = new rect_type, args

	.local int color_type
	find_type  color_type, 'SDL::Color'

	args['r'] = 0
	args['g'] = 0
	args['b'] = 0

	.local pmc black
	black = new color_type, args

	.local int sprite_type
	find_type  sprite_type, 'SDL::Sprite'

	.local pmc image
	.local int image_type
	.local pmc filename

	find_type image_type, 'SDL::Image'
	filename = new .String
	filename = 'examples/sdl/parrot_small.png'
	image    = new image_type, filename

	args = new .Hash
	args[ 'surface'  ] = image
	args[ 'source_x' ] =     0
	args[ 'source_y' ] =     0
	args[ 'dest_x'   ] =     0
	args[ 'dest_y'   ] =   190
	args[ 'bgcolor'  ] = black

	.local pmc sprite
	sprite = new sprite_type, args

	.local float start_time
	time start_time

	_animate_on_x_axis( main_screen, sprite,   0, 540,  1)
	sleep 1
	_animate_on_x_axis( main_screen, sprite, 540,   0, -1)<commit_msg>Made work with new SDL Parrot bindings.<commit_after>=head1 TITLE

anim_image.pir - animate an image in a Parrot SDL window

=head1 SYNOPSIS

To run this file, run the following command from the Parrot directory:

	$ ./parrot examples/sdl/anim_image.pir
	Drew 1080 frames in 0.948230 seconds (1138.964142 fps)
	$ 

=cut

.sub _main :main
	load_bytecode "library/SDL/App.pir"
	load_bytecode "library/SDL/Color.pir"
	load_bytecode "library/SDL/Rect.pir"
	load_bytecode "library/SDL/Image.pir"
	load_bytecode "library/SDL/Sprite.pir"


	.local pmc app
	.local int app_type

	find_type app_type, 'SDL::App'
	app = new app_type
	app.'init'( 'height' => 480, 'width' => 640, 'bpp' => 0, 'flags' => 1 )

	.local pmc main_screen
	main_screen = app.'surface'()

	.local int rect_type
	find_type rect_type, 'SDL::Rect'

	.local pmc dest_rect
	dest_rect   = new rect_type
	dest_rect.'init'( 'height' => 100, 'width' => 100, 'x' => 0, 'y' => 190 )

	.local pmc prev_rect
	prev_rect   = new rect_type
	prev_rect.'init'( 'height' => 100, 'width' => 101, 'x' => 0, 'y' => 190 )

	.local pmc source_rect
	source_rect = new rect_type
	source_rect.'init'( 'height' => 56, 'width' => 100, 'x' => 0, 'y' => 0 )

	.local int color_type
	find_type  color_type, 'SDL::Color'

	.local pmc black
	black = new color_type
	black.'init'( 'r' => 0, 'g' => 0, 'b' => 0 )

	.local int sprite_type
	find_type  sprite_type, 'SDL::Sprite'

	.local pmc image
	.local int image_type

	find_type image_type, 'SDL::Image'
	image    = new image_type
	image.'init'( 'examples/sdl/parrot_small.png' )

	.local pmc sprite
	sprite = new sprite_type
	sprite.'init'( 'surface' => image, 'source_x' => 0, 'source_y' => 0, 'dest_x' => 0, 'dest_y' => 190, 'bgcolor' => black )

	.local float start_time
	time start_time

	_animate_on_x_axis( main_screen, sprite,   0, 540,  1)
	sleep 1
	_animate_on_x_axis( main_screen, sprite, 540,   0, -1)
{'fraction_non_alphanumeric': 0.13098555865214087, 'fraction_numerical': 0.03775019001773499, 'mean_word_length': 3.512, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 28, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7191528', 'n_tokens_mistral': 1743, 'n_tokens_neox': 1530, 'n_words': 427}