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.51 by sf-exg, Sun Jun 10 19:01:03 2012 UTC vs.
Revision 1.52 by root, Tue Jun 12 10:45:53 2012 UTC

202 202
203=back 203=back
204 204
205=cut 205=cut
206 206
207our %_IMGCACHE; 207our %_IMG_CACHE;
208our %_ONCE_CACHE;
208our $HOME; 209our $HOME;
209our ($self, $old, $new); 210our ($self, $old, $new);
210our ($x, $y, $w, $h); 211our ($x, $y, $w, $h);
211 212
212# enforce at least this interval between updates 213# enforce at least this interval between updates
250 251
251=cut 252=cut
252 253
253 sub root() { 254 sub root() {
254 $new->{rootpmap_sensitive} = 1; 255 $new->{rootpmap_sensitive} = 1;
255 die "root op not supported, exg, we need you"; 256 $self->new_img_from_root
256 } 257 }
257 258
258=item solid $colour 259=item solid $colour
259 260
260=item solid $width, $height, $colour 261=item solid $width, $height, $colour
283=cut 284=cut
284 285
285 sub clone($) { 286 sub clone($) {
286 $_[0]->clone 287 $_[0]->clone
287 } 288 }
288
289=back
290 289
291=head2 TILING MODES 290=head2 TILING MODES
292 291
293The following operators modify the tiling mode of an image, that is, the 292The following operators modify the tiling mode of an image, that is, the
294way that pixels outside the image area are painted when the image is used. 293way that pixels outside the image area are painted when the image is used.
630 629
631 sub rootalign($) { 630 sub rootalign($) {
632 move -TX, -TY, $_[0] 631 move -TX, -TY, $_[0]
633 } 632 }
634 633
634=item rotate $center_x, $center_y, $degrees, $new_width, $new_height
635
636Rotates the image by C<$degrees> degrees, counter-clockwise, around the
637pointer 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
639C<$new_height>.
640
641#TODO# new width, height, maybe more operators?
642
643Example: rotate the image by 90 degrees
644
645=cut
646
647 sub rotate($$$$$$) {
648 my $img = pop;
649 $img->rotate (
650 $_[0] * $img->w,
651 $_[1] * $img->h,
652 $_[2] * (3.14159265 / 180),
653 $_[3],
654 $_[4],
655 )
656 }
657
635=back 658=back
636 659
637=head2 COLOUR MODIFICATIONS 660=head2 COLOUR MODIFICATIONS
638 661
639The following operators change the pixels of the image. 662The following operators change the pixels of the image.
721 sub blur($$;$) { 744 sub blur($$;$) {
722 my $img = pop; 745 my $img = pop;
723 $img->blur ($_[0], @_ >= 2 ? $_[1] : $_[0]) 746 $img->blur ($_[0], @_ >= 2 ? $_[1] : $_[0])
724 } 747 }
725 748
726=item rotate $new_width, $new_height, $center_x, $center_y, $degrees 749=back
727 750
728Rotates the image by C<$degrees> degrees, counter-clockwise, around the 751=head2 OTHER STUFF
729pointer at C<$center_x> and C<$center_y> (specified as factor of image
730width/height), generating a new image with width C<$new_width> and height
731C<$new_height>.
732 752
733#TODO# new width, height, maybe more operators? 753Anything that didn't fit any of the other categories, even after appliyng
754force and closing our eyes.
734 755
735Example: rotate the image by 90 degrees 756=over 4
736 757
737=cut 758=item once { ... }
738 759
739 sub rotate($$$$$$) { 760This function takes a code block as argument, that is, one or more
740 my $img = pop; 761statements enclosed by braces.
741 $img->rotate ( 762
742 $_[0], 763The trick is that this code block is only evaluated once - future calls
743 $_[1], 764will simply return the original image (yes, it should only be used with
744 $_[2] * $img->w, 765images).
745 $_[3] * $img->h, 766
746 $_[4] * (3.14159265 / 180), 767This can be extremely useful to avoid redoign the same slow operations
747 ) 768again and again- for example, if your background expression takes the root
769background, blurs it and then root-aligns it it would have to blur the
770root background on every window move or resize.
771
772Putting the blur into a C<once> block will make sure the blur is only done
773once:
774
775 rootlign once { blur 10, root }
776
777This leaves the question of how to force reevaluation of the block, in
778case the root background changes: Right now, all once blocks forget that
779they ahve been executed before each time the root background changes (if
780the expression is sensitive to that) or when C<once_again> is called.
781
782=item once_again
783
784Resets all C<once> block as if they had never been called, i.e. on the
785next call they will be reevaluated again.
786
787=cut
788
789 sub once(&) {
790 $_ONCE_CACHE{$_[0]+0} ||= $_[0]()
791 }
792
793 sub once_again() {
794 %_ONCE_CACHE = ();
748 } 795 }
749 796
750=back 797=back
751 798
752=cut 799=cut

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines