… | |
… | |
11 | =head1 SYNOPSIS |
11 | =head1 SYNOPSIS |
12 | |
12 | |
13 | urxvt --background-expr 'background expression' |
13 | urxvt --background-expr 'background expression' |
14 | --background-border |
14 | --background-border |
15 | --background-interval seconds |
15 | --background-interval seconds |
|
|
16 | |
|
|
17 | =head1 QUICK AND DIRTY CHEAT SHEET |
|
|
18 | |
|
|
19 | Just load a random jpeg image and tile the background with it without |
|
|
20 | scaling or anything else: |
|
|
21 | |
|
|
22 | load "/path/to/img.jpg" |
|
|
23 | |
|
|
24 | The same, but use mirroring/reflection instead of tiling: |
|
|
25 | |
|
|
26 | mirror load "/path/to/img.jpg" |
|
|
27 | |
|
|
28 | Load an image and scale it to exactly fill the terminal window: |
|
|
29 | |
|
|
30 | scale keep { load "/path/to/img.jpg" } |
|
|
31 | |
|
|
32 | Implement pseudo-transparency by using a suitably-aligned root pixmap |
|
|
33 | as window background: |
|
|
34 | |
|
|
35 | rootalign root |
|
|
36 | |
|
|
37 | Likewise, but keep a blurred copy: |
|
|
38 | |
|
|
39 | rootalign keep { blur 10, root } |
16 | |
40 | |
17 | =head1 DESCRIPTION |
41 | =head1 DESCRIPTION |
18 | |
42 | |
19 | This extension manages the terminal background by creating a picture that |
43 | This extension manages the terminal background by creating a picture that |
20 | is behind the text, replacing the normal background colour. |
44 | is behind the text, replacing the normal background colour. |
… | |
… | |
398 | for @_; |
422 | for @_; |
399 | |
423 | |
400 | $base |
424 | $base |
401 | } |
425 | } |
402 | |
426 | |
|
|
427 | =back |
|
|
428 | |
403 | =head2 TILING MODES |
429 | =head2 TILING MODES |
404 | |
430 | |
405 | The following operators modify the tiling mode of an image, that is, the |
431 | The following operators modify the tiling mode of an image, that is, the |
406 | way that pixels outside the image area are painted when the image is used. |
432 | way that pixels outside the image area are painted when the image is used. |
407 | |
433 | |
… | |
… | |
827 | latter in a white picture. |
853 | latter in a white picture. |
828 | |
854 | |
829 | Due to idiosyncrasies in the underlying XRender extension, biases less |
855 | Due to idiosyncrasies in the underlying XRender extension, biases less |
830 | than zero can be I<very> slow. |
856 | than zero can be I<very> slow. |
831 | |
857 | |
|
|
858 | You can also try the experimental(!) C<muladd> operator. |
|
|
859 | |
832 | =cut |
860 | =cut |
833 | |
861 | |
834 | sub contrast($$;$$;$) { |
862 | sub contrast($$;$$;$) { |
835 | my $img = pop; |
863 | my $img = pop; |
836 | my ($r, $g, $b, $a) = @_; |
864 | my ($r, $g, $b, $a) = @_; |
… | |
… | |
851 | $a = 1 if @_ < 4; |
879 | $a = 1 if @_ < 4; |
852 | |
880 | |
853 | $img = $img->clone; |
881 | $img = $img->clone; |
854 | $img->brightness ($r, $g, $b, $a); |
882 | $img->brightness ($r, $g, $b, $a); |
855 | $img |
883 | $img |
|
|
884 | } |
|
|
885 | |
|
|
886 | =item muladd $mul, $add, $img # EXPERIMENTAL |
|
|
887 | |
|
|
888 | First multipliesthe pixels by C<$mul>, then adds C<$add>. This cna be used |
|
|
889 | to implement brightness and contrast at the same time, with a wider value |
|
|
890 | range than contrast and brightness operators. |
|
|
891 | |
|
|
892 | Due to numerous bugs in XRender implementations, it can also introduce a |
|
|
893 | number of visual artifacts. |
|
|
894 | |
|
|
895 | Example: increase contrast by a factor of C<$c> without changing image |
|
|
896 | brightness too much. |
|
|
897 | |
|
|
898 | muladd $c, (1 - $c) * 0.5, $img |
|
|
899 | |
|
|
900 | =cut |
|
|
901 | |
|
|
902 | sub muladd($$$) { |
|
|
903 | $_[2]->muladd ($_[0], $_[1]) |
856 | } |
904 | } |
857 | |
905 | |
858 | =item blur $radius, $img |
906 | =item blur $radius, $img |
859 | |
907 | |
860 | =item blur $radius_horz, $radius_vert, $img |
908 | =item blur $radius_horz, $radius_vert, $img |
… | |
… | |
967 | |
1015 | |
968 | # compiles a parsed expression |
1016 | # compiles a parsed expression |
969 | sub set_expr { |
1017 | sub set_expr { |
970 | my ($self, $expr) = @_; |
1018 | my ($self, $expr) = @_; |
971 | |
1019 | |
972 | $self->{root} = []; |
1020 | $self->{root} = []; # the outermost frame |
973 | $self->{expr} = $expr; |
1021 | $self->{expr} = $expr; |
974 | $self->recalculate; |
1022 | $self->recalculate; |
975 | } |
1023 | } |
976 | |
1024 | |
977 | # takes a hash of sensitivity indicators and installs watchers |
1025 | # takes a hash of sensitivity indicators and installs watchers |
… | |
… | |
1039 | |
1087 | |
1040 | # set environment to evaluate user expression |
1088 | # set environment to evaluate user expression |
1041 | |
1089 | |
1042 | local $self = $arg_self; |
1090 | local $self = $arg_self; |
1043 | local $HOME = $ENV{HOME}; |
1091 | local $HOME = $ENV{HOME}; |
1044 | local $frame = []; |
1092 | local $frame = $self->{root}; |
1045 | |
1093 | |
1046 | ($x, $y, $w, $h) = $self->background_geometry ($self->{border}); |
1094 | ($x, $y, $w, $h) = $self->background_geometry ($self->{border}); |
1047 | |
1095 | |
1048 | # evaluate user expression |
1096 | # evaluate user expression |
1049 | |
1097 | |