File: example-net

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 (43 lines) | stat: -rwxr-xr-x 1,077 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
#!/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 spped test, flushing in between
  for $i (0..255) {
     Palette->set_background([$i,255-$i,$i]);
     $bg->edit_fill(BACKGROUND_FILL);
     Display->displays_flush();
  }
#  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