I'm trying to put together a simple "Ken Burns" style slideshow using SDL, however when I try and move the image inside of the app the portion of the image that was cropped because the app window is smaller than the image doesn't get drawn and the portion of the app window I'm moving away from doesn't update -- these leads to a neat streaking effect that I'd like to get rid of.
Here's the proof of concept I've been playing around with:
#!/usr/bin/perl
use SDL;
use SDL::Event;
use SDL::App;
use SDL::Rect;
use SDL::Surface;
use warnings;
use strict;
my $app = new SDL::App (
-title => 'Ken Burns Slideshow',
-width => 640,
-height => 480,
-depth => 32,
);
my $frame = SDL::Surface->new( -name => '/path/to/testimage.jpg' );
my $frame_rect = SDL::Rect->new(
-height => $frame->height(),
-width => $frame->width(),
-x => 0,
-y => 0,
);
my $dest_rect = SDL::Rect->new(
-height => $frame->height(),
-width => $frame->width(),
-x => 0,
-y => 0,
);
$frame->blit( $frame_rect, $app, $dest_rect );
$app->update( $dest_rect );
for my $x ( 1 .. 200 ) {
$dest_rect->x( $x );
$dest_rect->y( $x );
$frame->blit( $frame_rect, $app, $dest_rect );
$app->update( $dest_rect );
$app->sync;
$app->delay( 10 );
}
What am I missing? Thanks!!
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.