1: #!/usr/local/bin/perl
2:
3: use Gimp ":auto";
4: use Gimp::Fu;
5:
6: sub basic_logo {
7: my($font, $border, $text, $bgcolor, $fgcolor) = @_;
8:
9: # Create a new image of an arbitrary size with
10: $img = gimp_image_new(100, 100, RGB);
11:
12: # Create a new layer for the background of arbitrary size, and
13: # add it to the image
14: my $background = gimp_layer_new($img, 100, 100,
15: RGB, "Background", 100,
16: NORMAL_MODE);
17: gimp_image_add_layer($background, 1);
18:
19: # Choose color of text
20: gimp_palette_set_foreground($fgcolor);
21:
22: # Create the text layer. Using -1 as the drawable creates a new layer.
23: my $text_layer = gimp_text_fontname($img, -1, 0, 0, $text,
24: $border, 1, xlfd_size($font), $font);
25:
26: # Get size of the text drawable and resize the image and the
27: # background layer to this size.
28: my($width, $height) = ($text_layer->width, $text_layer->height);
29: gimp_image_resize($img, $width, $height, 0, 0);
30: gimp_layer_resize($background, $width, $height, 0, 0);
31:
32: # Fill the background layer now when it has the right size.
33: gimp_palette_set_background($bgcolor);
34: gimp_edit_fill($background, BG_IMAGE_FILL);
35:
36: return $img;
37: }
38:
39: # register the script
40: register "basic_logo", "basic logo", "basic logo",
41: "Dov Grobgeld", "Dov Grobgeld",
42: "1999-06-09",
43: "<Toolbox>/Xtns/Perl-Fu/Tutorial/Basic Logo",
44: "*",
45: [
46: [PF_FONT, "font", "font", "-*-utopia-bold-r-*-*-70-*-*-*-*-*-*-*"],
47: [PF_INT, "border", "border", "10"],
48: [PF_STRING, "text", "text", "Hello world!"],
49: [PF_COLOR, "bg_color", "Background color", [40,180,160]],
50: [PF_COLOR, "fg_color", "Background color", [255,255,0]],
51: ],
52: \&basic_logo;
53:
54: # Handle over control to gimp
55: exit main();
|