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.20 by root, Wed Jun 6 22:01:45 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 = '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($;$$;$$) {
47 my $img = pop; 96 my $img = pop;
48 $img->sub_rect ($_[0], $_[1], $_[2], $_[3], $_[4]) 97 $img->sub_rect ($_[0], $_[1], $_[2] || W, $_[3] || H)
49 } 98 }
50 99
51 sub resize($$$) { 100 sub resize($$$) {
52 my $img = pop; 101 my $img = pop;
53 $img->scale ($_[0], $_[1]) 102 $img->scale ($_[0], $_[1])
54 } 103 }
55 104
56 # TODO: ugly 105 # TODO: ugly
57 sub move($$;$) { 106 sub move($$;$) {
107 my $img = pop->clone;
108 $img->move ($_[0], $_[1]);
109 $img
58 my $img = pop; 110# my $img = pop;
59 $img->sub_rect ( 111# $img->sub_rect (
60 $_[0], $_[1], 112# $_[0], $_[1],
61 $img->w, $img->h, 113# $img->w, $img->h,
62 $_[2], 114# $_[2],
63 ) 115# )
64 } 116 }
65 117
66 sub rotate($$$$$$;$) { 118 sub rotate($$$$$$) {
67 my $img = pop; 119 my $img = pop;
68 $img->rotate ( 120 $img->rotate (
69 $_[0], 121 $_[0],
70 $_[1], 122 $_[1],
71 $_[2] * $img->w * .01, 123 $_[2] * $img->w * .01,
72 $_[3] * $img->h * .01, 124 $_[3] * $img->h * .01,
73 $_[4] * (3.14159265 / 180), 125 $_[4] * (3.14159265 / 180),
74 $_[5],
75 ) 126 )
76 } 127 }
77 128
78 sub blur($$$) { 129 sub blur($$$) {
79 my ($rh, $rv, $img) = @_; 130 my ($rh, $rv, $img) = @_;
103 $img = $img->clone; 154 $img = $img->clone;
104 $img->brightness ($r, $g, $b, $a); 155 $img->brightness ($r, $g, $b, $a);
105 $img 156 $img
106 } 157 }
107 158
108 sub X() { $new->{position_sensitive} = 1; $l } 159=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 160
113 sub now() { urxvt::NOW } 161=cut
114 162
115 sub again($) {
116 $new->{again} = $_[0];
117 }
118
119 sub counter($) {
120 $new->{again} = $_[0];
121 $bgdsl_self->{counter} + 0
122 }
123} 163}
124 164
125sub parse_expr { 165sub parse_expr {
126 my $expr = eval "sub {\npackage urxvt::bgdsl;\n#line 0 'background expression'\n$_[0]\n}"; 166 my $expr = eval "sub {\npackage urxvt::bgdsl;\n#line 0 'background expression'\n$_[0]\n}";
127 die if $@; 167 die if $@;
163 203
164 # evaluate user expression 204 # evaluate user expression
165 205
166 my $img = eval { $self->{expr}->() }; 206 my $img = eval { $self->{expr}->() };
167 warn $@ if $@;#d# 207 warn $@ if $@;#d#
208 die if !UNIVERSAL::isa $img, "urxvt::img";
168 209
169 # if the expression is sensitive to external events, prepare reevaluation then 210 # if the expression is sensitive to external events, prepare reevaluation then
170 211
171 my $repeat; 212 my $repeat;
172 213

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines