… | |
… | |
258 | } |
258 | } |
259 | |
259 | |
260 | =item root |
260 | =item root |
261 | |
261 | |
262 | Returns the root window pixmap, that is, hopefully, the background image |
262 | Returns the root window pixmap, that is, hopefully, the background image |
263 | of your screen. The image is set to extend mode. |
263 | of your screen. |
264 | |
264 | |
265 | This function makes your expression root sensitive, that means it will be |
265 | This function makes your expression root sensitive, that means it will be |
266 | reevaluated when the bg image changes. |
266 | reevaluated 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 |
… | |
… | |
303 | $_[0]->clone |
303 | $_[0]->clone |
304 | } |
304 | } |
305 | |
305 | |
306 | =item merge $img ... |
306 | =item merge $img ... |
307 | |
307 | |
308 | Takes any number of images and merges them together, creating a single image containing them all. |
308 | Takes any number of images and merges them together, creating a single |
|
|
309 | image containing them all. The tiling mode of the first image is used as |
|
|
310 | the tiling mdoe of the resulting image. |
|
|
311 | |
|
|
312 | This function is called automatically when an expression returns multiple |
|
|
313 | images. |
309 | |
314 | |
310 | =cut |
315 | =cut |
311 | |
316 | |
312 | sub merge(@) { |
317 | sub merge(@) { |
313 | #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 |
314 | } |
348 | } |
315 | |
349 | |
316 | =head2 TILING MODES |
350 | =head2 TILING MODES |
317 | |
351 | |
318 | The following operators modify the tiling mode of an image, that is, the |
352 | The following operators modify the tiling mode of an image, that is, the |
… | |
… | |
670 | =cut |
704 | =cut |
671 | |
705 | |
672 | sub rotate($$$$) { |
706 | sub rotate($$$$) { |
673 | my $img = pop; |
707 | my $img = pop; |
674 | $img->rotate ( |
708 | $img->rotate ( |
675 | $_[0] * $img->w, |
709 | $_[0] * ($img->w + $img->x), |
676 | $_[1] * $img->h, |
710 | $_[1] * ($img->h + $img->y), |
677 | $_[2] * (3.14159265 / 180), |
711 | $_[2] * (3.14159265 / 180), |
678 | ) |
712 | ) |
679 | } |
713 | } |
680 | |
714 | |
681 | =back |
715 | =back |
… | |
… | |
878 | ($x, $y, $w, $h) = |
912 | ($x, $y, $w, $h) = |
879 | $self->background_geometry ($self->{border}); |
913 | $self->background_geometry ($self->{border}); |
880 | |
914 | |
881 | # evaluate user expression |
915 | # evaluate user expression |
882 | |
916 | |
883 | my $img = eval { $self->{expr}->() }; |
917 | my $img = eval { urxvt::bgdsl::merge $self->{expr}->() }; |
884 | warn $@ if $@;#d# |
918 | die $@ if $@; |
885 | 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"; |
886 | |
920 | |
887 | # if the expression is sensitive to external events, prepare reevaluation then |
921 | # if the expression is sensitive to external events, prepare reevaluation then |
888 | |
922 | |
889 | my $again = delete $state->{again}; |
923 | my $again = delete $state->{again}; |