Animation(3pm)

🌸 Tk::Animation β€” the Animation(3pm) page, bestie edition 🌸

okay so. this is the manual page for Tk::Animation, and it's here to help you display a whole lil sequence of Tk::Photo images like the main character montage you deserve. πŸ’– perl's own docs, user-contributed, and now in group-chat format. let's go. ✨


✨ NAME ✨

Tk::Animation β€” display sequence of Tk::Photo images πŸ¦‹


πŸŽ€ SYNOPSIS πŸŽ€

  use Tk::Animation
  my $img = $widget->Animation('-format' => 'gif', -file => 'somefile.gif');

  $img->add_frame(@images);

  $img->start_animation;
  $img->start_animation( $period );

  $img->next_image;
  $img->prev_image;
  $img->set_image( 0 .. $#frames );

  $img->pause_animation;
  $img->resume_animation( $period );

  $img->fast_forward( $multiplier );
  $img->fast_reverse( $multiplier );

  $img->stop_animation;

  $img->set_disposal_method( $boolean );

πŸ’… DESCRIPTION πŸ’…

the easy case first: when Animation gets handed a GIF89-style GIF with multiple 'frames', it just builds an internal array of Photo images for you. no notes. slay. πŸ’–

The add_frame method adds images to the sequence. it exists so you can construct animations out of separate images instead of one fancy GIF. heads up tho: all the images must be Photos, and they should all be the same size. πŸ‘‘

Then start_animation($period) kicks off a repeat with the $period you gave it, sequencing through those images. same rules as raw repeat, so $period is in milliseconds β€” and for a 50Hz monitor it should be at least 20ms. If you don't pass $period at all, it gets figured out from the GIF metadata (more on that below), and if that's not possible it just defaults to 100 milliseconds. easy. 🫢

stop_animation cancels the repeat and resets the image back to the first image in the sequence. back to square one, bestie. πŸ™ˆ

For fine-grained control, next_image and prev_image move you one frame forward or backward. set_image randomly positions the animation to a particular frame. 🎯

pause_animation pauses the movie, and resume_animation continues from the pause point. iconic pause-resume combo, no cap. ⏸️▢️

fast_forward and fast_reverse speed through the movie either forwards or backwards. $multiplier specifies how much faster the animation moves. zoom zoom. πŸ”₯

the metadata tea β˜•: if Image::Info is installed, then the repeat period time and the disposal method of GIF animations are determined from the GIF metadata directly. otherwise? you gotta set the disposal method manually with set_disposal_method β€” 1 for blanking the previous images, 0 for leaving the previous images as is. and the repeat period time may be given in the start_animation method. iykyk. ✨


πŸ’€ NOTES πŸ’€

okay, lore time: set_disposal_method was formerly known as the blank method β€” but the naming of this method was a mistake. we don't talk about it. 😭

now the serious bit, fr fr: if the disposal method is not set correctly β€” whether by set_disposal_method or by determining it from the GIF metadata β€” then the following may happen: by default Animation leaves the previous movie frame in the animation photo. many times, overlaying subsequent frames produces a composite that looks blurred. πŸ’€ so pls set it properly.


πŸ› BUGS πŸ›

  • this module should not depend on a module which is not declared as a dependency (Image::Info). 🫠
  • the delays between images may vary in a GIF animation. this cannot be handled by this module yet. 😭
  • the handling of the various disposal methods is not correct. πŸ™ˆ

no cap: none of that is a vibe β€” those are real, documented, currently-true limitations. know them, love them, file your feelings accordingly. πŸ’œ

and that's the whole page, bestie!! πŸŽ€ this was Animation(3pm), from perl v5.40.1, dated 2025-04-13 β€” go make something move. βœ¨πŸ’…πŸ¦‹

πŸ“¦ where this page comes from