#!/usr/bin/perl

# example for the gimp-perl-server (also called Net-Server)

use Gimp;

# on_lib is called if run through Gimp
Gimp::on_lib {
   print STDERR "$0: this script is not intended to be run from within the gimp!\n";
};

# on_net is called if connecting to an already open Perl-Server, or if
# spawning a gimp without an interface to run on.

Gimp::on_net {
  # simple benchmark ;)
  $img=new Gimp::Image(600,300,RGB);

# the is the same as $img = new Image(600,300,RGB)
  $bg=$img->layer_new(30,20,RGB_IMAGE,"Background",100,NORMAL_MODE);
# you have to add a layer after you create it
  $bg->add_layer(1);
# Show it (this slows things down)
  new Gimp::Display($img);

# do a bunch of operations just as a speed test, flushing in between
  Context->push();
  for $i (0..255) {
     Context->set_background([$i,255-$i,$i]);
     $bg->edit_fill(BACKGROUND_FILL);
     Display->displays_flush();
  }
  Context->pop();
#  Gimp::Net::server_quit;  # kill the gimp-perl-server-extension (ugly name)
};

exit main;

=head1 LICENSE

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

=cut

