Ah, I knew it: code runs with result (almost) as expected on 1st attempt: no errors, no typos even. Then something _must_ be wrong with it:). Because of those "glitches" I said "almost" and "didn't investigate", though I should have :)

First thing, "copy" method doesn't copy gif tags (bug in Imager?), $trans_idx was undefined, mask always blank.

However, "compose" method apparently works, even if source image is converted to 3 channel RGB (no alpha) with "to_rgb8", and mask attribute not supplied at all. Statement in fragment further below could be replaced with

$backdrop-> rubthrough( src => $_-> to_rgb8, tx => $left, ty => $top );

and animation would still work. Where and why Imager gets transparency information in this case -- I don't know. I'd expect the result be the same as with "paste" method (you can try it if you wish -- that's where there are no masks, no transparency).

Further, I should have checked for offsets of gif frames -- they are not always zero. Whole "if else" fragment can be replaced with the following (though mask may be unnecessary(?), I'm not omitting it):

if ( $backdrop ) { # not 1st? my $mask = $_-> copy; my @mask_plt = map NC( 255, 255, 255 ), $_-> getcolors; my $trans_idx = $_-> tags( name => 'gif_trans_index' ); my $left = $_-> tags( name => 'gif_left' ); my $top = $_-> tags( name => 'gif_top' ); $mask_plt[ $trans_idx ] = NC( 0, 0, 0 ) if defined $trans_idx; $mask-> setcolors( colors => \@mask_plt ); $backdrop-> compose( src => $_, mask => $mask, tx => $left, ty => $top ); } else { $backdrop = $_-> to_rgb8 }

In reply to Re^3: Why is Tk::Animation so slow? (re: glitches) by vr
in thread Why is Tk::Animation so slow? by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.