… | |
… | |
74 | return load "$HOME/sunday.png"; |
74 | return load "$HOME/sunday.png"; |
75 | } |
75 | } |
76 | } |
76 | } |
77 | |
77 | |
78 | This inner expression is evaluated once per hour (and whenever the |
78 | This inner expression is evaluated once per hour (and whenever the |
79 | temrinal window is resized). It sets F<sunday.png> as background on |
79 | terminal window is resized). It sets F<sunday.png> as background on |
80 | Sundays, and F<weekday.png> on all other days. |
80 | Sundays, and F<weekday.png> on all other days. |
81 | |
81 | |
82 | Fortunately, we expect that most expressions will be much simpler, with |
82 | Fortunately, we expect that most expressions will be much simpler, with |
83 | little Perl knowledge needed. |
83 | little Perl knowledge needed. |
84 | |
84 | |
… | |
… | |
119 | width and doubles the image height: |
119 | width and doubles the image height: |
120 | |
120 | |
121 | scale 0.5, 2, load "$HOME/mypic.png" |
121 | scale 0.5, 2, load "$HOME/mypic.png" |
122 | |
122 | |
123 | IF you try out these expressions, you might suffer from some sluggishness, |
123 | IF you try out these expressions, you might suffer from some sluggishness, |
124 | because each time the terminal is resized, it loads the PNG image agin |
124 | because each time the terminal is resized, it loads the PNG image again |
125 | and scales it. Scaling is usually fast (and unavoidable), but loading the |
125 | and scales it. Scaling is usually fast (and unavoidable), but loading the |
126 | image can be quite time consuming. This is where C<keep> comes in handy: |
126 | image can be quite time consuming. This is where C<keep> comes in handy: |
127 | |
127 | |
128 | scale 0.5, 2, keep { load "$HOME/mypic.png" } |
128 | scale 0.5, 2, keep { load "$HOME/mypic.png" } |
129 | |
129 | |
… | |
… | |
159 | left corner of the terminal window)- the result is pseudo-transparency: |
159 | left corner of the terminal window)- the result is pseudo-transparency: |
160 | the image seems to be static while the window is moved around. |
160 | the image seems to be static while the window is moved around. |
161 | |
161 | |
162 | =head2 COLOUR SPECIFICATIONS |
162 | =head2 COLOUR SPECIFICATIONS |
163 | |
163 | |
164 | Whenever an oprator expects a "colour", then this can be specified in one |
164 | Whenever an operator expects a "colour", then this can be specified in one |
165 | of two ways: Either as string with an X11 colour specification, such as: |
165 | of two ways: Either as string with an X11 colour specification, such as: |
166 | |
166 | |
167 | "red" # named colour |
167 | "red" # named colour |
168 | "#f00" # simple rgb |
168 | "#f00" # simple rgb |
169 | "[50]red" # red with 50% alpha |
169 | "[50]red" # red with 50% alpha |
… | |
… | |
289 | uses it), then the in-memory copy us returned instead. |
289 | uses it), then the in-memory copy us returned instead. |
290 | |
290 | |
291 | =item load_uc $path |
291 | =item load_uc $path |
292 | |
292 | |
293 | Load uncached - same as load, but does not cache the image, which means it |
293 | Load uncached - same as load, but does not cache the image, which means it |
294 | is I<always> loaded from the filesystem again. |
294 | is I<always> loaded from the filesystem again, even if another copy of it |
|
|
295 | is in memory at the time. |
295 | |
296 | |
296 | =cut |
297 | =cut |
|
|
298 | |
|
|
299 | sub load_uc($) { |
|
|
300 | $self->new_img_from_file ($_[0]) |
|
|
301 | } |
297 | |
302 | |
298 | sub load($) { |
303 | sub load($) { |
299 | my ($path) = @_; |
304 | my ($path) = @_; |
300 | |
305 | |
301 | $_IMG_CACHE{$path} || do { |
306 | $_IMG_CACHE{$path} || do { |
302 | my $img = $self->new_img_from_file ($path); |
307 | my $img = load_uc $path; |
303 | Scalar::Util::weaken ($_IMG_CACHE{$path} = $img); |
308 | Scalar::Util::weaken ($_IMG_CACHE{$path} = $img); |
304 | $img |
309 | $img |
305 | } |
310 | } |
306 | } |
311 | } |
307 | |
312 | |
… | |
… | |
900 | C<keep> block so it only is reevaluated as required. |
905 | C<keep> block so it only is reevaluated as required. |
901 | |
906 | |
902 | Putting the blur into a C<keep> block will make sure the blur is only done |
907 | Putting the blur into a C<keep> block will make sure the blur is only done |
903 | once, while the C<rootalign> is still done each time the window moves. |
908 | once, while the C<rootalign> is still done each time the window moves. |
904 | |
909 | |
905 | rootlign keep { blur 10, root } |
910 | rootalign keep { blur 10, root } |
906 | |
911 | |
907 | This leaves the question of how to force reevaluation of the block, |
912 | This leaves the question of how to force reevaluation of the block, |
908 | in case the root background changes: If expression inside the block |
913 | in case the root background changes: If expression inside the block |
909 | is sensitive to some event (root background changes, window geometry |
914 | is sensitive to some event (root background changes, window geometry |
910 | changes), then it will be reevaluated automatically as needed. |
915 | changes), then it will be reevaluated automatically as needed. |