3 # Copyright Eric Windisch, 2003.
4 # Licensed under the MIT license.
11 my ($config_file, $path, $tmppath, $generator,$verbose, $inherits,$tmpscheme,$shadow, $opacity, $shadowx, $shadowy, $shadowblur,$shadowblursigma);
13 # default for variables
23 $generator="/usr/bin/X11/xcursorgen";
24 # it seems that recursive inheritance does not yet exist.
25 $inherits="whiteglass";
30 $0 [-v] [--inherits theme] [--shadow] [--shadow-x pixels] [--shadow-y pixels] [--shadow-blur size] [--shadow-blur-sigma size] [--generator xcursorgen-path] [--tmp temp-dir]
36 'inherits=s'=>\$inherits,
40 'generator=s'=>\$generator,
41 'opacity=i'=>\$opacity,
44 'shadow-x=i'=>\$shadowx,
45 'shadow-y=i'=>\$shadowy,
46 'shadow-blur=i'=>\$shadowblur,
47 'shadow-blur-sigma=i'=>\$shadowblursigma
50 # make sure path and tmppath end in /
51 if ($path =~ /[^\/]$/) {
54 if ($tmppath =~ /[^\/]$/) {
55 $tmppath=$tmppath."/";
61 if (! -d $path."cursors/") {
62 mkdir ($path."cursors/");
67 $tmpscheme=$tmppath."Scheme.ini";
69 # I did this much nicer, but Perl < 5.8 choked.
70 open (INI, "< Scheme.ini") or die ("Cannot open Scheme.ini");
71 open (INF, ">", $tmpscheme);
73 unless (!/=/ && !/^\s*\[/) {
81 my $cfg=new Config::IniFiles(-file=>$tmpscheme) or die ("Scheme.ini in wrong format? -".$@);
82 my @sections=$cfg->Sections;
85 Arrow=>["left_ptr","X_cursor","right_ptr",'4498f0e0c1937ffe01fd06f973665830'],
86 Cross=>["tcross","cross"],
87 Hand=>["hand1", "hand2",'9d800788f1b08800ae810202380a0822','e29285e634086352946a0e7090d73106'],
89 UpArrow=>"center_ptr",
90 SizeNWSE=>["bottom_right_corner","top_left_corner",'c7088f0f3e6c8088236ef8e1e3e70000'],
91 SizeNESW=>["bottom_left_corner","top_right_corner",'fcf1c3c7cd4491d801f1e1c78f100000'],
92 SizeWE=>["sb_h_double_arrow", "left_side", "right_side",'028006030e0e7ebffc7f7070c0600140'],
93 SizeNS=>["double_arrow","bottom_side","top_side",'00008160000006810000408080010102'],
94 Help=>["question_arrow",'d9ce0ab605698f320427677b458ad60b'],
95 Handwriting=>"pencil",
96 AppStarting=>["left_ptr_watch", '3ecb610c1bf2410f44200f48c40d3599'],
99 NO=>"03b6e0fcb3499374a867c041f52298f0"
102 foreach my $section (@sections) {
105 $filename=$section.".png";
106 unless (-f $filename) {
110 my ($image, $x, $frames, $width, $height, $curout);
112 $image=Image::Magick->new;
113 $x=$image->Read($filename);
116 $frames=$cfg->val($section, 'Frames');
117 $width=$image->Get('width')/$frames;
118 $height=$image->Get('height');
120 if (defined($filemap->{$section})) {
121 $curout=$filemap->{$section};
128 if (defined (@{$curout}[0])) { };
138 if (defined (@{$curout}[0])) {
139 $outfile=pop @{$curout};
146 $outfile=$path."cursors/".$outfile;
149 print "Writing to $section -> $outfile\n";
152 open (FH, "| $generator > \"$outfile\"");
154 for (my $i=0; $i<$frames; $i++) {
155 my ($tmpimg, $outfile);
156 $outfile=$tmppath.$section.'-'.$i.'.png';
157 $tmpimg=$image->Clone();
159 $x=$tmpimg->Crop(width=>$width, height=>$height, x=>$i*$width, y=>0);
165 my $shadow=$tmpimg->Clone();
166 my $orig=$tmpimg->Clone();
167 my $mask1; # shadow mask
168 my $mask2=$tmpimg->Clone();
170 $x=$orig->Crop(x=>0, y=>0, height=>$height, width=>$width);
172 $orig->Set(size=>$width+$shadowx."x".$height+$shadowy);
175 $x=$shadow->Quantize(colorspace=>"Gray");
177 $x=$shadow->Level(level=>0, gamma=>0);
179 $x=$shadow->Gamma(gamma=>0);
181 $x=$shadow->Blur(radius=>$shadowblur, sigma=>$shadowblursigma);
184 $mask1=$shadow->Clone();
186 $x=$mask1->Channel('Matte');
188 #$x=$mask2->Channel('Matte');
190 $x=$mask2->Composite(image=>$mask1, compose=>"Over");
193 #$x=$orig->Composite(image=>$shadow, compose=>"Over", x=>$shadowx, y=>$shadowy, opacity=>0, mask=>$mask2);
195 #$x=$orig->Composite(image=>$tmpimg, compose=>"Over", x=>0, y=>0, opacity=>0, mask=>$mask2);
197 #$x=$orig->Composite(image=>$tmpimg, compose=>"Over", x=>0, y=>0, opacity=>0, mask=>$mask1);
206 my $tmpimg1=$tmpimg->Clone();
207 my $x=$tmpimg1->Channel('Matte');
210 $tmpimg1->Set(type=>"GrayscaleMatte");
211 $x=$tmpimg1->Quantize(colorspace=>"Gray");
214 $x=$tmpimg->Level(level=>0, gamma=>0);
217 $x=$tmpimg1->Gamma(gamma=>100);
220 $x=$tmpimg->Composite(image=>$tmpimg, compose=>"Over", mask=>$tmpimg1);
225 $x=$tmpimg->Write($outfile);
229 $cfg->val($section,'Hot spot x')." ".
230 $cfg->val($section,'Hot spot y')." ".
232 $cfg->val($section,'Interval')."\n";
240 print "Writing theme index.\n";
241 open (FH, "> ${path}index.theme");
248 print "Done. Theme wrote to ${path}\n";