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.15 by root, Tue Jun 5 22:46:50 2012 UTC vs.
Revision 1.22 by root, Thu Jun 7 10:19:23 2012 UTC

1#! perl 1#! perl
2 2
3#:META:RESOURCE:$$:string:background expression 3#:META:X_RESOURCE:%.expr:string:background expression
4#:META:RESOURCE:$$-enable:boolean:some boolean 4#:META:X_RESOURCE:%.enable:boolean:some boolean
5#:META:X_RESOURCE:%.extra.:value:extra config
5 6
6our $EXPR = 'move load "/root/pix/das_fette_schwein.jpg", repeat_wrap, X, Y'; 7our $EXPR = 'clip move X, Y, load "MagnoliaAlpha.png"';
7$EXPR = ' 8#$EXPR = '
8 rotate W, H, 50, 50, counter 1/59.95, repeat_mirror, 9# rotate W, H, 50, 50, counter 1/59.95, repeat_mirror,
9 clip X, Y, W, H, repeat_mirror, 10# clip X, Y, W, H, repeat_mirror,
10 load "/root/pix/das_fette_schwein.jpg" 11# load "/root/pix/das_fette_schwein.jpg"
11'; 12#';
12$EXPR = 'solid "red"'; 13#$EXPR = 'solid "red"';
13#$EXPR = 'blur root, 10, 10' 14#$EXPR = 'blur root, 10, 10'
14#$EXPR = 'blur move (root, -x, -y), 5, 5' 15#$EXPR = 'blur move (root, -x, -y), 5, 5'
15#resize load "/root/pix/das_fette_schwein.jpg", w, h 16#resize load "/root/pix/das_fette_schwein.jpg", w, h
16 17
17use Safe; 18use Safe;
18 19
19our ($bgdsl_self, $old, $new); 20our ($bgdsl_self, $old, $new);
20our ($l, $t, $w, $h); 21our ($l, $t, $w, $h);
21 22
22# enforce at leats this time between updates 23# enforce at least this interval between updates
23our $MIN_INTERVAL = 1/100; 24our $MIN_INTERVAL = 1/100;
24 25
25{ 26{
26 package urxvt::bgdsl; # background language 27 package urxvt::bgdsl; # background language
27 28
28 *repeat_black = \&urxvt::RepeatNone; #TODO wtf 29# *repeat_empty = \&urxvt::RepeatNone;
29 *repeat_wrap = \&urxvt::RepeatNormal; 30# *repeat_tile = \&urxvt::RepeatNormal;
30 *repeat_pad = \&urxvt::RepeatPad; 31# *repeat_pad = \&urxvt::RepeatPad;
31 *repeat_mirror = \&urxvt::RepeatReflect; 32# *repeat_mirror = \&urxvt::RepeatReflect;
32 33
33=head2 PROVIDERS/GENERATORS 34=head2 PROVIDERS/GENERATORS
34 35
35=over 4 36=over 4
36 37
55 $img 56 $img
56 } 57 }
57 58
58=back 59=back
59 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
60=head2 OPERATORS 85=head2 OPERATORS
61 86
62=over 4 87=over 4
63 88
64=cut 89=cut
65 90
66# sub clone($) { 91# sub clone($) {
67# $_[0]->clone 92# $_[0]->clone
68# } 93# }
69 94
70 sub clip($$$$$;$) { 95 sub clip($;$$;$$) {
96 my $img = pop;
71 my $img = pop; 97 my $h = pop || H;
98 my $w = pop || W;
72 $img->sub_rect ($_[0], $_[1], $_[2], $_[3], $_[4]) 99 $img->sub_rect ($_[0], $_[1], $w, $h)
73 } 100 }
74 101
75 sub resize($$$) { 102 sub resize($$$) {
76 my $img = pop; 103 my $img = pop;
77 $img->scale ($_[0], $_[1]) 104 $img->scale ($_[0], $_[1])
78 } 105 }
79 106
80 # TODO: ugly 107 # TODO: ugly
81 sub move($$;$) { 108 sub move($$;$) {
109 my $img = pop->clone;
110 $img->move ($_[0], $_[1]);
111 $img
82 my $img = pop; 112# my $img = pop;
83 $img->sub_rect ( 113# $img->sub_rect (
84 $_[0], $_[1], 114# $_[0], $_[1],
85 $img->w, $img->h, 115# $img->w, $img->h,
86 $_[2], 116# $_[2],
87 ) 117# )
88 } 118 }
89 119
90 sub rotate($$$$$$;$) { 120 sub rotate($$$$$$) {
91 my $img = pop; 121 my $img = pop;
92 $img->rotate ( 122 $img->rotate (
93 $_[0], 123 $_[0],
94 $_[1], 124 $_[1],
95 $_[2] * $img->w * .01, 125 $_[2] * $img->w * .01,
96 $_[3] * $img->h * .01, 126 $_[3] * $img->h * .01,
97 $_[4] * (3.14159265 / 180), 127 $_[4] * (3.14159265 / 180),
98 $_[5],
99 ) 128 )
100 } 129 }
101 130
102 sub blur($$$) { 131 sub blur($$$) {
103 my ($rh, $rv, $img) = @_; 132 my ($rh, $rv, $img) = @_;
125 $a = 1 if @_ < 5; 154 $a = 1 if @_ < 5;
126 155
127 $img = $img->clone; 156 $img = $img->clone;
128 $img->brightness ($r, $g, $b, $a); 157 $img->brightness ($r, $g, $b, $a);
129 $img 158 $img
130 }
131
132 sub X() { $new->{position_sensitive} = 1; $l }
133 sub Y() { $new->{position_sensitive} = 1; $t }
134 sub W() { $new->{size_sensitive} = 1; $w }
135 sub H() { $new->{size_sensitive} = 1; $h }
136
137 sub now() { urxvt::NOW }
138
139 sub again($) {
140 $new->{again} = $_[0];
141 }
142
143 sub counter($) {
144 $new->{again} = $_[0];
145 $bgdsl_self->{counter} + 0
146 } 159 }
147 160
148=back 161=back
149 162
150=cut 163=cut
187 local $old = $self->{state}; 200 local $old = $self->{state};
188 local $new = my $state = $self->{state} = {}; 201 local $new = my $state = $self->{state} = {};
189 202
190 ($l, $t, $w, $h) = 203 ($l, $t, $w, $h) =
191 $self->get_geometry; 204 $self->get_geometry;
205
206 warn "$l,$t,$w,$h\n";#d#
192 207
193 # evaluate user expression 208 # evaluate user expression
194 209
195 my $img = eval { $self->{expr}->() }; 210 my $img = eval { $self->{expr}->() };
196 warn $@ if $@;#d# 211 warn $@ if $@;#d#

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines