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.28 by root, Thu Jun 7 12:56:27 2012 UTC vs.
Revision 1.30 by root, Thu Jun 7 13:22:06 2012 UTC

4#:META:X_RESOURCE:%.enable:boolean:some boolean 4#:META:X_RESOURCE:%.enable:boolean:some boolean
5#:META:X_RESOURCE:%.extra.:value:extra config 5#:META:X_RESOURCE:%.extra.:value:extra config
6 6
7our $EXPR; 7our $EXPR;
8#$EXPR = 'move W * 0.1, -H * 0.1, resize W * 0.5, H * 0.5, repeat_none load "opensource.png"'; 8#$EXPR = 'move W * 0.1, -H * 0.1, resize W * 0.5, H * 0.5, repeat_none load "opensource.png"';
9$EXPR = 'border; move -X, -Y, load "argb.png"'; 9$EXPR = 'move -TX, -TY, load "argb.png"';
10#$EXPR = ' 10#$EXPR = '
11# rotate W, H, 50, 50, counter 1/59.95, repeat_mirror, 11# rotate W, H, 50, 50, counter 1/59.95, repeat_mirror,
12# clip X, Y, W, H, repeat_mirror, 12# clip X, Y, W, H, repeat_mirror,
13# load "/root/pix/das_fette_schwein.jpg" 13# load "/root/pix/das_fette_schwein.jpg"
14#'; 14#';
17#$EXPR = 'blur move (root, -x, -y), 5, 5' 17#$EXPR = 'blur move (root, -x, -y), 5, 5'
18#resize load "/root/pix/das_fette_schwein.jpg", w, h 18#resize load "/root/pix/das_fette_schwein.jpg", w, h
19 19
20use Safe; 20use Safe;
21 21
22our $border;
23our ($bgdsl_self, $old, $new); 22our ($bgdsl_self, $old, $new);
24our ($l, $t, $w, $h); 23our ($x, $y, $w, $h);
25 24
26# enforce at least this interval between updates 25# enforce at least this interval between updates
27our $MIN_INTERVAL = 1/100; 26our $MIN_INTERVAL = 1/100;
28 27
29{ 28{
30 package urxvt::bgdsl; # background language 29 package urxvt::bgdsl; # background language
31 30
32# *repeat_empty = \&urxvt::RepeatNone;
33# *repeat_tile = \&urxvt::RepeatNormal;
34# *repeat_pad = \&urxvt::RepeatPad;
35# *repeat_mirror = \&urxvt::RepeatReflect;
36
37=head2 PROVIDERS/GENERATORS 31=head2 PROVIDERS/GENERATORS
38 32
39=over 4 33=over 4
40 34
41=item load $path 35=item load $path
36
37Loads the image at the given C<$path>. The image is set to plane tiling
38mode.
39
40
42 41
43=cut 42=cut
44 43
45 sub load($) { 44 sub load($) {
46 my ($path) = @_; 45 my ($path) = @_;
65 64
66=over 4 65=over 4
67 66
68=cut 67=cut
69 68
70 sub X() { $new->{position_sensitive} = 1; $l } 69 sub TX() { $new->{position_sensitive} = 1; $x }
71 sub Y() { $new->{position_sensitive} = 1; $t } 70 sub TY() { $new->{position_sensitive} = 1; $y }
72 sub W() { $new->{size_sensitive} = 1; $w } 71 sub TW() { $new->{size_sensitive} = 1; $w }
73 sub H() { $new->{size_sensitive} = 1; $h } 72 sub TH() { $new->{size_sensitive} = 1; $h }
74 73
75 sub now() { urxvt::NOW } 74 sub now() { urxvt::NOW }
76 75
77 sub again($) { 76 sub again($) {
78 $new->{again} = $_[0]; 77 $new->{again} = $_[0];
185 184
186=cut 185=cut
187 186
188 sub clip($;$$;$$) { 187 sub clip($;$$;$$) {
189 my $img = pop; 188 my $img = pop;
190 my $h = pop || H; 189 my $h = pop || TH;
191 my $w = pop || W; 190 my $w = pop || TW;
192 $img->sub_rect ($_[0], $_[1], $w, $h) 191 $img->sub_rect ($_[0], $_[1], $w, $h)
193 } 192 }
194 193
195=item scale $img 194=item scale $img
196 195
217 sub scale($$$) { 216 sub scale($$$) {
218 my $img = pop; 217 my $img = pop;
219 218
220 @_ == 2 ? $img->scale ($_[0] * $img->w * 0.01, $_[1] * $img->h * 0.01) 219 @_ == 2 ? $img->scale ($_[0] * $img->w * 0.01, $_[1] * $img->h * 0.01)
221 : @_ ? $img->scale ($_[0] * $img->w * 0.01, $_[0] * $img->h * 0.01) 220 : @_ ? $img->scale ($_[0] * $img->w * 0.01, $_[0] * $img->h * 0.01)
222 : $img->scale (W, H) 221 : $img->scale (TW, TH)
223 } 222 }
224 223
225 sub resize($$$) { 224 sub resize($$$) {
226 my $img = pop; 225 my $img = pop;
227 $img->scale ($_[0], $_[1]) 226 $img->scale ($_[0], $_[1])
228 } 227 }
229 228
230 # TODO: ugly
231 sub move($$;$) { 229 sub move($$;$) {
232 my $img = pop->clone; 230 my $img = pop->clone;
233 $img->move ($_[0], $_[1]); 231 $img->move ($_[0], $_[1]);
234 $img 232 $img
235# my $img = pop;
236# $img->sub_rect (
237# $_[0], $_[1],
238# $img->w, $img->h,
239# $_[2],
240# )
241 } 233 }
242 234
243 sub rotate($$$$$$) { 235 sub rotate($$$$$$) {
244 my $img = pop; 236 my $img = pop;
245 $img->rotate ( 237 $img->rotate (
251 ) 243 )
252 } 244 }
253 245
254 sub blur($$;$) { 246 sub blur($$;$) {
255 my $img = pop; 247 my $img = pop;
256
257 $img->blur ($_[0], @_ >= 2 ? $_[1] : $_[0]); 248 $img->blur ($_[0], @_ >= 2 ? $_[1] : $_[0])
258 } 249 }
259 250
260 sub contrast($$;$$;$) { 251 sub contrast($$;$$;$) {
261 my $img = pop; 252 my $img = pop;
262 my ($r, $g, $b, $a) = @_; 253 my ($r, $g, $b, $a) = @_;
277 $a = 1 if @_ < 5; 268 $a = 1 if @_ < 5;
278 269
279 $img = $img->clone; 270 $img = $img->clone;
280 $img->brightness ($r, $g, $b, $a); 271 $img->brightness ($r, $g, $b, $a);
281 $img 272 $img
282 }
283
284=back
285
286=head2 SETTINGS
287
288=over 4
289
290=item border $respect_border=1
291
292Sets whether the image should respect the terminal border (argument true
293or missing), or whether it should fill the whole window (the default).
294
295By default, the image will cover the whole toplevel window. If C<border>
296is enabled, then it will only fill the character area and leave a normal
297border in the background colour around it and behind the scrollbar.
298
299=cut
300
301 sub border {
302 $border = @_ ? $_[0] : 1;
303 } 273 }
304 274
305=back 275=back
306 276
307=cut 277=cut
338 $self->{next_refresh} = urxvt::NOW + $MIN_INTERVAL; 308 $self->{next_refresh} = urxvt::NOW + $MIN_INTERVAL;
339 309
340 # set environment to evaluate user expression 310 # set environment to evaluate user expression
341 311
342 local $bgdsl_self = $self; 312 local $bgdsl_self = $self;
343 local $border;
344 313
345 local $old = $self->{state}; 314 local $old = $self->{state};
346 local $new = my $state = $self->{state} = {}; 315 local $new = my $state = $self->{state} = {};
347 316
317 my $border = 0; #d#
318
348 ($l, $t, $w, $h) = 319 ($x, $y, $w, $h) =
349 $self->get_geometry; 320 $self->background_geometry ($border);
350
351 warn "$l,$t,$w,$h\n";#d#
352 321
353 # evaluate user expression 322 # evaluate user expression
354 323
355 my $img = eval { $self->{expr}->() }; 324 my $img = eval { $self->{expr}->() };
356 warn $@ if $@;#d# 325 warn $@ if $@;#d#

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines