home *** CD-ROM | disk | FTP | other *** search
/ MacWorld 2003 August / MW 8 2003 CD1.iso / Inside Macworld / Product News / gimp-1.2.4.sit / gimp-1.2.4 / plug-ins / perl / examples / example-fu < prev    next >
Encoding:
Text File  |  2000-05-21  |  2.9 KB  |  70 lines

  1. #!/usr/bin/perl
  2.  
  3. use Gimp;
  4. use Gimp::Fu;
  5.  
  6. register "gimp_fu_example_script",            # fill in a function name
  7.          "A non-working example of Gimp::Fu usage",    # and a short description,
  8.          "Just a starting point to derive new ".        # a (possibly multiline) help text
  9.             "scripts. Always remember to put a long".
  10.             "help message here!",
  11.          "Marc Lehmann <pcg\@goof.com>",        # don't forget your name (author)
  12.          "(c)1998,1999,2000 Marc Lehmann",        # and your copyright!
  13.          "20000321",                    # the date this script was written (YYYYMMDD)
  14.          N_"<Toolbox>/Xtns/Gimp::Fu Example...",    # the menu path
  15.          "RGB*, GRAYA",                    # image types to accept (RGB, RGAB amnd GRAYA)
  16.          [
  17.          # argument type, switch name    , a short description        , default value, extra arguments
  18.           [PF_SLIDER    , "width"    , "The image width"        , 360, [300, 500]],
  19.           [PF_SPINNER    , "height"    , "The image height"        , 100, [100, 200]],
  20.           [PF_STRING    , "text"    , "The Message"            , "example text"],
  21.           [PF_INT    , "bordersize"    , "The bordersize"        , 10],
  22.           [PF_FLOAT    , "borderwidth"    , "The borderwidth"        , 1/5],
  23.           [PF_FONT    , "font"    , "The Font Family"        ],
  24.           [PF_COLOUR    , "text_colour"    , "The (foreground) text colour", [10,10,10]],
  25.           [PF_COLOUR    , "bg_colour"    , "The background colour"    , "#ff8000"],
  26.           [PF_TOGGLE    , "ignore_cols" , "Ignore colours"        , 0],
  27.           [PF_IMAGE    , "extra_image"    , "An additonal picture to ignore"],
  28.           [PF_DRAWABLE    , "extra_draw"    , "Somehting to ignroe as well"    ],
  29.           [PF_RADIO    , "type"    , "The effect type"        , 0, [small => 0, large => 1]],
  30.           [PF_BRUSH    , "a_brush"    , "An unused brush"        ],
  31.           [PF_PATTERN    , "a_pattern"    , "An unused pattern"        ],
  32.           [PF_GRADIENT    , "a_gradients"    , "An unused gradients"        ],
  33.          ],
  34.          sub {
  35.  
  36.    # now do sth. useful with the garbage we got ;)
  37.    my($width,$height,$text,$brd1,$brd2,$font,$fg,$bg,$ignore,$xtraimg,$xtradrw,$effecttype,$brush,$pattern,$gradient)=@_;
  38.  
  39.    # set tracing, disable this to get rid of the debugging output
  40.    Gimp::set_trace(TRACE_CALL);
  41.  
  42.    my $img = new Image ($width, $height, RGB);
  43.  
  44.    # put an undo group around any modifications, so that
  45.    # they can be undone in one step.
  46.    $img->undo_push_group_start;
  47.  
  48.    # the __ before the string in the next line indicates text that must be translated
  49.    my $l = new Layer ($img, $width, $height, RGB, __"Background", 100, NORMAL_MODE);
  50.    $l->add_layer(0);
  51.  
  52.    # now a few syntax examples
  53.  
  54.    Palette->set_foreground($fg) unless $ignore;
  55.    Palette->set_background($bg) unless $ignore;
  56.  
  57.    fill $l BG_IMAGE_FILL;
  58.    $text_layer = $img->text_fontname(-1, 10, 10, $text, 5, 1, xlfd_size($font), $font);
  59.  
  60.    Palette->set_foreground("green");
  61.  
  62.    # close the undo push group
  63.    $img->undo_push_group_end;
  64.  
  65.    $img;    # return the image, or an empty list, i.e. ()
  66. };
  67.  
  68. exit main;
  69.  
  70.