Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
#!/usr/bin/perl use strict; use warnings; use Gtk2 '-init'; use LWP::Simple; # cheap webget, no error reporting if( ! -e 'earth.jpg' and ! -e 'moon.jpg'){ print "downloading test images, please wait\n"; foreach my $localfile('earth.jpg','moon.jpg'){ mirror( "http://zentara.net/$localfile", $localfile ); } } my $mw = Gtk2::Window->new; $mw->signal_connect('destroy', sub { Gtk2->main_quit }); my $vp = Gtk2::Viewport->new(undef, undef); $mw->add($vp); my $pixbuf = Gtk2::Gdk::Pixbuf->new_from_file_at_scale ('earth.jpg', 6 +00,600,0); my $pixbufa = $pixbuf->copy(); #my ($x, $y) = ($pixbufa->get_width, $pixbufa->get_height); #print "$x $y\n"; my $pixbuf1 = Gtk2::Gdk::Pixbuf->new_from_file_at_scale ('moon.jpg', 6 +00,600,0); my $pixbufb = $pixbuf1->copy(); #my ($x1, $y1) = ($pixbufb->get_width, $pixbufb->get_height); #print "$x1 $y1\n"; #$pixbuf1->composite ($pixbuf, $dest_x, $dest_y, $dest_width, $dest_he +ight, # $offset_x, $offset_y, $scale_x, $scale_y, $interp_type, $overa +ll_alpha) # start with base image my $toggle = 5; my $alpha = 0; $pixbufb->composite ($pixbufa, 0, 0, 600, 600, 0, 0, 1, 1, 'nearest', $alpha); # 0 <= alpha <= 255 my $image = Gtk2::Image->new_from_pixbuf ($pixbufa); $vp->add($image); $mw->set_title("fade demo"); $mw->show_all(); my $id = Glib::Timeout->add (100, \&sequence); Gtk2->main; sub sequence{ $alpha += $toggle; print "$alpha\n"; if ($alpha == 255){ $toggle = -5 } if ($alpha == 0){ $toggle = 5 } $pixbufb->composite ($pixbufa, 0, 0, 600, 600, 0, 0, 1, 1, 'nearest', $alpha); # 0 <= alpha <= 255 $image->set_from_pixbuf ($pixbufa); Gtk2->main_iteration while Gtk2->events_pending; # prevents accumulation of pixbuf changes $pixbufa = $pixbuf->copy(); return 1; }

In reply to Gtk2 Simple Image Fade by zentara

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



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (6)
As of 2024-04-19 12:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found