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.38 by root, Fri Jun 8 21:48:07 2012 UTC vs.
Revision 1.39 by root, Fri Jun 8 22:19:03 2012 UTC

70 } else { 70 } else {
71 return scale load "$HOME/sunday.png"; 71 return scale load "$HOME/sunday.png";
72 } 72 }
73 73
74This expression gets evaluated once per hour. It will set F<sunday.png> as 74This expression gets evaluated once per hour. It will set F<sunday.png> as
75background on sundays, and F<weekday.png> on all other days. 75background on Sundays, and F<weekday.png> on all other days.
76 76
77Fortunately, we expect that most expressions will be much simpler, with 77Fortunately, we expect that most expressions will be much simpler, with
78little Perl knowledge needed. 78little Perl knowledge needed.
79 79
80Basically, you always start with a function that "generates" an image 80Basically, you always start with a function that "generates" an image
112horizontal and vertical dimensions. For example, this halves the image 112horizontal and vertical dimensions. For example, this halves the image
113width and doubles the image height: 113width and doubles the image height:
114 114
115 scale 50, 200, load "$HOME/mypic.png" 115 scale 50, 200, load "$HOME/mypic.png"
116 116
117TODO 117Other effects than scalign are also readily available, for exmaple, you can
118tile the image to fill the whole window, instead of resizing it:
119
120 tile load "$HOME/mypic.png"
121
122In fact, images returned by C<load> are in C<tile> mode by default, so the C<tile> operator
123is kind of superfluous.
124
125Another common effect is to mirror the image, so that the same edges touch:
126
127 mirror load "$HOME/mypic.png"
128
129This is also a typical background expression:
130
131 rootalign root
132
133It first takes a snapshot of the screen background image, and then
134moves it to the upper left corner of the screen - the result is
135pseudo-transparency, as the image seems to be static while the window is
136moved around.
118 137
119=head3 CYCLES AND CACHING 138=head3 CYCLES AND CACHING
120 139
121TODO 140As has been mentioned before, the expression might be evaluated multiple
122
123Each time the expression is reevaluated, a new cycle is said to have begun. Many operators 141times. Each time the expression is reevaluated, a new cycle is said to
124cache their results till the next cycle. For example 142have begun. Many operators cache their results till the next cycle.
143
144For example, the C<load> operator keeps a copy of the image. If it is
145asked to load the same image on the next cycle it will not load it again,
146but return the cached copy.
147
148This only works for one cycle though, so as long as you load the same
149image every time, it will always be cached, but when you load a different
150image, it will forget about the first one.
151
152This allows you to either speed things up by keeping multiple images in
153memory, or comserve memory by loading images more often.
154
155For example, you can keep two images in memory and use a random one like
156this:
157
158 my $img1 = load "img1.png";
159 my $img2 = load "img2.png";
160 (0.5 > rand) ? $img1 : $img2
161
162Since both images are "loaded" every time the expression is evaluated,
163they are always kept in memory. Contrast this version:
164
165 my $path1 = "img1.png";
166 my $path2 = "img2.png";
167 load ((0.5 > rand) ? $path1 : $path2)
168
169Here, a path is selected randomly, and load is only called for one image,
170so keeps only one image in memory. If, on the next evaluation, luck
171decides to use the other path, then it will have to load that image again.
125 172
126=head2 REFERENCE 173=head2 REFERENCE
127 174
128=head3 COMMAND LINE SWITCHES 175=head3 COMMAND LINE SWITCHES
129 176
142replaces the background of the character area. 189replaces the background of the character area.
143 190
144=back 191=back
145 192
146=cut 193=cut
147
148our $EXPR;#d#
149#$EXPR = 'move W * 0.1, -H * 0.1, resize W * 0.5, H * 0.5, repeat_none load "opensource.png"';
150$EXPR = 'move -TX, -TY, load "argb.png"';
151#$EXPR = '
152# rotate W, H, 50, 50, counter 1/59.95, repeat_mirror,
153# clip X, Y, W, H, repeat_mirror,
154# load "/root/pix/das_fette_schwein.jpg"
155#';
156#$EXPR = 'solid "red"';
157#$EXPR = 'blur root, 10, 10'
158#$EXPR = 'blur move (root, -x, -y), 5, 5'
159#resize load "/root/pix/das_fette_schwein.jpg", w, h
160 194
161our $HOME; 195our $HOME;
162our ($self, $old, $new); 196our ($self, $old, $new);
163our ($x, $y, $w, $h); 197our ($x, $y, $w, $h);
164 198
562 596
563=item blur $radius_horz, $radius_vert, $img 597=item blur $radius_horz, $radius_vert, $img
564 598
565Gaussian-blurs the image with (roughly) C<$radius> pixel radius. The radii 599Gaussian-blurs the image with (roughly) C<$radius> pixel radius. The radii
566can also be specified separately. 600can also be specified separately.
601
602Blurring is often I<very> slow, at least compared or other
603operators. Larger blur radii are slower than smaller ones, too, so if you
604don't want to freeze your screen for long times, start experimenting with
605low values for radius (<5).
567 606
568=cut 607=cut
569 608
570 sub blur($$;$) { 609 sub blur($$;$) {
571 my $img = pop; 610 my $img = pop;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines