1#!/usr/bin/perl -w
2
3use Gimp;
4use strict;
5use warnings;
6
7Gimp::on_lib {
8   die "Not intended to be run from within GIMP!\n";
9};
10
11# on_net is called if connecting to an already open Perl-Server, or if
12# spawning a GIMP without an interface to run on.
13Gimp::on_net {
14  my $img=Gimp::Image->new(600,300,RGB);
15  my $bg=$img->layer_new(30,20,RGB_IMAGE,"Background",100,NORMAL_MODE);
16  $img->insert_layer($bg,0,1); # you have to add a layer after you create it
17  eval { Gimp::Display->new($img); }; # Show it (this slows things down)
18# do a bunch of operations just as a speed test, flushing in between
19  Gimp::Context->push;
20  for $i (0..255) {
21     Gimp::Context->set_background([$i,255-$i,$i]);
22     $bg->edit_fill(BACKGROUND_FILL);
23     Gimp::Display->displays_flush();
24  }
25  Gimp::Context->pop;
26};
27
28exit main;
29__END__
30
31=head1 NAME
32
33example-net - Demonstrate use of Gimp-Perl "net mode"
34
35=head1 LICENSE
36
37Copyright Marc Lehmann.
38Distributed under the same terms as Gimp-Perl.
39