File: script_roto.pl

package info (click to toggle)
libsdl-perl 2.548-6
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 5,972 kB
  • sloc: perl: 13,985; ansic: 583; makefile: 35
file content (63 lines) | stat: -rw-r--r-- 1,527 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!perl
use strict;
use warnings;
use Carp;
use SDL;
use SDL::Rect;
use SDL::Config;
use SDL::Video;
use SDL::Surface;
use SDL::GFX::Rotozoom;

my $display = SDL::Video::set_video_mode( 640, 480, 32, SDL_SWSURFACE );
my $pixel = SDL::Video::map_RGB( $display->format, 0, 0, 0 );
SDL::Video::fill_rect(
	$display,
	SDL::Rect->new( 0, 0, $display->w, $display->h ), $pixel
);

Carp::confess SDL::get_error if !$display;

my $src = SDL::Video::load_BMP('test/data/picture.bmp');
my $temp_surf;

sub draw {
	SDL::Video::fill_rect(
		$display,
		SDL::Rect->new( 0, 0, $display->w, $display->h ), $pixel
	);

	my $surface = $_[0];
	SDL::Video::blit_surface(
		$surface, SDL::Rect->new( 0, 0, $surface->w, $surface->h ),
		$display, SDL::Rect->new( 0, 0, $display->w, $display->w )
	);

	SDL::Video::update_rect( $display, 0, 0, 640, 480 );

	SDL::delay( $_[1] ) if $_[1];

}

# Note: new surface should be less than 16384 in width and height
foreach ( 1 .. 360 ) {

	$temp_surf = SDL::GFX::Rotozoom::surface( $src, $_, $_ / 180, 1 );
	Carp::confess SDL::get_error if !$temp_surf;
	draw( $temp_surf, 2 );
}

$temp_surf = SDL::GFX::Rotozoom::surface_xy( $src, 1, 1, 1, 1 );
Carp::confess SDL::get_error if !$temp_surf;
draw( $temp_surf, 1000 );

$temp_surf = SDL::GFX::Rotozoom::zoom_surface( $src, 1, 1, 1 );
Carp::confess SDL::get_error if !$temp_surf;
draw( $temp_surf, 1000 );

$temp_surf = SDL::GFX::Rotozoom::shrink_surface( $src, 1, 1 );
Carp::confess SDL::get_error if !$temp_surf;
draw( $temp_surf, 1000 );

SDL::delay(1000);