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.56 by root, Thu Jun 14 17:06:57 2012 UTC vs.
Revision 1.61 by root, Fri Jun 15 19:50:56 2012 UTC

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
303 $_[0]->clone 303 $_[0]->clone
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 image containing them all. 308Takes any number of images and merges them together, creating a single
309image containing them all.
310
311This function is called automatically when an expression returns multiple
312images.
309 313
310=cut 314=cut
311 315
312 sub merge(@) { 316 sub merge(@) {
313 #TODO 317 return $_[0] unless $#_;
318
319 # rather annoyingly clumsy, but optimisation is for another time
320
321 my $x0 = +1e9;
322 my $y0 = +1e9;
323 my $x1 = -1e9;
324 my $y1 = -1e9;
325
326 for (@_) {
327 my ($x, $y, $w, $h) = $_->geometry;
328
329 $x0 = $x if $x0 > $x;
330 $y0 = $y if $y0 > $y;
331
332 $x += $w;
333 $y += $h;
334
335 $x1 = $x if $x1 < $x;
336 $y1 = $y if $y1 < $y;
337 }
338
339 my $base = $self->new_img (urxvt::PictStandardARGB32, $x0, $y0, $x1 - $x0, $y1 - $y0);
340 $base->fill ([0, 0, 0, 0]);
341
342 $base->draw ($_)
343 for @_;
344
345 $base
314 } 346 }
315 347
316=head2 TILING MODES 348=head2 TILING MODES
317 349
318The following operators modify the tiling mode of an image, that is, the 350The following operators modify the tiling mode of an image, that is, the
670=cut 702=cut
671 703
672 sub rotate($$$$) { 704 sub rotate($$$$) {
673 my $img = pop; 705 my $img = pop;
674 $img->rotate ( 706 $img->rotate (
675 $_[0] * $img->w, 707 $_[0] * ($img->w + $img->x),
676 $_[1] * $img->h, 708 $_[1] * ($img->h + $img->y),
677 $_[2] * (3.14159265 / 180), 709 $_[2] * (3.14159265 / 180),
678 ) 710 )
679 } 711 }
680 712
681=back 713=back
878 ($x, $y, $w, $h) = 910 ($x, $y, $w, $h) =
879 $self->background_geometry ($self->{border}); 911 $self->background_geometry ($self->{border});
880 912
881 # evaluate user expression 913 # evaluate user expression
882 914
883 my $img = eval { $self->{expr}->() }; 915 my $img = eval { urxvt::bgdsl::merge $self->{expr}->() };
884 warn $@ if $@;#d# 916 die $@ if $@;
885 die "background-expr did not return an image.\n" if !UNIVERSAL::isa $img, "urxvt::img"; 917 die "background-expr did not return an image.\n" if !UNIVERSAL::isa $img, "urxvt::img";
886 918
887 # if the expression is sensitive to external events, prepare reevaluation then 919 # if the expression is sensitive to external events, prepare reevaluation then
888 920
889 my $again = delete $state->{again}; 921 my $again = delete $state->{again};

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines