ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/src/perl/background
(Generate patch)

Comparing rxvt-unicode/src/perl/background (file contents):
Revision 1.52 by root, Tue Jun 12 10:45:53 2012 UTC vs.
Revision 1.54 by root, Thu Jun 14 16:22:20 2012 UTC

71 return scale load "$HOME/weekday.png"; 71 return scale load "$HOME/weekday.png";
72 } else { 72 } else {
73 return scale load "$HOME/sunday.png"; 73 return scale load "$HOME/sunday.png";
74 } 74 }
75 75
76This expression gets evaluated once per hour. It will set F<sunday.png> as 76This expression is evaluated once per hour. It will set F<sunday.png> as
77background on Sundays, and F<weekday.png> on all other days. 77background on Sundays, and F<weekday.png> on all other days.
78 78
79Fortunately, we expect that most expressions will be much simpler, with 79Fortunately, we expect that most expressions will be much simpler, with
80little Perl knowledge needed. 80little Perl knowledge needed.
81 81
229=item load $path 229=item load $path
230 230
231Loads the image at the given C<$path>. The image is set to plane tiling 231Loads the image at the given C<$path>. The image is set to plane tiling
232mode. 232mode.
233 233
234Loaded images will be cached for one cycle. 234Loaded images will be cached for one cycle, and shared between temrinals
235running in the same process (e.g. in C<urxvtd>).
235 236
237=item load_uc $path
238
239Load uncached - same as load, but does not cache the image. This function
240is most useufl if you want to optimise a background expression in some
241way.
242
236=cut 243=cut
244
245 sub load_uc($) {
246 my ($path) = @_;
247
248 $_IMG_CACHE{$path} || do {
249 my $img = $self->new_img_from_file ($path);
250 Scalar::Util::weaken ($_IMG_CACHE{$path} = $img);
251 $img
252 }
253 }
237 254
238 sub load($) { 255 sub load($) {
239 my ($path) = @_; 256 my ($path) = @_;
240 257
241 $new->{load}{$path} = $old->{load}{$path} || $self->new_img_from_file ($path); 258 $new->{load}{$path} = $old->{load}{$path} || load_uc $path;
242 } 259 }
243 260
244=item root 261=item root
245 262
246Returns the root window pixmap, that is, hopefully, the background image 263Returns the root window pixmap, that is, hopefully, the background image
432C<$seconds> seconds. 449C<$seconds> seconds.
433 450
434Example: load some image and rotate it according to the time of day (as if it were 451Example: load some image and rotate it according to the time of day (as if it were
435the hour pointer of a clock). Update this image every minute. 452the hour pointer of a clock). Update this image every minute.
436 453
437 again 60; rotate TW, TH, 50, 50, (now % 86400) * -720 / 86400, scale load "myclock.png" 454 again 60; rotate 50, 50, (now % 86400) * -720 / 86400, scale load "myclock.png"
438 455
439=item counter $seconds 456=item counter $seconds
440 457
441Like C<again>, but also returns an increasing counter value, starting at 458Like C<again>, but also returns an increasing counter value, starting at
4420, which might be useful for some simple animation effects. 4590, which might be useful for some simple animation effects.
629 646
630 sub rootalign($) { 647 sub rootalign($) {
631 move -TX, -TY, $_[0] 648 move -TX, -TY, $_[0]
632 } 649 }
633 650
634=item rotate $center_x, $center_y, $degrees, $new_width, $new_height 651=item rotate $center_x, $center_y, $degrees
635 652
636Rotates the image by C<$degrees> degrees, counter-clockwise, around the 653Rotates the image by C<$degrees> degrees, counter-clockwise, around the
637pointer at C<$center_x> and C<$center_y> (specified as factor of image 654pointer at C<$center_x> and C<$center_y> (specified as factor of image
638width/height), generating a new image with width C<$new_width> and height 655width/height).
639C<$new_height>.
640 656
641#TODO# new width, height, maybe more operators? 657#TODO# new width, height, maybe more operators?
642 658
643Example: rotate the image by 90 degrees 659Example: rotate the image by 90 degrees
644 660
645=cut 661=cut
646 662
647 sub rotate($$$$$$) { 663 sub rotate($$$$) {
648 my $img = pop; 664 my $img = pop;
649 $img->rotate ( 665 $img->rotate (
650 $_[0] * $img->w, 666 $_[0] * $img->w,
651 $_[1] * $img->h, 667 $_[1] * $img->h,
652 $_[2] * (3.14159265 / 180), 668 $_[2] * (3.14159265 / 180),
653 $_[3],
654 $_[4],
655 ) 669 )
656 } 670 }
657 671
658=back 672=back
659 673

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines