… | |
… | |
28 | { |
28 | { |
29 | package urxvt::bgdsl; # background language |
29 | package urxvt::bgdsl; # background language |
30 | |
30 | |
31 | =head2 PROVIDERS/GENERATORS |
31 | =head2 PROVIDERS/GENERATORS |
32 | |
32 | |
|
|
33 | These functions provide an image, by loading it from disk, grabbing it |
|
|
34 | from the root screen or by simply generating it. They are used as strating |
|
|
35 | points to get an image you can play with. |
|
|
36 | |
33 | =over 4 |
37 | =over 4 |
34 | |
38 | |
35 | =item load $path |
39 | =item load $path |
36 | |
40 | |
37 | Loads the image at the given C<$path>. The image is set to plane tiling |
41 | Loads the image at the given C<$path>. The image is set to plane tiling |
38 | mode. |
42 | mode. |
39 | |
43 | |
40 | |
44 | Loaded images will be cached for one cycle. |
41 | |
45 | |
42 | =cut |
46 | =cut |
43 | |
47 | |
44 | sub load($) { |
48 | sub load($) { |
45 | my ($path) = @_; |
49 | my ($path) = @_; |
46 | |
50 | |
47 | $new->{load}{$path} = $old->{load}{$path} || $bgdsl_self->new_img_from_file ($path); |
51 | $new->{load}{$path} = $old->{load}{$path} || $bgdsl_self->new_img_from_file ($path); |
48 | } |
52 | } |
|
|
53 | |
|
|
54 | =item root |
|
|
55 | |
|
|
56 | Returns the root window pixmap, that is, hopefully, the background image |
|
|
57 | of your screen. The image is set to extend mode. |
|
|
58 | |
|
|
59 | This function makes your expression root sensitive, that means it will be |
|
|
60 | reevaluated when the bg image changes. |
|
|
61 | |
|
|
62 | =cut |
49 | |
63 | |
50 | sub root() { |
64 | sub root() { |
51 | $new->{rootpmap_sensitive} = 1; |
65 | $new->{rootpmap_sensitive} = 1; |
52 | die "root op not supported, exg, we need you"; |
66 | die "root op not supported, exg, we need you"; |
53 | } |
67 | } |
54 | |
68 | |
|
|
69 | =item solid $colour |
|
|
70 | |
|
|
71 | =item solid $width, $height, $colour |
|
|
72 | |
|
|
73 | Creates a new image and completely fills it with the given colour. The |
|
|
74 | image is set to tiling mode. |
|
|
75 | |
|
|
76 | If <$width> and C<$height> are omitted, it creates a 1x1 image, which is |
|
|
77 | useful for solid backgrounds or for use in filtering effects. |
|
|
78 | |
|
|
79 | =cut |
|
|
80 | |
55 | sub solid($;$$) { |
81 | sub solid($$;$) { |
|
|
82 | my $colour = pop; |
|
|
83 | |
56 | my $img = $bgdsl_self->new_img (urxvt::PictStandardARGB32, $_[1] || 1, $_[2] || 1); |
84 | my $img = $bgdsl_self->new_img (urxvt::PictStandardARGB32, $_[0] || 1, $_[1] || 1); |
57 | $img->fill ($_[0]); |
85 | $img->fill ($colour); |
58 | $img |
86 | $img |
59 | } |
87 | } |
60 | |
88 | |
61 | =back |
89 | =back |
62 | |
90 | |
63 | =head2 VARIABLES |
91 | =head2 VARIABLES |
64 | |
92 | |
|
|
93 | The following functions provide variable data such as the terminal |
|
|
94 | widnow dimensions. Most of them make your expression sensitive to some |
|
|
95 | events, for example using C<TW> (terminal width) means your expression is |
|
|
96 | evaluated again when the terminal is resized. |
|
|
97 | |
65 | =over 4 |
98 | =over 4 |
|
|
99 | |
|
|
100 | =item TX |
|
|
101 | |
|
|
102 | =item TY |
|
|
103 | |
|
|
104 | Return the X and Y coordinates of the terminal window (the terminal |
|
|
105 | window is the full window by default, and the character area only when in |
|
|
106 | border-respect mode). |
|
|
107 | |
|
|
108 | Using these functions make your expression sensitive to window moves. |
|
|
109 | |
|
|
110 | These functions are mainly useful to align images to the root window. |
|
|
111 | |
|
|
112 | Example: load an image and align it so it looks as if anchored to the |
|
|
113 | background. |
|
|
114 | |
|
|
115 | move -TX, -TY, load "mybg.png" |
|
|
116 | |
|
|
117 | =item TW |
|
|
118 | |
|
|
119 | Return the width (C<TW>) and height (C<TH>) of the terminal window (the |
|
|
120 | terminal window is the full window by default, and the character area only |
|
|
121 | when in border-respect mode). |
|
|
122 | |
|
|
123 | Using these functions make your expression sensitive to window resizes. |
|
|
124 | |
|
|
125 | These functions are mainly useful to scale images, or to clip images to |
|
|
126 | the window size to conserve memory. |
|
|
127 | |
|
|
128 | Example: take the screen background, clip it to the window size, blur it a |
|
|
129 | bit, align it to the window position and use it as background. |
|
|
130 | |
|
|
131 | clip move -TX, -TY, blur 5, root |
66 | |
132 | |
67 | =cut |
133 | =cut |
68 | |
134 | |
69 | sub TX() { $new->{position_sensitive} = 1; $x } |
135 | sub TX() { $new->{position_sensitive} = 1; $x } |
70 | sub TY() { $new->{position_sensitive} = 1; $y } |
136 | sub TY() { $new->{position_sensitive} = 1; $y } |