- Timestamp:
- 2000-07-13T10:21:53+12:00 (24 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/New_Config_Format-branch/gsdl/bin/script/gimp/title_icon.pl
r1037 r1279 46 46 47 47 48 my ($cfg_file, $imagefile, $width, $height, $imageheight, $stripecolor, $stripewidth,49 $stripe_alignment, $i_transparency, $text, $text_alignment, $filename, $textspace_x,50 $textspace_y, $bgcolor, $fontcolor, $fontsize, $minfontsize, $fontname,51 $fontweight, $fontslant, $fontwidth, $fontspacing, $image_dir);48 local ($cfg_file, $size, $imagefile, $width, $height, $imageheight, $stripecolor, $stripewidth, 49 $stripe_alignment, $i_transparency, $text, $text_alignment, $filename, $textspace_x, 50 $textspace_y, $bgcolor, $fontcolor, $fontsize, $minfontsize, $fontname, 51 $fontweight, $fontslant, $fontwidth, $fontspacing, $image_dir, $dont_wrap); 52 52 53 53 sub print_usage { … … 57 57 print STDERR " sets of the following options - use to create\n"; 58 58 print STDERR " batches of images\n"; 59 print STDERR " -size number the overall size ratio of the image (i.e. a size\n"; 60 print STDERR " of 2 will create an image twice the default size)\n"; 59 61 print STDERR " -image_dir directory directory to create images in [`pwd`]\n"; 60 62 print STDERR " this should be full path to existing directory\n"; … … 83 85 print STDERR " -fontslant [r]\n"; 84 86 print STDERR " -fontwidth [*]\n"; 85 print STDERR " -fontspacing [*]\n\n"; 87 print STDERR " -fontspacing [*]\n"; 88 print STDERR " -dont_wrap don't attempt to wrap text\n\n"; 86 89 } 87 90 … … 89 92 $image_dir = "./"; 90 93 $imagefile = ""; 91 $width = 150;92 $height = 44;93 $imageheight = 110;94 $width = int (150 * $size); 95 $height = int (44 * $size); 96 $imageheight = int (110 * $size); 94 97 $stripecolor = $gsdl_green; 95 $stripewidth = 40;98 $stripewidth = int (40 * $size); 96 99 $stripe_alignment = "left"; 97 100 $i_transparency = 60; … … 99 102 $text_alignment = "left"; 100 103 $filename = ""; 101 $textspace_x = 3;102 $textspace_y = 3;104 $textspace_x = int (3 * $size); 105 $textspace_y = int (3 * $size); 103 106 $bgcolor = $gsdl_green; 104 107 $fontcolor = $black; 105 $fontsize = 17;106 $minfontsize = 10;108 $fontsize = int (17 * $size); 109 $minfontsize = int (10 * $size); 107 110 $fontname = "lucida"; 108 111 $fontweight = "medium"; … … 116 119 if (!parsargv::parse(\@ARGV, 117 120 'cfg_file/.*/', \$cfg_file, 121 'size/\d+/1', \$size, 118 122 'image_dir/.*/./', \$image_dir, 119 123 'imagefile/.*/', \$imagefile, … … 138 142 'fontslant/.*/r', \$fontslant, 139 143 'fontwidth/.*/*', \$fontwidth, 140 'fontspacing/.*/*', \$fontspacing)) { 144 'fontspacing/.*/*', \$fontspacing, 145 'dont_wrap', \$dont_wrap)) { 141 146 &print_usage(); 142 147 die "title_icon.pl: incorrect options\n"; … … 148 153 chomp $image_dir; 149 154 } 150 155 151 156 if ($cfg_file =~ /\w/) { 152 157 … … 177 182 178 183 sub produce_image { 184 185 &adjust_args (); 186 &wrap_text () unless $dont_wrap; 179 187 180 188 my $use_image = 0; … … 338 346 return 1; 339 347 } 348 349 # adjust arguments that are effected by the size argument 350 sub adjust_args { 351 352 if ($size != 1) { 353 my @size_args = ('width', 'height', 'imageheight', 'stripewidth', 354 'textspace_x', 'textspace_y', 'fontsize', 'minfontsize'); 355 foreach $arg (@size_args) { 356 $$arg = int ($$arg * $size); 357 } 358 } 359 } 360 361 sub wrap_text { 362 363 # don't wrap text if it already contains carriage returns 364 return if $text =~ /\n/; 365 366 # the following assumes that all words are less than $wrap_length long 367 my $wrap_length = 14; 368 369 my $new_text = ""; 370 while (length ($text) >= $wrap_length) { 371 my $line = substr ($text, 0, $wrap_length); 372 $text =~ s/^$line//; 373 $line =~ s/\s([^\s]*)$/\n/; 374 $text = $1 . $text; 375 $new_text .= $line; 376 } 377 $new_text .= $text; 378 $text = $new_text; 379 } 340 380 341 381 sub query {
Note:
See TracChangeset
for help on using the changeset viewer.