1 | #! perl |
1 | #! perl |
2 | |
2 | |
3 | #:META:X_RESOURCE:%.expr:string:background expression |
3 | #:META:X_RESOURCE:%.expr:string:background expression |
4 | #:META:X_RESOURCE:%.border:boolean:respect the terminal border |
4 | #:META:X_RESOURCE:%.border:boolean:respect the terminal border |
5 | #:META:X_RESOURCE:%.interval:seconds:minimum time between updates |
5 | #:META:X_RESOURCE:%.interval:seconds:minimum time between updates |
6 | |
|
|
7 | #TODO: once, rootalign |
|
|
8 | |
6 | |
9 | =head1 NAME |
7 | =head1 NAME |
10 | |
8 | |
11 | background - manage terminal background |
9 | background - manage terminal background |
12 | |
10 | |
… | |
… | |
59 | |
57 | |
60 | For example, an expression such as C<scale load "$HOME/mybg.png"> scales the |
58 | For example, an expression such as C<scale load "$HOME/mybg.png"> scales the |
61 | image to the window size, so it relies on the window size and will |
59 | image to the window size, so it relies on the window size and will |
62 | be reevaluated each time it is changed, but not when it moves for |
60 | be reevaluated each time it is changed, but not when it moves for |
63 | example. That ensures that the picture always fills the terminal, even |
61 | example. That ensures that the picture always fills the terminal, even |
64 | after it's size changes. |
62 | after its size changes. |
65 | |
63 | |
66 | =head2 EXPRESSIONS |
64 | =head2 EXPRESSIONS |
67 | |
65 | |
68 | Expressions are normal Perl expressions, in fact, they are Perl blocks - |
66 | Expressions are normal Perl expressions, in fact, they are Perl blocks - |
69 | which means you could use multiple lines and statements: |
67 | which means you could use multiple lines and statements: |
… | |
… | |
117 | horizontal and vertical dimensions. For example, this halves the image |
115 | horizontal and vertical dimensions. For example, this halves the image |
118 | width and doubles the image height: |
116 | width and doubles the image height: |
119 | |
117 | |
120 | scale 0.5, 2, load "$HOME/mypic.png" |
118 | scale 0.5, 2, load "$HOME/mypic.png" |
121 | |
119 | |
122 | Other effects than scalign are also readily available, for exmaple, you can |
120 | Other effects than scaling are also readily available, for example, you can |
123 | tile the image to fill the whole window, instead of resizing it: |
121 | tile the image to fill the whole window, instead of resizing it: |
124 | |
122 | |
125 | tile load "$HOME/mypic.png" |
123 | tile load "$HOME/mypic.png" |
126 | |
124 | |
127 | In fact, images returned by C<load> are in C<tile> mode by default, so the C<tile> operator |
125 | In fact, images returned by C<load> are in C<tile> mode by default, so the C<tile> operator |
… | |
… | |
153 | This only works for one cycle though, so as long as you load the same |
151 | This only works for one cycle though, so as long as you load the same |
154 | image every time, it will always be cached, but when you load a different |
152 | image every time, it will always be cached, but when you load a different |
155 | image, it will forget about the first one. |
153 | image, it will forget about the first one. |
156 | |
154 | |
157 | This allows you to either speed things up by keeping multiple images in |
155 | This allows you to either speed things up by keeping multiple images in |
158 | memory, or comserve memory by loading images more often. |
156 | memory, or conserve memory by loading images more often. |
159 | |
157 | |
160 | For example, you can keep two images in memory and use a random one like |
158 | For example, you can keep two images in memory and use a random one like |
161 | this: |
159 | this: |
162 | |
160 | |
163 | my $img1 = load "img1.png"; |
161 | my $img1 = load "img1.png"; |
… | |
… | |
193 | Specifying this flag changes the behaviour, so that the image only |
191 | Specifying this flag changes the behaviour, so that the image only |
194 | replaces the background of the character area. |
192 | replaces the background of the character area. |
195 | |
193 | |
196 | =item --background-interval seconds |
194 | =item --background-interval seconds |
197 | |
195 | |
198 | Since some operations in the underlying XRender extension can effetively |
196 | Since some operations in the underlying XRender extension can effectively |
199 | freeze your X-server for prolonged time, this extension enforces a minimum |
197 | freeze your X-server for prolonged time, this extension enforces a minimum |
200 | time between updates, which is normally about 0.1 seconds. |
198 | time between updates, which is normally about 0.1 seconds. |
201 | |
199 | |
202 | If you want to do updates more often, you can decrease this safety |
200 | If you want to do updates more often, you can decrease this safety |
203 | interval with this switch. |
201 | interval with this switch. |
… | |
… | |
326 | become transparent. This mode is most useful when you want to place an |
324 | become transparent. This mode is most useful when you want to place an |
327 | image over another image or the background colour while leaving all |
325 | image over another image or the background colour while leaving all |
328 | background pixels outside the image unchanged. |
326 | background pixels outside the image unchanged. |
329 | |
327 | |
330 | Example: load an image and display it in the upper left corner. The rest |
328 | Example: load an image and display it in the upper left corner. The rest |
331 | of the space is left "empty" (transparent or wahtever your compisotr does |
329 | of the space is left "empty" (transparent or whatever your compositor does |
332 | in alpha mode, else background colour). |
330 | in alpha mode, else background colour). |
333 | |
331 | |
334 | pad load "mybg.png" |
332 | pad load "mybg.png" |
335 | |
333 | |
336 | =item extend $img |
334 | =item extend $img |
337 | |
335 | |
338 | Extends the image over the whole plane, using the closest pixel in the |
336 | Extends the image over the whole plane, using the closest pixel in the |
339 | area outside the image. This mode is mostly useful when you more complex |
337 | area outside the image. This mode is mostly useful when you use more complex |
340 | filtering operations and want the pixels outside the image to have the |
338 | filtering operations and want the pixels outside the image to have the |
341 | same values as the pixels near the edge. |
339 | same values as the pixels near the edge. |
342 | |
340 | |
343 | Example: just for curiosity, how does this pixel extension stuff work? |
341 | Example: just for curiosity, how does this pixel extension stuff work? |
344 | |
342 | |
… | |
… | |
675 | |
673 | |
676 | Values less than 0 reduce brightness, while values larger than 0 increase |
674 | Values less than 0 reduce brightness, while values larger than 0 increase |
677 | it. Useful range is from -1 to 1 - the former results in a black, the |
675 | it. Useful range is from -1 to 1 - the former results in a black, the |
678 | latter in a white picture. |
676 | latter in a white picture. |
679 | |
677 | |
680 | Due to idiosynchrasies in the underlying XRender extension, biases less |
678 | Due to idiosyncrasies in the underlying XRender extension, biases less |
681 | than zero can be I<very> slow. |
679 | than zero can be I<very> slow. |
682 | |
680 | |
683 | =cut |
681 | =cut |
684 | |
682 | |
685 | sub contrast($$;$$;$) { |
683 | sub contrast($$;$$;$) { |