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