… | |
… | |
194 | =item tile $img |
194 | =item tile $img |
195 | |
195 | |
196 | Tiles the whole plane with the image and returns this new image - or in |
196 | Tiles the whole plane with the image and returns this new image - or in |
197 | other words, it returns a copy of the image in plane tiling mode. |
197 | other words, it returns a copy of the image in plane tiling mode. |
198 | |
198 | |
|
|
199 | Example: load an image and tile it over the background, without |
|
|
200 | resizing. The C<tile> call is superfluous because C<load> already defaults |
|
|
201 | to tiling mode. |
|
|
202 | |
|
|
203 | tile load "mybg.png" |
|
|
204 | |
199 | =item mirror $img |
205 | =item mirror $img |
200 | |
206 | |
201 | Similar to tile, but reflects the image each time it uses a new copy, so |
207 | Similar to tile, but reflects the image each time it uses a new copy, so |
202 | that top edges always touch top edges, right edges always touch right |
208 | that top edges always touch top edges, right edges always touch right |
203 | edges and so on (with normal tiling, left edges always touch right edges |
209 | edges and so on (with normal tiling, left edges always touch right edges |
204 | and top always touch bottom edges). |
210 | and top always touch bottom edges). |
205 | |
211 | |
|
|
212 | Exmaple: load an image and mirror it over the background, avoiding sharp |
|
|
213 | edges 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 | |
208 | Takes an image and modifies it so that all pixels outside the image area |
219 | Takes an image and modifies it so that all pixels outside the image area |
209 | become transparent. This mode is most useful when you want to place an |
220 | become transparent. This mode is most useful when you want to place an |
210 | image over another image or the background colour while leaving all |
221 | image over another image or the background colour while leaving all |
211 | background pixels outside the image unchanged. |
222 | background pixels outside the image unchanged. |
212 | |
223 | |
|
|
224 | Example: load an image and display it in the upper left corner. The rets |
|
|
225 | of the space is left "empty" (transparent or wahtever your compisotr does |
|
|
226 | in alpha mode, else background colour). |
|
|
227 | |
|
|
228 | pad load "mybg.png" |
|
|
229 | |
213 | =item extend $img |
230 | =item extend $img |
214 | |
231 | |
215 | Extends the image over the whole plane, using the closest pixel in the |
232 | Extends the image over the whole plane, using the closest pixel in the |
216 | area outside the image. This mode is mostly useful when you more complex |
233 | area outside the image. This mode is mostly useful when you more complex |
217 | filtering operations and want the pixels outside the image to have the |
234 | filtering operations and want the pixels outside the image to have the |
218 | same values as the pixels near the edge. |
235 | same values as the pixels near the edge. |
|
|
236 | |
|
|
237 | Example: 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 | } |