… | |
… | |
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 | |
76 | This expression gets evaluated once per hour. It will set F<sunday.png> as |
76 | This expression is evaluated once per hour. It will set F<sunday.png> as |
77 | background on Sundays, and F<weekday.png> on all other days. |
77 | background on Sundays, and F<weekday.png> on all other days. |
78 | |
78 | |
79 | Fortunately, we expect that most expressions will be much simpler, with |
79 | Fortunately, we expect that most expressions will be much simpler, with |
80 | little Perl knowledge needed. |
80 | little Perl knowledge needed. |
81 | |
81 | |
… | |
… | |
229 | =item load $path |
229 | =item load $path |
230 | |
230 | |
231 | Loads the image at the given C<$path>. The image is set to plane tiling |
231 | Loads the image at the given C<$path>. The image is set to plane tiling |
232 | mode. |
232 | mode. |
233 | |
233 | |
234 | Loaded images will be cached for one cycle. |
234 | Loaded images will be cached for one cycle, and shared between temrinals |
|
|
235 | running in the same process (e.g. in C<urxvtd>). |
235 | |
236 | |
|
|
237 | =item load_uc $path |
|
|
238 | |
|
|
239 | Load uncached - same as load, but does not cache the image. This function |
|
|
240 | is most useufl if you want to optimise a background expression in some |
|
|
241 | way. |
|
|
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 | |
246 | Returns the root window pixmap, that is, hopefully, the background image |
263 | Returns the root window pixmap, that is, hopefully, the background image |
… | |
… | |
432 | C<$seconds> seconds. |
449 | C<$seconds> seconds. |
433 | |
450 | |
434 | Example: load some image and rotate it according to the time of day (as if it were |
451 | Example: load some image and rotate it according to the time of day (as if it were |
435 | the hour pointer of a clock). Update this image every minute. |
452 | the 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 | |
441 | Like C<again>, but also returns an increasing counter value, starting at |
458 | Like C<again>, but also returns an increasing counter value, starting at |
442 | 0, which might be useful for some simple animation effects. |
459 | 0, 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 | |
636 | Rotates the image by C<$degrees> degrees, counter-clockwise, around the |
653 | Rotates the image by C<$degrees> degrees, counter-clockwise, around the |
637 | pointer at C<$center_x> and C<$center_y> (specified as factor of image |
654 | pointer at C<$center_x> and C<$center_y> (specified as factor of image |
638 | width/height), generating a new image with width C<$new_width> and height |
655 | width/height). |
639 | C<$new_height>. |
|
|
640 | |
656 | |
641 | #TODO# new width, height, maybe more operators? |
657 | #TODO# new width, height, maybe more operators? |
642 | |
658 | |
643 | Example: rotate the image by 90 degrees |
659 | Example: 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 | |