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.33 by root, Thu Jun 7 16:30:58 2012 UTC vs.
Revision 1.34 by root, Thu Jun 7 17:04:33 2012 UTC

194=item tile $img 194=item tile $img
195 195
196Tiles the whole plane with the image and returns this new image - or in 196Tiles the whole plane with the image and returns this new image - or in
197other words, it returns a copy of the image in plane tiling mode. 197other words, it returns a copy of the image in plane tiling mode.
198 198
199Example: load an image and tile it over the background, without
200resizing. The C<tile> call is superfluous because C<load> already defaults
201to tiling mode.
202
203 tile load "mybg.png"
204
199=item mirror $img 205=item mirror $img
200 206
201Similar to tile, but reflects the image each time it uses a new copy, so 207Similar to tile, but reflects the image each time it uses a new copy, so
202that top edges always touch top edges, right edges always touch right 208that top edges always touch top edges, right edges always touch right
203edges and so on (with normal tiling, left edges always touch right edges 209edges and so on (with normal tiling, left edges always touch right edges
204and top always touch bottom edges). 210and top always touch bottom edges).
205 211
212Exmaple: load an image and mirror it over the background, avoiding sharp
213edges at the image borders at the expense of mirroring the image itself
214
215 mirror load "mybg.png"
216
206=item pad $img 217=item pad $img
207 218
208Takes an image and modifies it so that all pixels outside the image area 219Takes an image and modifies it so that all pixels outside the image area
209become transparent. This mode is most useful when you want to place an 220become transparent. This mode is most useful when you want to place an
210image over another image or the background colour while leaving all 221image over another image or the background colour while leaving all
211background pixels outside the image unchanged. 222background pixels outside the image unchanged.
212 223
224Example: load an image and display it in the upper left corner. The rets
225of the space is left "empty" (transparent or wahtever your compisotr does
226in alpha mode, else background colour).
227
228 pad load "mybg.png"
229
213=item extend $img 230=item extend $img
214 231
215Extends the image over the whole plane, using the closest pixel in the 232Extends the image over the whole plane, using the closest pixel in the
216area outside the image. This mode is mostly useful when you more complex 233area outside the image. This mode is mostly useful when you more complex
217filtering operations and want the pixels outside the image to have the 234filtering operations and want the pixels outside the image to have the
218same values as the pixels near the edge. 235same values as the pixels near the edge.
236
237Example: just for curiosity, how does this pixel extension stuff work?
238
239 extend move 50, 50, load "mybg.png"
219 240
220=cut 241=cut
221 242
222 sub pad($) { 243 sub pad($) {
223 my $img = $_[0]->clone; 244 my $img = $_[0]->clone;
420 # evaluate user expression 441 # evaluate user expression
421 442
422 my $img = eval { $self->{expr}->() }; 443 my $img = eval { $self->{expr}->() };
423 warn $@ if $@;#d# 444 warn $@ if $@;#d#
424 die if !UNIVERSAL::isa $img, "urxvt::img"; 445 die if !UNIVERSAL::isa $img, "urxvt::img";
446
447 $state->{size_sensitive} = 1
448 if $img->repeat_mode != urxvt::RepeatNormal;
425 449
426 # if the expression is sensitive to external events, prepare reevaluation then 450 # if the expression is sensitive to external events, prepare reevaluation then
427 451
428 my $repeat; 452 my $repeat;
429 453
465 unless ($repeat) { 489 unless ($repeat) {
466 delete $self->{state}; 490 delete $self->{state};
467 delete $self->{expr}; 491 delete $self->{expr};
468 } 492 }
469 493
470 # prepare and set background pixmap 494 # set background pixmap
471
472 $img = $img->sub_rect (0, 0, $w, $h)
473 if $img->w != $w || $img->h != $h;
474 495
475 $self->set_background ($img, $self->{border}); 496 $self->set_background ($img, $self->{border});
476 $self->scr_recolour (0); 497 $self->scr_recolour (0);
477 $self->want_refresh; 498 $self->want_refresh;
478} 499}

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines