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.69 by root, Mon Jul 2 01:32:26 2012 UTC vs.
Revision 1.74 by root, Sat Jul 14 08:42:54 2012 UTC

74 return load "$HOME/sunday.png"; 74 return load "$HOME/sunday.png";
75 } 75 }
76 } 76 }
77 77
78This inner expression is evaluated once per hour (and whenever the 78This inner expression is evaluated once per hour (and whenever the
79temrinal window is resized). It sets F<sunday.png> as background on 79terminal window is resized). It sets F<sunday.png> as background on
80Sundays, and F<weekday.png> on all other days. 80Sundays, and F<weekday.png> on all other days.
81 81
82Fortunately, we expect that most expressions will be much simpler, with 82Fortunately, we expect that most expressions will be much simpler, with
83little Perl knowledge needed. 83little Perl knowledge needed.
84 84
119width and doubles the image height: 119width 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
123IF you try out these expressions, you might suffer from some sluggishness, 123IF you try out these expressions, you might suffer from some sluggishness,
124because each time the terminal is resized, it loads the PNG image agin 124because each time the terminal is resized, it loads the PNG image again
125and scales it. Scaling is usually fast (and unavoidable), but loading the 125and scales it. Scaling is usually fast (and unavoidable), but loading the
126image can be quite time consuming. This is where C<keep> comes in handy: 126image 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
157This one first takes a snapshot of the screen background image, and then 157This one first takes a snapshot of the screen background image, and then
158moves it to the upper left corner of the screen (as opposed to the upper 158moves it to the upper left corner of the screen (as opposed to the upper
159left corner of the terminal window)- the result is pseudo-transparency: 159left corner of the terminal window)- the result is pseudo-transparency:
160the image seems to be static while the window is moved around. 160the image seems to be static while the window is moved around.
161
162=head2 COLOUR SPECIFICATIONS
163
164Whenever an operator expects a "colour", then this can be specified in one
165of 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
172OR 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
164Since some operations (such as C<load> and C<blur>) can take a long time, 180Since some operations (such as C<load> and C<blur>) can take a long time,
165caching results can be very important for a smooth operation. Caching can 181caching results can be very important for a smooth operation. Caching can
273uses it), then the in-memory copy us returned instead. 289uses it), then the in-memory copy us returned instead.
274 290
275=item load_uc $path 291=item load_uc $path
276 292
277Load uncached - same as load, but does not cache the image, which means it 293Load uncached - same as load, but does not cache the image, which means it
278is I<always> loaded from the filesystem again. 294is I<always> loaded from the filesystem again, even if another copy of it
295is in memory at the time.
279 296
280=cut 297=cut
298
299 sub load_uc($) {
300 $self->new_img_from_file ($_[0])
301 }
281 302
282 sub load($) { 303 sub load($) {
283 my ($path) = @_; 304 my ($path) = @_;
284 305
285 $_IMG_CACHE{$path} || do { 306 $_IMG_CACHE{$path} || do {
286 my $img = $self->new_img_from_file ($path); 307 my $img = load_uc $path;
287 Scalar::Util::weaken ($_IMG_CACHE{$path} = $img); 308 Scalar::Util::weaken ($_IMG_CACHE{$path} = $img);
288 $img 309 $img
289 } 310 }
290 } 311 }
291 312
750 771
751The following operators change the pixels of the image. 772The following operators change the pixels of the image.
752 773
753=over 4 774=over 4
754 775
776=item tint $color, $img
777
778Tints the image in the given colour.
779
780Example: tint the image red.
781
782 tint "red", load "rgb.png"
783
784Example: 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
755=item contrast $factor, $img 794=item contrast $factor, $img
756 795
757=item contrast $r, $g, $b, $img 796=item contrast $r, $g, $b, $img
758 797
759=item contrast $r, $g, $b, $a, $img 798=item contrast $r, $g, $b, $a, $img
866C<keep> block so it only is reevaluated as required. 905C<keep> block so it only is reevaluated as required.
867 906
868Putting the blur into a C<keep> block will make sure the blur is only done 907Putting the blur into a C<keep> block will make sure the blur is only done
869once, while the C<rootalign> is still done each time the window moves. 908once, while the C<rootalign> is still done each time the window moves.
870 909
871 rootlign keep { blur 10, root } 910 rootalign keep { blur 10, root }
872 911
873This leaves the question of how to force reevaluation of the block, 912This leaves the question of how to force reevaluation of the block,
874in case the root background changes: If expression inside the block 913in case the root background changes: If expression inside the block
875is sensitive to some event (root background changes, window geometry 914is sensitive to some event (root background changes, window geometry
876changes), then it will be reevaluated automatically as needed. 915changes), then it will be reevaluated automatically as needed.
928 967
929# compiles a parsed expression 968# compiles a parsed expression
930sub set_expr { 969sub set_expr {
931 my ($self, $expr) = @_; 970 my ($self, $expr) = @_;
932 971
933 $self->{root} = []; 972 $self->{root} = []; # the outermost frame
934 $self->{expr} = $expr; 973 $self->{expr} = $expr;
935 $self->recalculate; 974 $self->recalculate;
936} 975}
937 976
938# takes a hash of sensitivity indicators and installs watchers 977# takes a hash of sensitivity indicators and installs watchers
1000 1039
1001 # set environment to evaluate user expression 1040 # set environment to evaluate user expression
1002 1041
1003 local $self = $arg_self; 1042 local $self = $arg_self;
1004 local $HOME = $ENV{HOME}; 1043 local $HOME = $ENV{HOME};
1005 local $frame = []; 1044 local $frame = $self->{root};
1006 1045
1007 ($x, $y, $w, $h) = $self->background_geometry ($self->{border}); 1046 ($x, $y, $w, $h) = $self->background_geometry ($self->{border});
1008 1047
1009 # evaluate user expression 1048 # evaluate user expression
1010 1049

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines