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.44 by root, Sun Jun 10 11:31:22 2012 UTC vs.
Revision 1.45 by root, Sun Jun 10 11:53:32 2012 UTC

263 my $img = $self->new_img (urxvt::PictStandardARGB32, $_[0] || 1, $_[1] || 1); 263 my $img = $self->new_img (urxvt::PictStandardARGB32, $_[0] || 1, $_[1] || 1);
264 $img->fill ($colour); 264 $img->fill ($colour);
265 $img 265 $img
266 } 266 }
267 267
268=item clone $img
269
270Returns an exact copy of the image. This is useful if you want to have
271multiple copies of the same image to apply different effects to.
272
273=cut
274
275 sub clone($) {
276 $_[0]->clone
277 }
278
268=back 279=back
269 280
281=head2 TILING MODES
282
283The following operators modify the tiling mode of an image, that is, the
284way that pixels outside the image area are painted when the image is used.
285
286=over 4
287
288=item tile $img
289
290Tiles the whole plane with the image and returns this new image - or in
291other words, it returns a copy of the image in plane tiling mode.
292
293Example: load an image and tile it over the background, without
294resizing. The C<tile> call is superfluous because C<load> already defaults
295to tiling mode.
296
297 tile load "mybg.png"
298
299=item mirror $img
300
301Similar to tile, but reflects the image each time it uses a new copy, so
302that top edges always touch top edges, right edges always touch right
303edges and so on (with normal tiling, left edges always touch right edges
304and top always touch bottom edges).
305
306Example: load an image and mirror it over the background, avoiding sharp
307edges at the image borders at the expense of mirroring the image itself
308
309 mirror load "mybg.png"
310
311=item pad $img
312
313Takes an image and modifies it so that all pixels outside the image area
314become transparent. This mode is most useful when you want to place an
315image over another image or the background colour while leaving all
316background pixels outside the image unchanged.
317
318Example: load an image and display it in the upper left corner. The rest
319of the space is left "empty" (transparent or wahtever your compisotr does
320in alpha mode, else background colour).
321
322 pad load "mybg.png"
323
324=item extend $img
325
326Extends the image over the whole plane, using the closest pixel in the
327area outside the image. This mode is mostly useful when you more complex
328filtering operations and want the pixels outside the image to have the
329same values as the pixels near the edge.
330
331Example: just for curiosity, how does this pixel extension stuff work?
332
333 extend move 50, 50, load "mybg.png"
334
335=cut
336
337 sub pad($) {
338 my $img = $_[0]->clone;
339 $img->repeat_mode (urxvt::RepeatNone);
340 $img
341 }
342
343 sub tile($) {
344 my $img = $_[0]->clone;
345 $img->repeat_mode (urxvt::RepeatNormal);
346 $img
347 }
348
349 sub mirror($) {
350 my $img = $_[0]->clone;
351 $img->repeat_mode (urxvt::RepeatReflect);
352 $img
353 }
354
355 sub extend($) {
356 my $img = $_[0]->clone;
357 $img->repeat_mode (urxvt::RepeatPad);
358 $img
359 }
360
361=back
362
270=head2 VARIABLES 363=head2 VARIABLE VALUES
271 364
272The following functions provide variable data such as the terminal window 365The following functions provide variable data such as the terminal window
273dimensions. They are not (Perl-) variables, they jsut return stuff that 366dimensions. They are not (Perl-) variables, they just return stuff that
274varies. Most of them make your expression sensitive to some events, for 367varies. Most of them make your expression sensitive to some events, for
275example using C<TW> (terminal width) means your expression is evaluated 368example using C<TW> (terminal width) means your expression is evaluated
276again when the terminal is resized. 369again when the terminal is resized.
277 370
278=over 4 371=over 4
352 $self->{counter} + 0 445 $self->{counter} + 0
353 } 446 }
354 447
355=back 448=back
356 449
357=head2 TILING MODES 450=head2 SHAPE CHANGING OPERATORS
358 451
359The following operators modify the tiling mode of an image, that is, the 452The following operators modify the shape, size or position of the image.
360way that pixels outside the image area are painted when the image is used.
361 453
362=over 4 454=over 4
363
364=item tile $img
365
366Tiles the whole plane with the image and returns this new image - or in
367other words, it returns a copy of the image in plane tiling mode.
368
369Example: load an image and tile it over the background, without
370resizing. The C<tile> call is superfluous because C<load> already defaults
371to tiling mode.
372
373 tile load "mybg.png"
374
375=item mirror $img
376
377Similar to tile, but reflects the image each time it uses a new copy, so
378that top edges always touch top edges, right edges always touch right
379edges and so on (with normal tiling, left edges always touch right edges
380and top always touch bottom edges).
381
382Example: load an image and mirror it over the background, avoiding sharp
383edges at the image borders at the expense of mirroring the image itself
384
385 mirror load "mybg.png"
386
387=item pad $img
388
389Takes an image and modifies it so that all pixels outside the image area
390become transparent. This mode is most useful when you want to place an
391image over another image or the background colour while leaving all
392background pixels outside the image unchanged.
393
394Example: load an image and display it in the upper left corner. The rest
395of the space is left "empty" (transparent or wahtever your compisotr does
396in alpha mode, else background colour).
397
398 pad load "mybg.png"
399
400=item extend $img
401
402Extends the image over the whole plane, using the closest pixel in the
403area outside the image. This mode is mostly useful when you more complex
404filtering operations and want the pixels outside the image to have the
405same values as the pixels near the edge.
406
407Example: just for curiosity, how does this pixel extension stuff work?
408
409 extend move 50, 50, load "mybg.png"
410
411=cut
412
413 sub pad($) {
414 my $img = $_[0]->clone;
415 $img->repeat_mode (urxvt::RepeatNone);
416 $img
417 }
418
419 sub tile($) {
420 my $img = $_[0]->clone;
421 $img->repeat_mode (urxvt::RepeatNormal);
422 $img
423 }
424
425 sub mirror($) {
426 my $img = $_[0]->clone;
427 $img->repeat_mode (urxvt::RepeatReflect);
428 $img
429 }
430
431 sub extend($) {
432 my $img = $_[0]->clone;
433 $img->repeat_mode (urxvt::RepeatPad);
434 $img
435 }
436
437=back
438
439=head2 PIXEL OPERATORS
440
441The following operators modify the image pixels in various ways.
442
443=over 4
444
445=item clone $img
446
447Returns an exact copy of the image.
448
449=cut
450
451 sub clone($) {
452 $_[0]->clone
453 }
454 455
455=item clip $img 456=item clip $img
456 457
457=item clip $width, $height, $img 458=item clip $width, $height, $img
458 459
596 597
597 sub rootalign($) { 598 sub rootalign($) {
598 move -TX, -TY, $_[0] 599 move -TX, -TY, $_[0]
599 } 600 }
600 601
602=back
603
604=head2 COLOUR MODIFICATIONS
605
606The following operators change the pixels of the image.
607
608=over 4
609
601=item contrast $factor, $img 610=item contrast $factor, $img
602 611
603=item contrast $r, $g, $b, $img 612=item contrast $r, $g, $b, $img
604 613
605=item contrast $r, $g, $b, $a, $img 614=item contrast $r, $g, $b, $a, $img
606 615
607Adjusts the I<contrast> of an image. 616Adjusts the I<contrast> of an image.
608 617
609#TODO# 618The first form applies a single C<$factor> to red, green and blue, the
619second form applies separate factors to each colour channel, and the last
620form includes the alpha channel.
610 621
622Values from 0 to 1 lower the contrast, values higher than 1 increase the
623contrast.
624
625Due to limitations in the underlying XRender extension, lowering contrast
626also reduces brightness, while increasing contrast currently also
627increases brightness.
628
611=item brightness $factor, $img 629=item brightness $bias, $img
612 630
613=item brightness $r, $g, $b, $img 631=item brightness $r, $g, $b, $img
614 632
615=item brightness $r, $g, $b, $a, $img 633=item brightness $r, $g, $b, $a, $img
616 634
617Adjusts the brightness of an image. 635Adjusts the brightness of an image.
636
637The first form applies a single C<$bias> to red, green and blue, the
638second form applies separate biases to each colour channel, and the last
639form includes the alpha channel.
640
641Values less than 0 reduce brightness, while values larger than 0 increase
642it. Useful range is from -1 to 1 - the former results in a black, the
643latter in a white picture.
644
645Due to idiosynchrasies in the underlying XRender extension, biases less
646than zero can be I<very> slow.
618 647
619=cut 648=cut
620 649
621 sub contrast($$;$$;$) { 650 sub contrast($$;$$;$) {
622 my $img = pop; 651 my $img = pop;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines