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.57 by root, Thu Jun 14 18:06:15 2012 UTC vs.
Revision 1.62 by root, Sun Jun 17 21:58:18 2012 UTC

258 } 258 }
259 259
260=item root 260=item root
261 261
262Returns the root window pixmap, that is, hopefully, the background image 262Returns the root window pixmap, that is, hopefully, the background image
263of your screen. The image is set to extend mode. 263of your screen.
264 264
265This function makes your expression root sensitive, that means it will be 265This function makes your expression root sensitive, that means it will be
266reevaluated when the bg image changes. 266reevaluated when the bg image changes.
267 267
268=cut 268=cut
285=cut 285=cut
286 286
287 sub solid($;$$) { 287 sub solid($;$$) {
288 my $colour = pop; 288 my $colour = pop;
289 289
290 my $img = $self->new_img (urxvt::PictStandardARGB32, $_[0] || 1, $_[1] || 1); 290 my $img = $self->new_img (urxvt::PictStandardARGB32, 0, 0, $_[0] || 1, $_[1] || 1);
291 $img->fill ($colour); 291 $img->fill ($colour);
292 $img 292 $img
293 } 293 }
294 294
295=item clone $img 295=item clone $img
304 } 304 }
305 305
306=item merge $img ... 306=item merge $img ...
307 307
308Takes any number of images and merges them together, creating a single 308Takes any number of images and merges them together, creating a single
309image containing them all. 309image containing them all. The tiling mode of the first image is used as
310the tiling mdoe of the resulting image.
311
312This function is called automatically when an expression returns multiple
313images.
310 314
311=cut 315=cut
312 316
313 sub merge(@) { 317 sub merge(@) {
314 #TODO 318 return $_[0] unless $#_;
319
320 # rather annoyingly clumsy, but optimisation is for another time
321
322 my $x0 = +1e9;
323 my $y0 = +1e9;
324 my $x1 = -1e9;
325 my $y1 = -1e9;
326
327 for (@_) {
328 my ($x, $y, $w, $h) = $_->geometry;
329
330 $x0 = $x if $x0 > $x;
331 $y0 = $y if $y0 > $y;
332
333 $x += $w;
334 $y += $h;
335
336 $x1 = $x if $x1 < $x;
337 $y1 = $y if $y1 < $y;
338 }
339
340 my $base = $self->new_img (urxvt::PictStandardARGB32, $x0, $y0, $x1 - $x0, $y1 - $y0);
341 $base->repeat_mode ($_[0]->repeat_mode);
342 $base->fill ([0, 0, 0, 0]);
343
344 $base->draw ($_)
345 for @_;
346
347 $base
315 } 348 }
316 349
317=head2 TILING MODES 350=head2 TILING MODES
318 351
319The following operators modify the tiling mode of an image, that is, the 352The following operators modify the tiling mode of an image, that is, the
671=cut 704=cut
672 705
673 sub rotate($$$$) { 706 sub rotate($$$$) {
674 my $img = pop; 707 my $img = pop;
675 $img->rotate ( 708 $img->rotate (
676 $_[0] * $img->w, 709 $_[0] * ($img->w + $img->x),
677 $_[1] * $img->h, 710 $_[1] * ($img->h + $img->y),
678 $_[2] * (3.14159265 / 180), 711 $_[2] * (3.14159265 / 180),
679 ) 712 )
680 } 713 }
681 714
682=back 715=back
879 ($x, $y, $w, $h) = 912 ($x, $y, $w, $h) =
880 $self->background_geometry ($self->{border}); 913 $self->background_geometry ($self->{border});
881 914
882 # evaluate user expression 915 # evaluate user expression
883 916
884 my $img = eval { $self->{expr}->() }; 917 my $img = eval { urxvt::bgdsl::merge $self->{expr}->() };
885 warn $@ if $@;#d# 918 die $@ if $@;
886 die "background-expr did not return an image.\n" if !UNIVERSAL::isa $img, "urxvt::img"; 919 die "background-expr did not return an image.\n" if !UNIVERSAL::isa $img, "urxvt::img";
887 920
888 # if the expression is sensitive to external events, prepare reevaluation then 921 # if the expression is sensitive to external events, prepare reevaluation then
889 922
890 my $again = delete $state->{again}; 923 my $again = delete $state->{again};

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines