… | |
… | |
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 | |
… | |
… | |
156 | |
156 | |
157 | This one first takes a snapshot of the screen background image, and then |
157 | This one first takes a snapshot of the screen background image, and then |
158 | moves it to the upper left corner of the screen (as opposed to the upper |
158 | moves it to the upper left corner of the screen (as opposed to the upper |
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 | |
|
|
162 | =head2 COLOUR SPECIFICATIONS |
|
|
163 | |
|
|
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: |
|
|
166 | |
|
|
167 | "red" # named colour |
|
|
168 | "#f00" # simple rgb |
|
|
169 | "[50]red" # red with 50% alpha |
|
|
170 | "TekHVC:300/50/50" # anything goes |
|
|
171 | |
|
|
172 | OR as an array reference with one, three or four components: |
|
|
173 | |
|
|
174 | [0.5] # 50% gray, 100% alpha |
|
|
175 | [0.5, 0, 0] # dark red, no green or blur, 100% alpha |
|
|
176 | [0.5, 0, 0, 0.7] # same with explicit 70% alpha |
161 | |
177 | |
162 | =head2 CACHING AND SENSITIVITY |
178 | =head2 CACHING AND SENSITIVITY |
163 | |
179 | |
164 | Since some operations (such as C<load> and C<blur>) can take a long time, |
180 | Since some operations (such as C<load> and C<blur>) can take a long time, |
165 | caching results can be very important for a smooth operation. Caching can |
181 | caching results can be very important for a smooth operation. Caching can |
… | |
… | |
273 | uses it), then the in-memory copy us returned instead. |
289 | uses it), then the in-memory copy us returned instead. |
274 | |
290 | |
275 | =item load_uc $path |
291 | =item load_uc $path |
276 | |
292 | |
277 | 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 |
278 | 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. |
279 | |
296 | |
280 | =cut |
297 | =cut |
281 | |
298 | |
282 | sub load_uc($) { |
299 | sub load_uc($) { |
283 | $self->new_img_from_file ($path) |
300 | $self->new_img_from_file ($_[0]) |
284 | } |
301 | } |
285 | |
302 | |
286 | sub load($) { |
303 | sub load($) { |
287 | my ($path) = @_; |
304 | my ($path) = @_; |
288 | |
305 | |
… | |
… | |
754 | |
771 | |
755 | The following operators change the pixels of the image. |
772 | The following operators change the pixels of the image. |
756 | |
773 | |
757 | =over 4 |
774 | =over 4 |
758 | |
775 | |
|
|
776 | =item tint $color, $img |
|
|
777 | |
|
|
778 | Tints the image in the given colour. |
|
|
779 | |
|
|
780 | Example: tint the image red. |
|
|
781 | |
|
|
782 | tint "red", load "rgb.png" |
|
|
783 | |
|
|
784 | Example: the same, but specify the colour by component. |
|
|
785 | |
|
|
786 | tint [1, 0, 0], load "rgb.png" |
|
|
787 | |
|
|
788 | =cut |
|
|
789 | |
|
|
790 | sub tint($$) { |
|
|
791 | $_[1]->tint ($_[0]) |
|
|
792 | } |
|
|
793 | |
759 | =item contrast $factor, $img |
794 | =item contrast $factor, $img |
760 | |
795 | |
761 | =item contrast $r, $g, $b, $img |
796 | =item contrast $r, $g, $b, $img |
762 | |
797 | |
763 | =item contrast $r, $g, $b, $a, $img |
798 | =item contrast $r, $g, $b, $a, $img |
… | |
… | |
870 | C<keep> block so it only is reevaluated as required. |
905 | C<keep> block so it only is reevaluated as required. |
871 | |
906 | |
872 | 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 |
873 | 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. |
874 | |
909 | |
875 | rootlign keep { blur 10, root } |
910 | rootalign keep { blur 10, root } |
876 | |
911 | |
877 | 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, |
878 | in case the root background changes: If expression inside the block |
913 | in case the root background changes: If expression inside the block |
879 | is sensitive to some event (root background changes, window geometry |
914 | is sensitive to some event (root background changes, window geometry |
880 | changes), then it will be reevaluated automatically as needed. |
915 | changes), then it will be reevaluated automatically as needed. |
… | |
… | |
932 | |
967 | |
933 | # compiles a parsed expression |
968 | # compiles a parsed expression |
934 | sub set_expr { |
969 | sub set_expr { |
935 | my ($self, $expr) = @_; |
970 | my ($self, $expr) = @_; |
936 | |
971 | |
937 | $self->{root} = []; |
972 | $self->{root} = []; # the outermost frame |
938 | $self->{expr} = $expr; |
973 | $self->{expr} = $expr; |
939 | $self->recalculate; |
974 | $self->recalculate; |
940 | } |
975 | } |
941 | |
976 | |
942 | # takes a hash of sensitivity indicators and installs watchers |
977 | # takes a hash of sensitivity indicators and installs watchers |
… | |
… | |
1004 | |
1039 | |
1005 | # set environment to evaluate user expression |
1040 | # set environment to evaluate user expression |
1006 | |
1041 | |
1007 | local $self = $arg_self; |
1042 | local $self = $arg_self; |
1008 | local $HOME = $ENV{HOME}; |
1043 | local $HOME = $ENV{HOME}; |
1009 | local $frame = []; |
1044 | local $frame = $self->{root}; |
1010 | |
1045 | |
1011 | ($x, $y, $w, $h) = $self->background_geometry ($self->{border}); |
1046 | ($x, $y, $w, $h) = $self->background_geometry ($self->{border}); |
1012 | |
1047 | |
1013 | # evaluate user expression |
1048 | # evaluate user expression |
1014 | |
1049 | |