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.16 by root, Wed Jun 6 11:46:11 2012 UTC vs.
Revision 1.26 by root, Thu Jun 7 11:34:09 2012 UTC

1#! perl 1#! perl
2 2
3#:META:X_RESOURCE:%.expr:string:background expression 3#:META:X_RESOURCE:%.expr:string:background expression
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
7our $EXPR = 'move load "/root/pix/das_fette_schwein.jpg", repeat_wrap, X, Y'; 7our $EXPR = 'move W * 0.1, -H * 0.1, resize W * 0.5, H * 0.5, repeat_none load "MagnoliaAlpha.png"';
8$EXPR = ' 8#$EXPR = '
9 rotate W, H, 50, 50, counter 1/59.95, repeat_mirror, 9# rotate W, H, 50, 50, counter 1/59.95, repeat_mirror,
10 clip X, Y, W, H, repeat_mirror, 10# clip X, Y, W, H, repeat_mirror,
11 load "/root/pix/das_fette_schwein.jpg" 11# load "/root/pix/das_fette_schwein.jpg"
12'; 12#';
13$EXPR = 'solid "red"'; 13#$EXPR = 'solid "red"';
14#$EXPR = 'blur root, 10, 10' 14#$EXPR = 'blur root, 10, 10'
15#$EXPR = 'blur move (root, -x, -y), 5, 5' 15#$EXPR = 'blur move (root, -x, -y), 5, 5'
16#resize load "/root/pix/das_fette_schwein.jpg", w, h 16#resize load "/root/pix/das_fette_schwein.jpg", w, h
17 17
18use Safe; 18use Safe;
24our $MIN_INTERVAL = 1/100; 24our $MIN_INTERVAL = 1/100;
25 25
26{ 26{
27 package urxvt::bgdsl; # background language 27 package urxvt::bgdsl; # background language
28 28
29 *repeat_black = \&urxvt::RepeatNone; #TODO wtf 29# *repeat_empty = \&urxvt::RepeatNone;
30 *repeat_wrap = \&urxvt::RepeatNormal; 30# *repeat_tile = \&urxvt::RepeatNormal;
31 *repeat_pad = \&urxvt::RepeatPad; 31# *repeat_pad = \&urxvt::RepeatPad;
32 *repeat_mirror = \&urxvt::RepeatReflect; 32# *repeat_mirror = \&urxvt::RepeatReflect;
33 33
34=head2 PROVIDERS/GENERATORS 34=head2 PROVIDERS/GENERATORS
35 35
36=over 4 36=over 4
37 37
56 $img 56 $img
57 } 57 }
58 58
59=back 59=back
60 60
61=head2 VARIABLES
62
63=over 4
64
65=cut
66
67 sub X() { $new->{position_sensitive} = 1; $l }
68 sub Y() { $new->{position_sensitive} = 1; $t }
69 sub W() { $new->{size_sensitive} = 1; $w }
70 sub H() { $new->{size_sensitive} = 1; $h }
71
72 sub now() { urxvt::NOW }
73
74 sub again($) {
75 $new->{again} = $_[0];
76 }
77
78 sub counter($) {
79 $new->{again} = $_[0];
80 $bgdsl_self->{counter} + 0
81 }
82
83=back
84
61=head2 OPERATORS 85=head2 OPERATORS
62 86
63=over 4 87=over 4
64 88
65=cut 89=cut
66 90
67# sub clone($) { 91# sub clone($) {
68# $_[0]->clone 92# $_[0]->clone
69# } 93# }
70 94
95 sub repeat_none($) {
96 my $img = $_[0]->clone;
97 $img->repeat_mode (urxvt::RepeatNone);
98 $img
99 }
100
71 sub clip($$$$$;$) { 101 sub clip($;$$;$$) {
102 my $img = pop;
72 my $img = pop; 103 my $h = pop || H;
104 my $w = pop || W;
73 $img->sub_rect ($_[0], $_[1], $_[2], $_[3], $_[4]) 105 $img->sub_rect ($_[0], $_[1], $w, $h)
74 } 106 }
75 107
76 sub resize($$$) { 108 sub resize($$$) {
77 my $img = pop; 109 my $img = pop;
78 $img->scale ($_[0], $_[1]) 110 $img->scale ($_[0], $_[1])
79 } 111 }
80 112
81 # TODO: ugly 113 # TODO: ugly
82 sub move($$;$) { 114 sub move($$;$) {
115 my $img = pop->clone;
116 $img->move ($_[0], $_[1]);
117 $img
83 my $img = pop; 118# my $img = pop;
84 $img->sub_rect ( 119# $img->sub_rect (
85 $_[0], $_[1], 120# $_[0], $_[1],
86 $img->w, $img->h, 121# $img->w, $img->h,
87 $_[2], 122# $_[2],
88 ) 123# )
89 } 124 }
90 125
91 sub rotate($$$$$$;$) { 126 sub rotate($$$$$$) {
92 my $img = pop; 127 my $img = pop;
93 $img->rotate ( 128 $img->rotate (
94 $_[0], 129 $_[0],
95 $_[1], 130 $_[1],
96 $_[2] * $img->w * .01, 131 $_[2] * $img->w * .01,
97 $_[3] * $img->h * .01, 132 $_[3] * $img->h * .01,
98 $_[4] * (3.14159265 / 180), 133 $_[4] * (3.14159265 / 180),
99 $_[5],
100 ) 134 )
101 } 135 }
102 136
103 sub blur($$$) { 137 sub blur($$$) {
104 my ($rh, $rv, $img) = @_; 138 my ($rh, $rv, $img) = @_;
126 $a = 1 if @_ < 5; 160 $a = 1 if @_ < 5;
127 161
128 $img = $img->clone; 162 $img = $img->clone;
129 $img->brightness ($r, $g, $b, $a); 163 $img->brightness ($r, $g, $b, $a);
130 $img 164 $img
131 }
132
133 sub X() { $new->{position_sensitive} = 1; $l }
134 sub Y() { $new->{position_sensitive} = 1; $t }
135 sub W() { $new->{size_sensitive} = 1; $w }
136 sub H() { $new->{size_sensitive} = 1; $h }
137
138 sub now() { urxvt::NOW }
139
140 sub again($) {
141 $new->{again} = $_[0];
142 }
143
144 sub counter($) {
145 $new->{again} = $_[0];
146 $bgdsl_self->{counter} + 0
147 } 165 }
148 166
149=back 167=back
150 168
151=cut 169=cut
188 local $old = $self->{state}; 206 local $old = $self->{state};
189 local $new = my $state = $self->{state} = {}; 207 local $new = my $state = $self->{state} = {};
190 208
191 ($l, $t, $w, $h) = 209 ($l, $t, $w, $h) =
192 $self->get_geometry; 210 $self->get_geometry;
211
212 warn "$l,$t,$w,$h\n";#d#
193 213
194 # evaluate user expression 214 # evaluate user expression
195 215
196 my $img = eval { $self->{expr}->() }; 216 my $img = eval { $self->{expr}->() };
197 warn $@ if $@;#d# 217 warn $@ if $@;#d#
252} 272}
253 273
254sub on_start { 274sub on_start {
255 my ($self) = @_; 275 my ($self) = @_;
256 276
257 warn $self->x_resource ("background.enable");
258
259 $self->set_expr (parse_expr $EXPR); 277 $self->set_expr (parse_expr $EXPR);
260 278
261 () 279 ()
262} 280}
263 281

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines