File: example-fu

package info (click to toggle)
libgimp-perl 2.0.dfsg-5
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 2,112 kB
  • ctags: 462
  • sloc: perl: 10,026; sh: 207; ansic: 207; makefile: 70
file content (77 lines) | stat: -rwxr-xr-x 3,146 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#!/opt/bin/perl

use Gimp;
use Gimp::Fu;

# expand your terminal to 121 across to read easily...

register "gimp_fu_example_script",			# fill in a function name
         "A non-working example of Gimp::Fu usage",	# and a short description,
         "Just a starting point to derive new ".        # a (possibly multiline) help text
            "scripts. Always remember to put a long".
            "help message here!",
         "Marc Lehmann <pcg\@goof.com>",		# don't forget your name (author)
         "(c)1998,1999,2000 Marc Lehmann",		# and your copyright!
         "20000321",					# the date this script was written (YYYYMMDD)
         N_"<Toolbox>/Xtns/Gimp::Fu Example...",	# the menu path - the 'N_' is for internationalization
         "RGB*, GRAYA",					# image types to accept (RGB, RGAB amnd GRAYA)
         [ # one of each type of parameter here 
         # argument type, switch name	, a short description		, default value, extra arguments
          [PF_SLIDER	, "width"	, "The image width"		, 360, [300, 500]],
          [PF_SPINNER	, "height"	, "The image height"		, 100, [100, 200]],
          [PF_STRING	, "text"	, "The Message"			, "example text"],
          [PF_INT	, "bordersize"	, "The bordersize"		, 10],
          [PF_FLOAT	, "borderwidth"	, "The borderwidth"		, 1/5],
          [PF_FONT	, "font"	, "The Font Family"		],
          [PF_COLOUR	, "text_colour"	, "The (foreground) text colour", [10,10,10]],
          [PF_COLOUR	, "bg_colour"	, "The background colour"	, [0xff,0x80,0]],
          [PF_TOGGLE	, "ignore_cols" , "Ignore colours"		, 0],
          [PF_IMAGE	, "extra_image"	, "An additonal picture to ignore"],
          [PF_DRAWABLE	, "extra_draw"	, "Somehting to ignroe as well"	],
          [PF_RADIO	, "type"	, "The effect type"		, 0, [small => 0, large => 1]],
          [PF_BRUSH	, "a_brush"	, "An unused brush"		],
          [PF_PATTERN	, "a_pattern"	, "An unused pattern"		],
          [PF_GRADIENT	, "a_gradients"	, "An unused gradients"		],
         ],
         sub {

   # now do sth. useful with the garbage we got ;)
   my($width,$height,$text,$brd1,$brd2,$font,$fg,$bg,$ignore,$xtraimg,$xtradrw,$effecttype,$brush,$pattern,$gradient)=@_;

   # set tracing, disable this to get rid of the debugging output
   Gimp::set_trace(TRACE_CALL);

   my $img = new Image ($width, $height, RGB);

   # put an undo group around any modifications, so that
   # they can be undone in one step.
   $img->undo_group_start;

   # the __ before the string in the next line indicates text that must be translated
   my $l = new Layer ($img, $width, $height, RGB, __"Background", 100, NORMAL_MODE);
   $l->add_layer(0);

   # now a few syntax examples

   Palette->set_foreground($fg) unless $ignore;
   Palette->set_background($bg) unless $ignore;

   fill $l BACKGROUND_FILL;
   $text_layer = $img->text_fontname(-1, 10, 10, $text, 5, 1, 10, PIXELS, $font);

   Palette->set_foreground("green");

   # close the undo push group
   $img->undo_group_end;

   $img;	# return the image, or an empty list, i.e. ()
};

exit main;
=head1 LICENSE

Copyright Marc Lehman.
Distrubuted under the same terms as Gimp-Perl.

=cut