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.13 by root, Tue Jun 5 19:32:29 2012 UTC vs.
Revision 1.23 by root, Thu Jun 7 10:22:55 2012 UTC

1#! perl 1#! perl
2 2
3#:META:RESOURCE:$$:string:background expression 3#:META:X_RESOURCE:%.expr:string:background expression
4#:META:X_RESOURCE:%.enable:boolean:some boolean
5#:META:X_RESOURCE:%.extra.:value:extra config
4 6
5our $EXPR = 'move load "/root/pix/das_fette_schwein.jpg", repeat_wrap, X, Y'; 7our $EXPR = 'clip move -X, -Y, load "MagnoliaAlpha.png"';
6$EXPR = ' 8#$EXPR = '
7 rotate W, H, 50, 50, counter 1/59.95, repeat_mirror, 9# rotate W, H, 50, 50, counter 1/59.95, repeat_mirror,
8 clip X, Y, W, H, repeat_mirror, 10# clip X, Y, W, H, repeat_mirror,
9 load "/root/pix/das_fette_schwein.jpg" 11# load "/root/pix/das_fette_schwein.jpg"
10'; 12#';
13#$EXPR = 'solid "red"';
11#$EXPR = 'blur root, 10, 10' 14#$EXPR = 'blur root, 10, 10'
12#$EXPR = 'blur move (root, -x, -y), 5, 5' 15#$EXPR = 'blur move (root, -x, -y), 5, 5'
13#resize load "/root/pix/das_fette_schwein.jpg", w, h 16#resize load "/root/pix/das_fette_schwein.jpg", w, h
14 17
15use Safe; 18use Safe;
16 19
17our ($bgdsl_self, $old, $new); 20our ($bgdsl_self, $old, $new);
18our ($l, $t, $w, $h); 21our ($l, $t, $w, $h);
19 22
20# enforce at leats this time between updates 23# enforce at least this interval between updates
21our $MIN_INTERVAL = 1/100; 24our $MIN_INTERVAL = 1/100;
22 25
23{ 26{
24 package urxvt::bgdsl; # background language 27 package urxvt::bgdsl; # background language
25 28
26 *repeat_black = \&urxvt::RepeatNone; #TODO wtf 29# *repeat_empty = \&urxvt::RepeatNone;
27 *repeat_wrap = \&urxvt::RepeatNormal; 30# *repeat_tile = \&urxvt::RepeatNormal;
28 *repeat_pad = \&urxvt::RepeatPad; 31# *repeat_pad = \&urxvt::RepeatPad;
29 *repeat_mirror = \&urxvt::RepeatReflect; 32# *repeat_mirror = \&urxvt::RepeatReflect;
33
34=head2 PROVIDERS/GENERATORS
35
36=over 4
37
38=item load $path
39
40=cut
30 41
31 sub load($) { 42 sub load($) {
32 my ($path) = @_; 43 my ($path) = @_;
33 44
34 $new->{load}{$path} = $old->{load}{$path} || $bgdsl_self->new_img_from_file ($path); 45 $new->{load}{$path} = $old->{load}{$path} || $bgdsl_self->new_img_from_file ($path);
37 sub root() { 48 sub root() {
38 $new->{rootpmap_sensitive} = 1; 49 $new->{rootpmap_sensitive} = 1;
39 die "root op not supported, exg, we need you"; 50 die "root op not supported, exg, we need you";
40 } 51 }
41 52
53 sub solid($;$$) {
54 my $img = $bgdsl_self->new_img (urxvt::PictStandardARGB32, $_[1] || 1, $_[2] || 1);
55 $img->fill ($_[0]);
56 $img
57 }
58
59=back
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
85=head2 OPERATORS
86
87=over 4
88
89=cut
90
42# sub clone($) { 91# sub clone($) {
43# $_[0]->clone 92# $_[0]->clone
44# } 93# }
45 94
46 sub clip($$$$$;$) { 95 sub clip($;$$;$$) {
96 my $img = pop;
47 my $img = pop; 97 my $h = pop || H;
98 my $w = pop || W;
48 $img->sub_rect ($_[0], $_[1], $_[2], $_[3], $_[4]) 99 $img->sub_rect ($_[0], $_[1], $w, $h)
49 } 100 }
50 101
51 sub resize($$$) { 102 sub resize($$$) {
52 my $img = pop; 103 my $img = pop;
53 $img->scale ($_[0], $_[1]) 104 $img->scale ($_[0], $_[1])
54 } 105 }
55 106
56 # TODO: ugly 107 # TODO: ugly
57 sub move($$;$) { 108 sub move($$;$) {
109 my $img = pop->clone;
110 $img->move ($_[0], $_[1]);
111 $img
58 my $img = pop; 112# my $img = pop;
59 $img->sub_rect ( 113# $img->sub_rect (
60 $_[0], $_[1], 114# $_[0], $_[1],
61 $img->w, $img->h, 115# $img->w, $img->h,
62 $_[2], 116# $_[2],
63 ) 117# )
64 } 118 }
65 119
66 sub rotate($$$$$$;$) { 120 sub rotate($$$$$$) {
67 my $img = pop; 121 my $img = pop;
68 $img->rotate ( 122 $img->rotate (
69 $_[0], 123 $_[0],
70 $_[1], 124 $_[1],
71 $_[2] * $img->w * .01, 125 $_[2] * $img->w * .01,
72 $_[3] * $img->h * .01, 126 $_[3] * $img->h * .01,
73 $_[4] * (3.14159265 / 180), 127 $_[4] * (3.14159265 / 180),
74 $_[5],
75 ) 128 )
76 } 129 }
77 130
78 sub blur($$$) { 131 sub blur($$$) {
79 my ($rh, $rv, $img) = @_; 132 my ($rh, $rv, $img) = @_;
103 $img = $img->clone; 156 $img = $img->clone;
104 $img->brightness ($r, $g, $b, $a); 157 $img->brightness ($r, $g, $b, $a);
105 $img 158 $img
106 } 159 }
107 160
108 sub X() { $new->{position_sensitive} = 1; $l } 161=back
109 sub Y() { $new->{position_sensitive} = 1; $t }
110 sub W() { $new->{size_sensitive} = 1; $w }
111 sub H() { $new->{size_sensitive} = 1; $h }
112 162
113 sub now() { urxvt::NOW } 163=cut
114 164
115 sub again($) {
116 $new->{again} = $_[0];
117 }
118
119 sub counter($) {
120 $new->{again} = $_[0];
121 $bgdsl_self->{counter} + 0
122 }
123} 165}
124 166
125sub parse_expr { 167sub parse_expr {
126 my $expr = eval "sub {\npackage urxvt::bgdsl;\n#line 0 'background expression'\n$_[0]\n}"; 168 my $expr = eval "sub {\npackage urxvt::bgdsl;\n#line 0 'background expression'\n$_[0]\n}";
127 die if $@; 169 die if $@;
159 local $new = my $state = $self->{state} = {}; 201 local $new = my $state = $self->{state} = {};
160 202
161 ($l, $t, $w, $h) = 203 ($l, $t, $w, $h) =
162 $self->get_geometry; 204 $self->get_geometry;
163 205
206 warn "$l,$t,$w,$h\n";#d#
207
164 # evaluate user expression 208 # evaluate user expression
165 209
166 my $img = eval { $self->{expr}->() }; 210 my $img = eval { $self->{expr}->() };
167 warn $@ if $@;#d# 211 warn $@ if $@;#d#
212 die if !UNIVERSAL::isa $img, "urxvt::img";
168 213
169 # if the expression is sensitive to external events, prepare reevaluation then 214 # if the expression is sensitive to external events, prepare reevaluation then
170 215
171 my $repeat; 216 my $repeat;
172 217

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines