… | |
… | |
4 | #:META:X_RESOURCE:%.enable:boolean:some boolean |
4 | #:META:X_RESOURCE:%.enable:boolean:some boolean |
5 | #:META:X_RESOURCE:%.extra.:value:extra config |
5 | #:META:X_RESOURCE:%.extra.:value:extra config |
6 | |
6 | |
7 | our $EXPR; |
7 | our $EXPR; |
8 | #$EXPR = 'move W * 0.1, -H * 0.1, resize W * 0.5, H * 0.5, repeat_none load "opensource.png"'; |
8 | #$EXPR = 'move W * 0.1, -H * 0.1, resize W * 0.5, H * 0.5, repeat_none load "opensource.png"'; |
9 | $EXPR = 'move -X, -Y, load "argb.png"'; |
9 | $EXPR = 'move -TX, -TY, load "argb.png"'; |
10 | #$EXPR = ' |
10 | #$EXPR = ' |
11 | # rotate W, H, 50, 50, counter 1/59.95, repeat_mirror, |
11 | # rotate W, H, 50, 50, counter 1/59.95, repeat_mirror, |
12 | # clip X, Y, W, H, repeat_mirror, |
12 | # clip X, Y, W, H, repeat_mirror, |
13 | # load "/root/pix/das_fette_schwein.jpg" |
13 | # load "/root/pix/das_fette_schwein.jpg" |
14 | #'; |
14 | #'; |
… | |
… | |
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 starting |
|
|
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 | window 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 |
66 | |
99 | |
67 | =cut |
100 | =item TX |
68 | |
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 |
|
|
132 | |
|
|
133 | =cut |
|
|
134 | |
69 | sub X() { $new->{position_sensitive} = 1; $x } |
135 | sub TX() { $new->{position_sensitive} = 1; $x } |
70 | sub Y() { $new->{position_sensitive} = 1; $y } |
136 | sub TY() { $new->{position_sensitive} = 1; $y } |
71 | sub W() { $new->{size_sensitive} = 1; $w } |
137 | sub TW() { $new->{size_sensitive} = 1; $w } |
72 | sub H() { $new->{size_sensitive} = 1; $h } |
138 | sub TH() { $new->{size_sensitive} = 1; $h } |
73 | |
139 | |
74 | sub now() { urxvt::NOW } |
140 | sub now() { urxvt::NOW } |
75 | |
141 | |
76 | sub again($) { |
142 | sub again($) { |
77 | $new->{again} = $_[0]; |
143 | $new->{again} = $_[0]; |
… | |
… | |
184 | |
250 | |
185 | =cut |
251 | =cut |
186 | |
252 | |
187 | sub clip($;$$;$$) { |
253 | sub clip($;$$;$$) { |
188 | my $img = pop; |
254 | my $img = pop; |
189 | my $h = pop || H; |
255 | my $h = pop || TH; |
190 | my $w = pop || W; |
256 | my $w = pop || TW; |
191 | $img->sub_rect ($_[0], $_[1], $w, $h) |
257 | $img->sub_rect ($_[0], $_[1], $w, $h) |
192 | } |
258 | } |
193 | |
259 | |
194 | =item scale $img |
260 | =item scale $img |
195 | |
261 | |
… | |
… | |
216 | sub scale($$$) { |
282 | sub scale($$$) { |
217 | my $img = pop; |
283 | my $img = pop; |
218 | |
284 | |
219 | @_ == 2 ? $img->scale ($_[0] * $img->w * 0.01, $_[1] * $img->h * 0.01) |
285 | @_ == 2 ? $img->scale ($_[0] * $img->w * 0.01, $_[1] * $img->h * 0.01) |
220 | : @_ ? $img->scale ($_[0] * $img->w * 0.01, $_[0] * $img->h * 0.01) |
286 | : @_ ? $img->scale ($_[0] * $img->w * 0.01, $_[0] * $img->h * 0.01) |
221 | : $img->scale (W, H) |
287 | : $img->scale (TW, TH) |
222 | } |
288 | } |
223 | |
289 | |
224 | sub resize($$$) { |
290 | sub resize($$$) { |
225 | my $img = pop; |
291 | my $img = pop; |
226 | $img->scale ($_[0], $_[1]) |
292 | $img->scale ($_[0], $_[1]) |
227 | } |
293 | } |
228 | |
294 | |
229 | # TODO: ugly |
|
|
230 | sub move($$;$) { |
295 | sub move($$;$) { |
231 | my $img = pop->clone; |
296 | my $img = pop->clone; |
232 | $img->move ($_[0], $_[1]); |
297 | $img->move ($_[0], $_[1]); |
233 | $img |
298 | $img |
234 | # my $img = pop; |
|
|
235 | # $img->sub_rect ( |
|
|
236 | # $_[0], $_[1], |
|
|
237 | # $img->w, $img->h, |
|
|
238 | # $_[2], |
|
|
239 | # ) |
|
|
240 | } |
299 | } |
241 | |
300 | |
242 | sub rotate($$$$$$) { |
301 | sub rotate($$$$$$) { |
243 | my $img = pop; |
302 | my $img = pop; |
244 | $img->rotate ( |
303 | $img->rotate ( |
… | |
… | |
250 | ) |
309 | ) |
251 | } |
310 | } |
252 | |
311 | |
253 | sub blur($$;$) { |
312 | sub blur($$;$) { |
254 | my $img = pop; |
313 | my $img = pop; |
255 | |
|
|
256 | $img->blur ($_[0], @_ >= 2 ? $_[1] : $_[0]); |
314 | $img->blur ($_[0], @_ >= 2 ? $_[1] : $_[0]) |
257 | } |
315 | } |
258 | |
316 | |
259 | sub contrast($$;$$;$) { |
317 | sub contrast($$;$$;$) { |
260 | my $img = pop; |
318 | my $img = pop; |
261 | my ($r, $g, $b, $a) = @_; |
319 | my ($r, $g, $b, $a) = @_; |