Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling

Tk gif animation

by Chuma (Acolyte)
on Mar 01, 2013 at 12:58 UTC ( #1021246=perlquestion: print w/ replies, xml ) Need Help??
Chuma has asked for the wisdom of the Perl Monks concerning the following question:

I'm trying out Tk::Animation, by making an example program that displays an animated gif. But the different frames have different transparent areas, and each frame is displayed on top of the previous ones.

That's no fun. What to do?

Comment on Tk gif animation
Replies are listed 'Best First'.
Re: Tk gif animation
by zentara (Archbishop) on Mar 01, 2013 at 17:52 UTC
    As far as I know, Perl Tk dosn't support transparencies. You will have to put everything on an appropriately colored background to mask the transparency. This works.
    #!/usr/bin/perl use warnings; use strict; use Tk; use Tk::Animation; my $scr = new MainWindow; $scr->configure(-background=>"black"); $scr->geometry("200x150"); my $canvas = $scr->Canvas(-width,200,-height,100, -background=> "black")->pack(-expand, 1, -fill, 'both'); my $image = $scr->Animation('-format' => 'gif', -data => get_gif() + ); $canvas->createImage( 50,50, -image=> $image); $image->blank; my $buttonframe = $scr->Frame()->pack(-expand=>1, -fill=>'both'); my $start = $buttonframe->Button(-text => 'Start', -command => sub{ $image->start_animation(40); } )->pack(-side=>'left'); my $stop = $buttonframe->Button(-text => 'Stop', -command => sub{ $image ->stop_animation; $image ->blank } )->pack(-side=>'right'); MainLoop; sub get_gif{ #base64encoded gif89a ... Tk accepts images in base64encoded format as + -data my $gif = 'R0lGODlhIAAgAPMAAP////zzBf9kAt0IBvIIhEYApQAA1AKr6h+3FABkEVYsBZBxOsDAw +ICAgEBA QAAAACH/C05FVFNDQVBFMi4wAwEAAAAh/h1HaWZCdWlsZGVyIDAuMSBieSBZdmVzIFBpZ3 +VldAAh +QQECgD/ACwAAAAAIAAgAEMEgxC82SS4OOvNb6sfVT1dyX1AQ6YhuZpwh7agyL5xjoFf5d +U606x3 CwZrvh1vgjNqesOm8xSdSXXWTXbKSj2iV67y9g2JlcPuuat6tizrHzn+i9Iz4F74uPx6z1 +BEW05I bn+EQBhMI1xZfXsxVnZrgZN3bCplcGKCKjOALChynImXbDgRACH5BAQKAP8ALAAAAAAgAC +AAQwSG sLUHqr04a9uAlFw3baQGfuJYrpv4dNdJndPbUewqV99D4bkgL+VzCUk74sujOupoNg/Quc +NUnUwp dIo1KXvd2Cd7pRotvmV4qE0xuWu2pDiPk2vnLmpcFrpgIVJYZWk3ekZKcH5/RHZ7UHZWX4 +ZrfBN9 fkwgcopPgpIeh589nUEykHGnIhEAIfkEBAoA/wAsAAAAACAAIABDBIywtfckeCDrzbu2Uy +ZNGOad aAeSDRCmsNiGM2m64zffMbquvF5v19qAgkLOaInD1Cq75OlljEp1LmgTeVU9odSubIXLis +thSuVy Rmsl3LYMzTLLlzW7eFLEhpNWGWotcTBHLluFMUdAcjh4TY5KXxaKi0CHe499mVKdfpYemS +MUbHtE X3c1jZJ+f44gEQAh+QQECgD/ACwAAAAAIAAgAEMEhhDI1kB7MuvNNbVURWFdaW7iU3np6W +ZhDJIZ GT4Y/e6weKkWHY/zuVhmuKEyNFv1gsrOpfiLvqi4mxXFpEK3RR0OKFymsFsXVuVMH2Xcr1 +szrpSX GN94ftbPQTF+fyxIH3dDXVMtYIBOYVaPcUZRkTc5aWFrfD5og08jbG2YekB/Mh+DZxkRAD +s='; return $gif; }

    I'm not really a human, but I play one on earth.
    Old Perl Programmer Haiku ................... flash japh
Re: Tk gif animation
by ww (Bishop) on Mar 01, 2013 at 13:35 UTC
    Post some code, maybe, so we can see where your problems lie?

    If you didn't program your executable by toggling in binary, it wasn't really programming!

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1021246]
Approved by Ratazong
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (3)
As of 2015-11-29 20:03 GMT
Find Nodes?
    Voting Booth?

    What would be the most significant thing to happen if a rope (or wire) tied the Earth and the Moon together?

    Results (753 votes), past polls