[gimp-perl] Test supplied plugins, delete Gimp::Feature. Bug 727126
- From: Ed J <edj src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp-perl] Test supplied plugins, delete Gimp::Feature. Bug 727126
- Date: Wed, 23 Apr 2014 05:11:35 +0000 (UTC)
commit 09781c3cf7d14c8bb882d6fb102e6fbd6fef5409
Author: Ed J <m8r-35s8eo mailinator com>
Date: Tue Apr 1 06:12:48 2014 +0100
Test supplied plugins, delete Gimp::Feature. Bug 727126
Gimp.pm | 13 ++-
Gimp/Feature.pm | 253 ------------------------------------------
Gimp/Fu.pm | 60 +++--------
Gimp/Lib.xs | 2 +
Gimp/Makefile.PL | 2 +-
Gimp/Util.pm | 79 ++++---------
MANIFEST | 2 -
Net/Net.pm | 10 +--
README | 129 +++++++++++-----------
TODO | 146 ++++--------------------
UI/UI.xs | 99 ++++++++++++++++-
examples/Makefile.PL | 2 +-
examples/billboard | 6 +-
examples/blended2 | 10 +-
examples/bricks | 2 +-
examples/burst | 1 -
examples/dots | 9 +-
examples/dust | 27 ++---
examples/example-fu | 10 +-
examples/example-net | 8 +-
examples/example-oo | 16 ++--
examples/fade-alpha | 8 +-
examples/frame_filter | 1 -
examples/frame_reshuffle | 1 -
examples/glowing_steel | 30 ++----
examples/goldenmean | 5 +-
examples/gouge | 3 +-
examples/guidegrid | 1 -
examples/guides_to_selection | 7 +-
examples/iland | 1 -
examples/image_tile | 4 +-
examples/innerbevel | 38 ++----
examples/layerfuncs | 13 +--
examples/map_to_gradient | 3 +-
examples/mirrorsplit | 98 +++++++++--------
examples/pixelmap | 5 +-
examples/prep4gif | 4 +-
examples/randomart1 | 14 +-
examples/randomblends | 7 +-
examples/redeye | 3 +-
examples/repdup | 2 +-
examples/scratches | 5 +-
examples/selective_sharpen | 4 +-
examples/sethspin | 55 ++++------
examples/stamps | 2 +-
examples/translogo | 8 +-
examples/view3d | 5 +-
examples/warp-sharp | 1 -
examples/webify | 5 +-
examples/windify | 60 +----------
examples/xachlego | 4 +-
examples/xachshadow | 12 +-
examples/xachvision | 8 +-
examples/yinyang | 2 +-
po/Makefile.PL | 2 +-
t/gimpsetup.pl | 12 ++-
t/supplied.t | 140 +++++++++++++++++++++++
57 files changed, 584 insertions(+), 875 deletions(-)
---
diff --git a/Gimp.pm b/Gimp.pm
index 1f0b6bd..cf954b8 100644
--- a/Gimp.pm
+++ b/Gimp.pm
@@ -3,7 +3,7 @@ package Gimp;
use strict 'vars';
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK $AUTOLOAD %EXPORT_TAGS @EXPORT_FAIL
$interface_pkg $interface_type
- @PREFIXES
+ @PREFIXES @GUI_FUNCTIONS
$function $basename $spawn_opts
$in_quit $in_run $in_net $in_init $in_query $no_SIG
$help $verbose $host $in_top);
@@ -24,6 +24,14 @@ BEGIN {
use Gimp::ColorDB;
use Carp qw(croak);
+ GUI_FUNCTIONS = qw(
+ gimp_progress_init
+ gimp_progress_update
+ gimp_displays_flush
+ gimp_display_new
+ gimp_display_delete
+);
+
my @_procs = ('main', '__', 'N_');
#my @_default = (@_procs, ':consts' ,':_auto2');
my @_default = (@_procs, ':consts');
@@ -138,7 +146,6 @@ sub wrap_text {
$spawn_opts = "";
-# extra check for Gimp::Feature::import
$in_query=0 unless defined $in_query;
$in_top=$in_quit=$in_run=$in_net=$in_init=0;
($function)=$0=~/([^\/\\]+)$/;
@@ -1013,7 +1020,7 @@ Ed J (with oversight and guidance from Kevin Cozens) (2.3+)
=head1 SEE ALSO
perl(1), gimp(1), L<Gimp::OO>, L<Gimp::Data>, L<Gimp::Pixel>,
-L<Gimp::Util>, L<Gimp::UI>, L<Gimp::Feature>, L<Gimp::Net>,
+L<Gimp::Util>, L<Gimp::UI>, L<Gimp::Net>,
L<Gimp::Config>, and L<Gimp::Lib>.
=cut
diff --git a/Gimp/Fu.pm b/Gimp/Fu.pm
index 8935fdc..1dd3052 100644
--- a/Gimp/Fu.pm
+++ b/Gimp/Fu.pm
@@ -5,7 +5,10 @@ use Gimp::Data;
use File::Basename;
use strict;
use Carp qw(croak);
-use vars qw($run_mode);
+use vars qw($run_mode @EXPORT);
+
+ EXPORT = qw($run_mode);
+# EXPORT_OK = qw($run_mode save_image);
use constant {
PF_INT8 => Gimp::PDB_INT8,
@@ -54,8 +57,6 @@ Gimp::Fu - "easy to use" framework for Gimp scripts
use Gimp;
use Gimp::Fu;
- (this module uses Gtk, so make sure it's correctly installed)
-
=head1 DESCRIPTION
Currently, there are only three functions in this module. This
@@ -122,8 +123,6 @@ my @_params=qw(PF_INT8 PF_INT16 PF_INT32 PF_FLOAT PF_VALUE PF_STRING PF_COLOR
PF_BRUSH PF_PATTERN PF_GRADIENT PF_RADIO PF_CUSTOM PF_FILE
PF_TEXT);
-# EXPORT_OK = qw($run_mode save_image);
-
sub import {
local $^W=0;
my $up = caller;
@@ -192,17 +191,6 @@ sub interact {
goto &Gimp::UI::interact;
}
-sub fu_feature_present($$) {
- my ($feature,$function)= _;
- require Gimp::Feature;
- if (Gimp::Feature::present($feature)) {
- 1;
- } else {
- Gimp::Feature::missing(Gimp::Feature::describe($feature),$function);
- 0;
- }
-}
-
sub this_script {
return $scripts[0] unless $#scripts;
# well, not-so-easy-day today
@@ -271,11 +259,7 @@ Gimp::on_net {
my($interact)=1;
my($perl_sub,$function,$blurb,$help,$author,$copyright,$date,
- $menupath,$imagetypes,$params,$results,$features,$code,$type)= $this;
-
- for(@$features) {
- return unless fu_feature_present($_, $function);
- }
+ $menupath,$imagetypes,$params,$results,$code,$type)= $this;
# %map is a hash that associates (mangled) parameter names to parameter index
@map{map mangle_key($_->[1]), @{$params}} = (0..$#{$params});
@@ -323,7 +307,7 @@ Gimp::on_query {
script:
for(@scripts) {
my($perl_sub,$function,$blurb,$help,$author,$copyright,$date,
- $menupath,$imagetypes,$params,$results,$features,$code,$type,
+ $menupath,$imagetypes,$params,$results,$code,$type,
$defargs)= $_;
for (@$results) {
@@ -333,10 +317,6 @@ Gimp::on_query {
}
}
- for(@$features) {
- next script unless fu_feature_present($_,$function);
- }
-
# guess the datatype. yeah!
sub datatype(@) {
for(@_) {
@@ -364,12 +344,6 @@ Gimp::on_query {
$_->[0]=datatype($_->[3],@{$_->[4]}) if $_->[0] == PF_ADJUSTMENT;
}
- # Gtk not installed -> do not install menu entry
- if (@$params > $defargs) {
- require Gimp::Feature;
- undef $menupath unless Gimp::Feature::present('gtk');
- }
-
Gimp->install_procedure(
$function,
$blurb,
@@ -410,7 +384,6 @@ Gimp::on_query {
[
# like above, but for return values (optional)
],
- ['feature1', 'feature2'...], # optionally check for features
sub { code };
=over 2
@@ -474,8 +447,9 @@ optional extra arguments describing some types like C<PF_SLIDER>.
Each array element has the form C<[type, name, description, default_value,
extra_args]>.
-<Image>-type plugins get two additional parameters, image (C<PF_IMAGE>) and
-drawable (C<PF_DRAWABLE>). Do not specify these yourself. Also, the
+<Image>-type plugins get two additional parameters, image (C<PF_IMAGE>)
+and drawable (C<PF_DRAWABLE>) B<if and only if> the menu path does not start
+C<E<lt>ImageE<gt>/File/Create>. Do not specify these yourself. Also, the
C<run_mode> argument is never given to the script but its value can be
accessed in the package-global C<$run_mode>. The B<name> is used in the
dialog box as a hint. The B<description> will be used as a tooltip.
@@ -496,12 +470,6 @@ a C<PF_COLOR>.
This is just like the parameter array except that it describes the return
values. Specify the type and variable name only. This argument is optional.
-=item the features requirements
-
-See L<Gimp::Features> for a description of which features can be checked
-for. This argument is optional (but remember to specify an empty return
-value array, C<[]>, if you want to specify it).
-
=item the code
This is either an anonymous sub declaration (C<sub { your code here; }>, or a
@@ -640,16 +608,15 @@ sub register($$$$$$$$$;@) {
no strict 'refs';
my ($function, $blurb, $help, $author, $copyright, $date,
$menupath, $imagetypes, $params) = splice @_, 0, 9;
- my ($results, $features, $code, $type, $defargs);
+ my ($results, $code, $type, $defargs);
$results = (ref $_[0] eq "ARRAY") ? shift : [];
- $features = (ref $_[0] eq "ARRAY") ? shift : [];
$code = shift;
for($menupath) {
if (/^<Image>\//) {
$type = &Gimp::PLUGIN;
- unshift @$params, @image_params;
+ unshift @$params, @image_params unless m#^<Image>/File/Create#;
$defargs = @image_params;
} elsif (/^<Load>\//) {
$type = &Gimp::PLUGIN;
@@ -694,6 +661,9 @@ sub register($$$$$$$$$;@) {
$run_mode = shift; # global!
my(@pre,@defaults,@lastvals,$input_image);
+ Gimp::ignore_functions(@Gimp::GUI_FUNCTIONS)
+ unless $run_mode == &Gimp::RUN_INTERACTIVE;
+
# set default arguments
for (0..$#{$params}) {
next if defined $_[$_];
@@ -790,7 +760,7 @@ sub register($$$$$$$$$;@) {
Gimp::register_callback($function,$perl_sub);
push(@scripts,[$perl_sub,$function,$blurb,$help,$author,$copyright,$date,
- $menupath,$imagetypes,$params,$results,$features,$code,$type,
+ $menupath,$imagetypes,$params,$results,$code,$type,
$defargs]);
}
diff --git a/Gimp/Lib.xs b/Gimp/Lib.xs
index 90165f3..165f97c 100644
--- a/Gimp/Lib.xs
+++ b/Gimp/Lib.xs
@@ -811,6 +811,7 @@ push_gimp_sv (const GimpParam *arg, int array_as_ref)
case GIMP_PDB_LAYER:
case GIMP_PDB_CHANNEL:
case GIMP_PDB_DRAWABLE:
+ case GIMP_PDB_ITEM:
case GIMP_PDB_SELECTION:
case GIMP_PDB_VECTORS:
case GIMP_PDB_STATUS:
@@ -824,6 +825,7 @@ push_gimp_sv (const GimpParam *arg, int array_as_ref)
case GIMP_PDB_LAYER: id = arg->data.d_layer; break;
case GIMP_PDB_CHANNEL: id = arg->data.d_channel; break;
case GIMP_PDB_DRAWABLE: id = arg->data.d_drawable; break;
+ case GIMP_PDB_ITEM: id = arg->data.d_item; break;
case GIMP_PDB_SELECTION: id = arg->data.d_selection; break;
case GIMP_PDB_VECTORS: id = arg->data.d_vectors; break;
case GIMP_PDB_STATUS: id = arg->data.d_status; break;
diff --git a/Gimp/Makefile.PL b/Gimp/Makefile.PL
index aea2c6d..2074034 100644
--- a/Gimp/Makefile.PL
+++ b/Gimp/Makefile.PL
@@ -1,7 +1,7 @@
use ExtUtils::MakeMaker;
use ExtUtils::Depends;
-do '../config.pl';
+require '../config.pl';
my $pkg = new ExtUtils::Depends Gimp;
$pkg->set_inc($cfg{GIMP_CFLAGS});
diff --git a/Gimp/Util.pm b/Gimp/Util.pm
index 09d4c54..1b27149 100644
--- a/Gimp/Util.pm
+++ b/Gimp/Util.pm
@@ -39,8 +39,9 @@ The need to explicitly C<use Gimp::Util> will go away in the future.
=cut
package Gimp::Util;
-require Exporter;
- ISA = qw(Exporter);
+use Exporter 'import';
+use vars qw(@EXPORT $VERSION);
+use strict;
@EXPORT = qw(
layer_create
text_draw
@@ -50,6 +51,7 @@ require Exporter;
# EXPORT_OK = qw();
import Gimp;
+# manual "import" to shut perl -cw up
sub __ ($);
$VERSION = 2.3001;
@@ -102,12 +104,12 @@ sub layer_create {
my $tcol; # scratch color
# create a colored layer
- $layer = Gimp->layer_new ($image,Gimp->image_width($image),
+ $layer = Gimp::Layer->new ($image,Gimp->image_width($image),
Gimp->image_height($image),
- RGB_IMAGE,$name,100,NORMAL_MODE);
+ &RGB_IMAGE,$name,100,&NORMAL_MODE);
$tcol = Gimp->palette_get_background ();
Gimp->palette_set_background ($color);
- Gimp->drawable_fill ($layer,BACKGROUND_FILL);
+ Gimp->drawable_fill ($layer,&BACKGROUND_FILL);
Gimp->image_add_layer($image, $layer, $pos);
Gimp->palette_set_background ($tcol); # reset
$layer;
@@ -137,13 +139,13 @@ sub text_draw {
Gimp->palette_set_foreground ($fgcolor);
# Create a layer for the text.
$text_layer = Gimp->text($image,-1,0,0,$text,10,1,$size,
- PIXELS,"*",$font,"*","*","*","*");
+ &PIXELS,"*",$font,"*","*","*","*");
# Do the fun stuff with the text.
- Gimp->layer_set_preserve_trans($text_layer, FALSE);
+ Gimp->layer_set_preserve_trans($text_layer, &FALSE);
# add text to image
- Gimp->image_add_layer($image, $text_layer, $pos);
+ Gimp->image_add_layer($image, $text_layer, 0);
# merge white and text
Gimp->image_merge_visible_layers ($image,1);
# cleanup the left over layer (!)
@@ -175,16 +177,16 @@ sub image_create_text {
# $font = "Helvetica" if ($font eq "");
# create an image. We'll just set whatever size here because we want
# to resize the image when we figure out how big the text is.
- $image = Gimp->image_new(64,64,RGB); # don't waste too much resources ;-/
+ $image = Gimp::Image->new(64,64,&RGB); # don't waste too much resources ;-/
$tcol = Gimp->palette_get_foreground ();
Gimp->palette_set_foreground ($fgcolor);
# Create a layer for the text.
$text_layer = Gimp->text($image,-1,0,0,$text,10,1,$size,
- PIXELS,"*",$font,"*","*","*","*","*","*");
+ &PIXELS,"*",$font,"*","*","*","*","*","*");
Gimp->palette_set_foreground ($tcol);
- Gimp->layer_set_preserve_trans($text_layer, FALSE);
+ Gimp->layer_set_preserve_trans($text_layer, &FALSE);
# Resize the image based on size of text.
Gimp->image_resize($image,Gimp->drawable_width($text_layer),
@@ -258,38 +260,31 @@ alpha.
mark the given layers visible (invisible) and all others invisible (visible).
-=item C<gimp_layer_get_position $layer>
-
-return the position the layer has in the image layer stack.
-
-=item C<gimp_layer_set_position $layer,$new_index>
-
-moves the layer to a new position in the layer stack.
-
=cut
+
sub gimp_image_layertype {
my($type,$alpha) = ($_[0]->base_type,$_[1]);
- $type == RGB ? $alpha ? RGBA_IMAGE : RGB_IMAGE :
- $type == GRAY ? $alpha ? GRAYA_IMAGE : GRAY_IMAGE :
- $type == INDEXED ? $alpha ? INDEXEDA_IMAGE : INDEXED_IMAGE :
+ $type == &RGB ? $alpha ? &RGBA_IMAGE : &RGB_IMAGE :
+ $type == &GRAY ? $alpha ? &GRAYA_IMAGE : &GRAY_IMAGE :
+ $type == &INDEXED ? $alpha ? &INDEXEDA_IMAGE : &INDEXED_IMAGE :
die;
}
sub gimp_layer2imagetype {
my $type = shift;
- $type == RGB_IMAGE ? RGB :
- $type == RGBA_IMAGE ? RGB :
- $type == GRAY_IMAGE ? GRAY :
- $type == GRAYA_IMAGE ? GRAY :
- $type == INDEXED_IMAGE ? INDEXED :
- $type == INDEXEDA_IMAGE ? INDEXED :
+ $type == &RGB_IMAGE ? &RGB :
+ $type == &RGBA_IMAGE ? &RGB :
+ $type == &GRAY_IMAGE ? &GRAY :
+ $type == &GRAYA_IMAGE ? &GRAY :
+ $type == &INDEXED_IMAGE ? &INDEXED :
+ $type == &INDEXEDA_IMAGE ? &INDEXED :
die;
}
sub gimp_image_add_new_layer {
my ($image,$index,$filltype,$alpha)= _;
- my $layer = new Layer ($image, $image->width, $image->height, $image->layertype (defined $alpha ? $alpha
: 1), join(":",(caller)[1,2]), 100, NORMAL_MODE);
- $layer->fill (defined $filltype ? $filltype : BACKGROUND_FILL);
+ my $layer = new Gimp::Layer ($image, $image->width, $image->height, $image->layertype (defined $alpha ?
$alpha : 1), join(":",(caller)[1,2]), 100, &NORMAL_MODE);
+ $layer->fill (defined $filltype ? $filltype : &BACKGROUND_FILL);
$image->add_layer ($layer, $index*1);
$layer;
}
@@ -310,30 +305,6 @@ sub gimp_image_set_invisible {
}
}
-sub gimp_layer_get_position {
- my $layer = shift;
- my @layers = $layer->get_image->get_layers;
- for (0..$#layers) {
- # the my is necessary for broken perl (return $_ => undef)
- return (my $index=$_) if ${$layers[$_]} == $$layer;
- }
- ();
-}
-
-sub gimp_layer_set_position {
- my($layer,$new_pos)= _;
- $pos=$layer->get_position;
- $layer->add_alpha;
- while($pos>$new_pos) {
- $layer->lower_layer;
- $pos--;
- }
- while($pos<$new_pos) {
- $layer->raise_layer;
- $pos++;
- }
-}
-
=pod
=back
diff --git a/MANIFEST b/MANIFEST
index a8c7bea..4f7edd9 100644
--- a/MANIFEST
+++ b/MANIFEST
@@ -17,7 +17,6 @@ Gimp/ColorDB.pm
Gimp/Config.pm.in
Gimp/Constant.pm
Gimp/Data.pm
-Gimp/Feature.pm
Gimp/Fu.pm
Gimp/Lib.pm
Gimp/Lib.xs
@@ -97,7 +96,6 @@ examples/xachlego
examples/xachshadow
examples/xachvision
examples/yinyang
-extra.c
extra.h
gppport.h
logo.xpm
diff --git a/Net/Net.pm b/Net/Net.pm
index f87f630..1c64306 100644
--- a/Net/Net.pm
+++ b/Net/Net.pm
@@ -132,14 +132,6 @@ sub set_trace {
$old_level;
}
-my @gimp_gui_functions = qw(
- gimp_progress_init
- gimp_progress_update
- gimp_displays_flush
- gimp_display_new
- gimp_display_delete
-);
-
sub start_server {
my $opt = shift;
$opt = $Gimp::spawn_opts unless $opt;
@@ -152,7 +144,7 @@ sub start_server {
$gimp_pid = fork;
croak __"unable to fork: $!" if $gimp_pid < 0;
if ($gimp_pid > 0) {
- Gimp::ignore_functions(@gimp_gui_functions) unless $opt=~s/(^|:)gui//;
+ Gimp::ignore_functions(@Gimp::GUI_FUNCTIONS) unless $opt=~s/(^|:)gui//;
return $server_fh;
}
close $server_fh;
diff --git a/README b/README
index b5ec0d7..d1d792a 100644
--- a/README
+++ b/README
@@ -155,77 +155,74 @@ LICENSE
EXAMPLE PERL PLUG-IN
To get even more look & feel, here is a complete plug-in source,
- its the examples/example-fu script from the distribution.
+ it's the examples/example-fu script from the distribution.
#!/opt/bin/perl
use Gimp;
use Gimp::Fu;
-# expand your terminal to 121 across to read easily...
-
-register "gimp_fu_example_script", # fill in a function name
- "A non-working example of Gimp::Fu usage", # and a short description,
- "Just a starting point to derive new ". # a (possibly multiline) help text
- "scripts. Always remember to put a long".
- "help message here!",
- "Marc Lehmann <pcg\ goof com>", # don't forget your name (author)
- "(c)1998,1999,2000 Marc Lehmann", # and your copyright!
- "20000321", # the date this script was written (YYYYMMDD)
- N_"<Toolbox>/Xtns/Gimp::Fu Example...", # the menu path - the 'N_' is for
internationalization
- "RGB*, GRAYA", # image types to accept (RGB, RGAB amnd GRAYA)
- [ # one of each type of parameter here
- # argument type, switch name , a short description , default value, extra arguments
- [PF_SLIDER , "width" , "The image width" , 360, [300, 500]],
- [PF_SPINNER , "height" , "The image height" , 100, [100, 200]],
- [PF_STRING , "text" , "The Message" , "example text"],
- [PF_INT , "bordersize" , "The bordersize" , 10],
- [PF_FLOAT , "borderwidth" , "The borderwidth" , 1/5],
- [PF_FONT , "font" , "The Font Family" ],
- [PF_COLOUR , "text_colour" , "The (foreground) text colour", [10,10,10]],
- [PF_COLOUR , "bg_colour" , "The background colour" , [0xff,0x80,0]],
- [PF_TOGGLE , "ignore_cols" , "Ignore colours" , 0],
- [PF_IMAGE , "extra_image" , "An additonal picture to ignore"],
- [PF_DRAWABLE , "extra_draw" , "Somehting to ignroe as well" ],
- [PF_RADIO , "type" , "The effect type" , 0, [small => 0, large => 1]],
- [PF_BRUSH , "a_brush" , "An unused brush" ],
- [PF_PATTERN , "a_pattern" , "An unused pattern" ],
- [PF_GRADIENT , "a_gradients" , "An unused gradients" ],
- ],
- sub {
-
- # now do sth. useful with the garbage we got ;)
- my($width,$height,$text,$brd1,$brd2,$font,$fg,$bg,$ignore,$xtraimg,
- $xtradrw,$effecttype,$brush,$pattern,$gradient)= _;
-
- # set tracing, disable this to get rid of the debugging output
- Gimp::set_trace(TRACE_CALL);
-
- my $img = new Image ($width, $height, RGB);
-
- # put an undo group around any modifications, so that
- # they can be undone in one step.
- $img->undo_group_start;
-
- # the __ before the string in the next line indicates text that must be translated
- my $l = new Layer ($img, $width, $height, RGB, __"Background", 100, NORMAL_MODE);
- $l->add_layer(0);
-
- # now a few syntax examples
-
- Context->set_foreground($fg) unless $ignore;
- Context->set_background($bg) unless $ignore;
-
- fill $l BACKGROUND_FILL;
- $text_layer = $img->text_fontname(-1, 10, 10, $text, 5, 1, 10, PIXELS, $font);
-
- Palette->set_foreground("green");
-
- # close the undo push group
- $img->undo_group_end;
-
- $img; # return the image, or an empty list, i.e. ()
-};
+register
+ "gimp_fu_example_script", # fill in a function name
+ "A non-working example of Gimp::Fu usage", # and a short description,
+ "Just a starting point to derive new ". # a (possibly multiline) help text
+ "scripts. Always remember to put a long".
+ "help message here!",
+ "Marc Lehmann <pcg\ goof com>", # don't forget your name (author)
+ "(c)1998,1999,2000 Marc Lehmann", # and your copyright!
+ "20000321", # the date this script was written (YYYYMMDD)
+ N_"<Image>/File/Create/Gimp::Fu Example...", # the menu path - the 'N_' is for internationalization
+ "RGB*, GRAYA", # image types to accept (RGB, RGAB amnd GRAYA)
+ [ # one of each type of parameter here
+ # argument type, switch name , a short description , default value, extra arguments
+ [PF_SLIDER , "width" , "The image width" , 360, [300, 500]],
+ [PF_SPINNER , "height" , "The image height" , 100, [100, 200]],
+ [PF_STRING , "text" , "The message" , "example text"],
+ [PF_INT , "bordersize" , "The bordersize" , 10],
+ [PF_FLOAT , "borderwidth" , "The borderwidth" , 1/5],
+ [PF_FONT , "font" , "The font family" ],
+ [PF_COLOUR , "text_colour" , "The (foreground) text colour", [10,10,10]],
+ [PF_COLOUR , "bg_colour" , "The background colour" , [0xff,0x80,0]],
+ [PF_TOGGLE , "ignore_cols" , "Ignore colours" , 0],
+ [PF_IMAGE , "extra_image" , "An additional picture to ignore"],
+ [PF_DRAWABLE , "extra_draw" , "Something to ignore as well" ],
+ [PF_RADIO , "type" , "The effect type" , 0, [small => 0, large => 1]],
+ [PF_BRUSH , "a_brush" , "An unused brush" ],
+ [PF_PATTERN , "a_pattern" , "An unused pattern" ],
+ [PF_GRADIENT , "a_gradients" , "An unused gradients" ],
+ ],
+ sub {
+ # now do something useful with our parameters
+ my($width,$height,$text,$brd1,$brd2,$font,$fg,$bg,$ignore,$xtraimg,
+ $xtradrw,$effecttype,$brush,$pattern,$gradient)= _;
+
+ # set tracing, disable this to get rid of the debugging output
+ Gimp::set_trace(TRACE_CALL);
+
+ my $img = new Gimp::Image ($width, $height, RGB);
+
+ # put an undo group around any modifications, so that
+ # they can be undone in one step.
+ $img->undo_group_start;
+
+ # the __ before the string in the next line indicates text that must be translated
+ my $l = new Gimp::Layer ($img, $width, $height, RGB, __"Background", 100, NORMAL_MODE);
+ $l->add_layer(0);
+
+ # now a few syntax examples
+
+ Gimp::Context->set_foreground($fg) unless $ignore;
+ Gimp::Context->set_background($bg) unless $ignore;
+
+ fill $l BACKGROUND_FILL;
+ $text_layer = $img->text_fontname(-1, 10, 10, $text, 5, 1, 10, PIXELS, $font);
+
+ Gimp::Palette->set_foreground("green");
+
+ # close the undo push group
+ $img->undo_group_end;
+
+ $img; # return the image, or an empty list, i.e. ()
+ };
exit main; # call the "main" funciton to start the script working
-
diff --git a/TODO b/TODO
index 14493c5..971672c 100644
--- a/TODO
+++ b/TODO
@@ -1,122 +1,24 @@
-<Kevin's random notes>
-* Eliminate deprecation warnings in example scripts.
-* Review TODO list to see which issues still need to be addressed.
-* Get list of enums from GIMP instead of using a hard-coded list.
-* Make use of new GIMP font requester.
-* When a script is run from the command line which takes a PF_ADJUSTMENT, the
- value passed to the script is the full list of arguments and not the default
- value for the spinner or slider.
-
-
-<Seth's random notes>
-Make a 2.2 release so I can tag it and start towards 2.4. Critical items:
-* Cleanup unused stuff:
- Remove Gimp/PDL.pm
- Remove Module
- Remove embed
- Remove etc
- Remove nolib
- Remove examples/image_list
- Remove or rewrite font_table - logic in it no longer applicable.
-* Fix the code so I don't get "
-Gtk-CRITICAL **: file gtktooltips.c: line 314 (gtk_tooltips_set_tip): assertion `GTK_IS_TOOLTIPS (tooltips)'
failed at ..../Gimp/UI.pm line 821.
-" repeated when I use a color picker.
-
-Win32 port?
-
-Add a gtk2 gimp console.
-
-Reorganize Menues.
-
-Impprove documentation quality - feedback desired!
-
-HIGify dialogs as possible.
-
-A Compat12.pm for GIMP 1.2 compatibility (no way to convert xlfd stuff though).
-Done? (I fixed some xlfd stuff - kc)
-
-Generate a new web presence for Gimp-Perl, with a friendlier face to it. Redo my scripts page, possibly
expanding to cover all working scripts? Regenerate documentation there.
-
-Add optional podviewer for help. Add POD docs to all example scripts/documentation, to encourage good style.
-
-New mailing list; netcentral doesn't archive, rarely used.
-
-Figure out i18n some day.
-
-Determine what if anything is needed in the enums* in the root. I expect I can remove all of this.
-
-Remove unused(?) extra.[ch]
-
-<Marc's previous stuff>
-this is mostly my personal worksheet and notepad, which may not be
-up-to-date and may not even be readable ;)
-
-Put module under LGPL?
-
-/usr/app/lib/perl5/Gtk.pm:107 (method call -> goto)
-
-gimpenv.c, gimpmodule.h, color_selector.h, color_display.h
-
-po/Makefile
-<Sven> schmorp: I think the makefile should have all (builds the pot-file and
- calls msgfmt if po-files have changed),
-+update-po (merges all po-files), install, uninstall eventually
-
-API generalization
- guide ->
- gimp_desaturate -> drawable
-
-bugs
- STIFTUNG, FOUNDATION etc.. => ask.
- * URGENT: deinit might block... tis'is bad, but not close'ing is also bad
- * --enable-perl-prefix, --with-perl=, --with-perl-cc=
- * URGENT: podperl doesn't work.
- * try to work around the redhat-undef $fh => no close problem.
- * .pot file -> add to dist(???)
- * damnit libintl crazy shit
- * font_text with negative size? bug report #5523
- * gimp-perl list archives.. where and add this to the gimp.html page!
- * g_direct_equal and glin hash, kill in favour of way nicer perl hashes.
- * ping-funktion für JENS.
- * gtview_log (perlcc & helpfenster) erste zeile anzeigen + scrollbar
- * document on_xxx functions and register_callback
- * fix Gimp::Feature::missing => on_query-dir!
- * on-query => remove gimp::fu parasite(?)
-[????] * bricks requires disable for pattern(?)
- * installation & Feature system (?)
- * map_to_gradient does not work on GRAYA thingies. Argh.
- * document Gimp::PDL and rect2, ...2 functions!
- * Kommandozeilenmodus(!). (???)
- * gimp-piddle must be written back automatically on destroy, if changed
- * gimp-tile set dirty automatically(!)
- * create gimpstyle.pod
-
-important issues
-
- * gimp_default_display -> undef when not available.
- * find_next_guide is a lousy interface. => just do num_guides
- * constant names (RADIO) automatically into help strings!
- * migrate BOOT: into INIT() (forgot why but important for B)
- * gimp_progress_done, gimp_progress_close
- * gimp_default_display (...) for libgimp
- * Gimp::Module for modules (!)
- * gimp for dummies (you don't understand this, harharhar!)
- * PerlCC configurable options for Perl-Server startup, Gipm_host etc.
- * implement CALLBACKS via the Perl-Server
- * PF_COORDS (just as Light Effects/FlareFX)
- * PF_PREVIEW(!)
- * Gimp::IO (?)
- * install scripts in share/
- * vamp up homepage
- * Gimp::ping
- * allow plug-ins to register with only a drawable argument(!)
- * gradient button
- * default parameters at end(!)
- * try to deduce default parameters
-
-long term issues and ideas
-
- * rewrite interact() in pure C, gets rid of most gtk dependencies.
- * default function parameters (with hash %defaults?)
- * gimp_text(text => "hallo", family => "engraver", size => 20);
-
+Items as of 2014-03-31 (by Ed J)
+* Gimp/Lib.xs is huge, and not very XS-y - lots of it is manually
+ pushing GIMP data structures onto perl stack and vice versa. Figure
+ way to pass GIMP data back and forth directly via typemap system. May
+ involve a gimp-perl "wrapper" data structure that pairs an SV with its
+ GimpPDBArgType/GimpParamDef counterpart - Gimp::Lib::Data?
+* gimp-perl website: maybe just gimp.org/glossary entry - only needs
+ links to CPAN, bugzilla, git - make sure CPAN has all POD docs
+ - https://mail.gnome.org/mailman/listinfo/gimp-developer-list
+ - https://bugzilla.gnome.org/buglist.cgi?quicksearch=product:gimp-perl
+* Remove extra.[ch] - move into Gimp.xs?
+* Get gimp PDL objects working right over Gimp::Net - infrastructure is there
+ - gimp-tile set dirty automatically(!)
+* Document on_* and callback architecture
+* Restructure dirs so all libs under lib/ using ExtUtils::MakeMaker::BigHelper
+* http://search.cpan.org/dist/Glib-Object-Introspection/
+* Add a gtk2 gimp-perl console - cf http://registry.gimp.org/node/29348
+ - gimp/plug-ins/script-fu/script-fu-console.c
+* Test menupath <File> etc
+
+Legacy notes from Seth Burgess:
+* Win32 port
+* Improve documentation quality - feedback desired!
+* Figure out i18n some day.
diff --git a/UI/UI.xs b/UI/UI.xs
index b5896a4..58cc784 100644
--- a/UI/UI.xs
+++ b/UI/UI.xs
@@ -17,7 +17,104 @@
#include <libgimp/gimpexport.h>
#endif
-#include "extra.c"
+#include <glib-object.h>
+
+#include <gtk2perl-autogen.h>
+
+/* need to factor these out, otherwise we always need gtk :( */
+#include <libgimpwidgets/gimpwidgets.h>
+#include <libgimpbase/gimpbasetypes.h>
+
+#include "extra.h"
+
+static void
+sv_color3 (SV *sv, gdouble *e, gdouble *f, gdouble *g, gdouble *a)
+{
+ if (!SvROK (sv)
+ || SvTYPE (SvRV (sv)) != SVt_PVAV
+ || av_len ((AV *)SvRV (sv)) < 2
+ || av_len ((AV *)SvRV (sv)) > 3)
+ croak ("GimpRGB/HSV/HLS must be specified as an arrayref with length three or four");
+
+ *e = SvNV (*av_fetch ((AV *)SvRV (sv), 0, 1));
+ *f = SvNV (*av_fetch ((AV *)SvRV (sv), 1, 1));
+ *g = SvNV (*av_fetch ((AV *)SvRV (sv), 2, 1));
+ *a = av_len ((AV *)SvRV (sv)) < 3
+ ? 1.
+ : SvNV (*av_fetch ((AV *)SvRV (sv), 3, 1));
+}
+
+static SV *
+newSV_color3 (gdouble e, gdouble f, gdouble g, gdouble a)
+{
+ AV *av = newAV ();
+
+ av_push (av, newSVnv (e));
+ av_push (av, newSVnv (f));
+ av_push (av, newSVnv (g));
+ av_push (av, newSVnv (a));
+
+ return newRV_noinc ((SV *)av);
+}
+
+#define ENUM(name) \
+ static GType t_ ## name; \
+ static GType name ## _type (void) \
+ { \
+ if (!t_ ## name) \
+ t_ ## name = g_enum_register_static (# name, _ ## name ## _values); \
+ return t_ ## name; \
+ }
+
+static const GEnumValue _gimp_unit_values[] = {
+ { GIMP_UNIT_PIXEL, "GIMP_UNIT_PIXEL", "pixel" },
+ { GIMP_UNIT_INCH, "GIMP_UNIT_INCH", "inch" },
+ { GIMP_UNIT_MM, "GIMP_UNIT_MM", "mm" },
+ { GIMP_UNIT_POINT, "GIMP_UNIT_POINT", "point" },
+ { GIMP_UNIT_PICA, "GIMP_UNIT_PICA", "pica" },
+ { GIMP_UNIT_END, "GIMP_UNIT_END", "end" },
+ { 0, NULL, NULL }
+};
+ENUM(gimp_unit)
+static const GEnumValue _gimp_chain_position_values[] = {
+ { GIMP_CHAIN_TOP, "GIMP_CHAIN_TOP", "top" },
+ { GIMP_CHAIN_LEFT, "GIMP_CHAIN_LEFT", "left" },
+ { GIMP_CHAIN_BOTTOM, "GIMP_CHAIN_BOTTOM", "bottom" },
+ { GIMP_CHAIN_RIGHT, "GIMP_CHAIN_RIGHT", "right" },
+ { 0, NULL, NULL }
+};
+ENUM(gimp_chain_position)
+static const GEnumValue _gimp_color_area_type_values[] = {
+ { GIMP_COLOR_AREA_FLAT, "GIMP_COLOR_AREA_FLAT", "flat" },
+ { GIMP_COLOR_AREA_SMALL_CHECKS, "GIMP_COLOR_AREA_SMALL_CHECKS", "small-checks" },
+ { GIMP_COLOR_AREA_LARGE_CHECKS, "GIMP_COLOR_AREA_LARGE_CHECKS", "large-checks" },
+ { 0, NULL, NULL }
+};
+ENUM(gimp_color_area_type)
+static const GEnumValue _gimp_color_selector_channel_values[] = {
+ { GIMP_COLOR_SELECTOR_HUE, "GIMP_COLOR_SELECTOR_HUE", "hue" },
+ { GIMP_COLOR_SELECTOR_SATURATION, "GIMP_COLOR_SELECTOR_SATURATION", "saturation" },
+ { GIMP_COLOR_SELECTOR_VALUE, "GIMP_COLOR_SELECTOR_VALUE", "value" },
+ { GIMP_COLOR_SELECTOR_RED, "GIMP_COLOR_SELECTOR_RED", "red" },
+ { GIMP_COLOR_SELECTOR_GREEN, "GIMP_COLOR_SELECTOR_GREEN", "green" },
+ { GIMP_COLOR_SELECTOR_BLUE, "GIMP_COLOR_SELECTOR_BLUE", "blue" },
+ { GIMP_COLOR_SELECTOR_ALPHA, "GIMP_COLOR_SELECTOR_ALPHA", "alpha" },
+ { 0, NULL, NULL }
+};
+ENUM(gimp_color_selector_channel)
+static const GEnumValue _gimp_size_entry_update_policy_values[] = {
+ { GIMP_SIZE_ENTRY_UPDATE_NONE, "GIMP_SIZE_ENTRY_UPDATE_NONE", "none" },
+ { GIMP_SIZE_ENTRY_UPDATE_SIZE, "GIMP_SIZE_ENTRY_UPDATE_SIZE", "size" },
+ { GIMP_SIZE_ENTRY_UPDATE_RESOLUTION, "GIMP_SIZE_ENTRY_UPDATE_RESOLUTION", "resolution" },
+ { 0, NULL, NULL }
+};
+ENUM(gimp_size_entry_update_policy)
+
+#define SvGimpRGB(sv, color) sv_color3 ((sv), &(color).r, &(color).g, &(color).b, &(color).a)
+#define SvGimpHSV(sv, color) sv_color3 ((sv), &(color).h, &(color).s, &(color).v, &(color).a)
+
+#define newSVGimpRGB(color) newSV_color3 ((color).r, (color).g, (color).b, (color).a)
+#define newSVGimpHSV(color) newSV_color3 ((color).h, (color).s, (color).v, (color).a)
typedef GtkWidget GimpMemsizeEntry_own;
typedef GtkWidget GimpButton_own;
diff --git a/examples/Makefile.PL b/examples/Makefile.PL
index a922aff..d019151 100644
--- a/examples/Makefile.PL
+++ b/examples/Makefile.PL
@@ -18,6 +18,7 @@ require '../config.pl';
glowing_steel goldenmean guidegrid guides_to_selection
image_tile innerbevel
layerfuncs mirrorsplit
+ map_to_gradient
perlotine prep4gif
repdup roundsel
scratches sethspin stamps
@@ -30,7 +31,6 @@ require '../config.pl';
gouge
redeye
pixelmap
- view3d
);
sub plugin_target {
diff --git a/examples/billboard b/examples/billboard
index 0d7b70a..06b6027 100755
--- a/examples/billboard
+++ b/examples/billboard
@@ -119,8 +119,8 @@ register "billboard",
$tmpimglayer = $img->add_new_layer(0,3,1);
$img->display_new;
Gimp->progress_init("Billboard...",-1);
- Context->push();
- Context->set_background($color);
+ Gimp::Context->push();
+ Gimp::Context->set_background($color);
$src->edit_copy();
$spinlayer = $tmpimglayer->edit_paste(1);
$spinlayer->floating_sel_to_layer();
@@ -179,7 +179,7 @@ register "billboard",
);
}
- Context->pop();
+ Gimp::Context->pop();
gimp_displays_flush();
return();
};
diff --git a/examples/blended2 b/examples/blended2
index 2890300..68cb254 100755
--- a/examples/blended2
+++ b/examples/blended2
@@ -23,7 +23,7 @@ sub my_innerbevel {
elsif ($gimpmajor == 2 && $gimpminor >= 3) { $api23 = 1; }
else {die "Don't know how to handle gimp version $gimpversion with this plugin!\n"};
- Context->push();
+ Gimp::Context->push();
my $img = gimp_image_new (256, 100, RGB_IMAGE);
$drawable->get_image->selection_all;
@@ -32,7 +32,7 @@ sub my_innerbevel {
if ($rad_tog == 0) {
my $bg_layer;
$bg_layer=$img->layer_new($drawable->width,$drawable->height,$image->layertype(1),
"Background", 100, NORMAL_MODE);
- Context->set_background ($bg_col);
+ Gimp::Context->set_background ($bg_col);
$bg_layer->drawable_fill(BACKGROUND_FILL);
$img->insert_layer($bg_layer,0,0);
}
@@ -48,8 +48,8 @@ sub my_innerbevel {
elsif ($api23) {
$text1_lay->set_lock_alpha(1);
}
- Context->set_foreground ($bl1);
- Context->set_background ($bl2);
+ Gimp::Context->set_foreground ($bl1);
+ Gimp::Context->set_background ($bl2);
@start = ($text1_lay->width / 2 - 5, 0);
@end = ($text1_lay->width / 2 + 5, $text1_lay->height);
gimp_edit_blend ($text1_lay,
@@ -69,7 +69,7 @@ sub my_innerbevel {
$text2_lay=$text1_lay->copy(1);
$text2_lay->add_alpha;
$img->insert_layer($text2_lay, 0, -1);
- Context->set_background ([255, 255, 255]);
+ Gimp::Context->set_background ([255, 255, 255]);
$text2_lay->edit_fill(BACKGROUND_FILL);
if ($api22) {
$text1_lay->set_preserve_trans(0);
diff --git a/examples/bricks b/examples/bricks
index d3f232a..1a0e12f 100755
--- a/examples/bricks
+++ b/examples/bricks
@@ -139,7 +139,7 @@ register
"Tels",
"http://bloodgate.com",
"10/26/1999a",
- N_"<Image>/Filters/Render/Bricks...",
+ N_"<Image>/File/Create/Patterns/Bricks...",
undef,
[
[PF_PATTERN, "background", "Brick pattern", "Leather"],
diff --git a/examples/burst b/examples/burst
index bc0104c..cff68af 100755
--- a/examples/burst
+++ b/examples/burst
@@ -82,7 +82,6 @@ fades from if you have Fade set\n",
[PF_SPINNER, 'arc_angle', "How many degrees to arc through.", 360, [-360, 360, 1]]
],
[],
- [],
sub {
my($img,$layer, $shape, $fade_dir, $points,
$inside_pixels, $outside_pixels, $start_angle, $arc_angle) = _;
diff --git a/examples/dots b/examples/dots
index 44e2f75..d147a14 100755
--- a/examples/dots
+++ b/examples/dots
@@ -27,7 +27,6 @@ register "dots",
[PF_SPINNER, "yoffset", "Offset of dots in y dimension", 0, [0,255,1]],
],
[],
- ['gimp-1.3'],
sub {
my($img,$layer,$size,$dotcolor,$opacity,$xspacing,$yspacing,$xoffset,$yoffset) = _;
my $has_noselection;
@@ -63,11 +62,11 @@ register "dots",
}
# Set opacity of dots via selection mask
- Context->push();
+ Gimp::Context->push();
$opc = gimp_channel_new($img,$img->width,$img->height,"OPC", 50, [0,0,0]);
$img->insert_channel($opc,0,0);
- Context->set_foreground([($opacity/100.0)x3]);
+ Gimp::Context->set_foreground([($opacity/100.0)x3]);
$opc->fill(FOREGROUND_FILL);
$img->select_item(CHANNEL_OP_INTERSECT, $opc);
@@ -75,7 +74,7 @@ register "dots",
$img->select_item(CHANNEL_OP_INTERSECT, $selchannel);
# Make the dots
- Context->set_foreground($dotcolor);
+ Gimp::Context->set_foreground($dotcolor);
$layer->edit_fill(FOREGROUND_FILL);
# Cleanup to state before plugin was called
@@ -91,7 +90,7 @@ register "dots",
$img->remove_channel($selchannel);
$img->remove_channel($opc);
- Context->pop();
+ Gimp::Context->pop();
$img->undo_group_end;
$layer->set_active_layer;
diff --git a/examples/dust b/examples/dust
index 13be6b4..3bb0343 100755
--- a/examples/dust
+++ b/examples/dust
@@ -80,21 +80,16 @@ register "dust",
$image->undo_group_start;
- Context->push();
- Context->set_foreground("white");
- Context->set_brush("Circle (01)");
- Context->set_opacity(50);
- # This will cause a PDB failure as of 9/7/05 CVS - can't set
- # spacing on non-editable brush via PDB. We should probably
- # let this happen, so we can do via script what we can via the UI.
- # Brushes->set_spacing(Context->get_brush, 100);
- warn "Unable to set spacing due to missing PDB functionailty\n";
- Context->set_paint_mode(NORMAL_MODE);
-
- if (1) {
- $layer = $image->add_new_layer (0, TRANSPARENT_FILL, 1);
- $layer->set_mode (DIFFERENCE_MODE);
- }
+ Gimp::Context->push;
+ Gimp::Context->set_foreground("white");
+ my $brush = Gimp->brush_duplicate("Circle (01)");
+ Gimp::Context->set_brush($brush);
+ Gimp::Brushes->set_spacing($brush, 100);
+ Gimp::Context->set_opacity(50);
+ Gimp::Context->set_paint_mode(NORMAL_MODE);
+
+ $layer = $image->add_new_layer (0, TRANSPARENT_FILL, 1);
+ $layer->set_mode (DIFFERENCE_MODE);
for (1..($w*$h*$density)) {
my ($x, $y) = (rand $w, rand $h);
@@ -109,7 +104,7 @@ register "dust",
$layer->paintbrush_default([map { $x+$c[$_], $y+$c[$_+$l] } 0..$l-1]);
}
- Context->pop();
+ Gimp::Context->pop;
$image->undo_group_end;
diff --git a/examples/example-fu b/examples/example-fu
index f1f8671..144761c 100755
--- a/examples/example-fu
+++ b/examples/example-fu
@@ -42,7 +42,7 @@ register "gimp_fu_example_script", # fill in a function name
Gimp::set_trace(TRACE_CALL);
# store current context, so that present settings aren't affected
- Context->push();
+ Gimp::Context->push();
my $img = new Gimp::Image ($width, $height, RGB);
@@ -56,19 +56,19 @@ register "gimp_fu_example_script", # fill in a function name
# now a few syntax examples
- Context->set_foreground($fg) unless $ignore;
- Context->set_background($bg) unless $ignore;
+ Gimp::Context->set_foreground($fg) unless $ignore;
+ Gimp::Context->set_background($bg) unless $ignore;
fill $l BACKGROUND_FILL;
my $text_layer = $img->text_fontname(-1, 10, 10, $text, 5, 1, 10, PIXELS, $font);
- Context->set_foreground("green");
+ Gimp::Context->set_foreground("green");
# close the undo push group
$img->undo_group_end;
# restore original context
- Context->pop();
+ Gimp::Context->pop();
$img; # return the image, or an empty list, i.e. ()
};
diff --git a/examples/example-net b/examples/example-net
index 29d9c38..7d6b63d 100755
--- a/examples/example-net
+++ b/examples/example-net
@@ -24,13 +24,13 @@ Gimp::on_net {
new Gimp::Display($img);
# do a bunch of operations just as a speed test, flushing in between
- Context->push();
+ Gimp::Context->push();
for $i (0..255) {
- Context->set_background([$i,255-$i,$i]);
+ Gimp::Context->set_background([$i,255-$i,$i]);
$bg->edit_fill(BACKGROUND_FILL);
- Display->displays_flush();
+ Gimp::Display->displays_flush();
}
- Context->pop();
+ Gimp::Context->pop();
# Gimp::Net::server_quit; # kill the gimp-perl-server-extension (ugly name)
};
diff --git a/examples/example-oo b/examples/example-oo
index ea89fa5..595eec4 100755
--- a/examples/example-oo
+++ b/examples/example-oo
@@ -13,21 +13,22 @@ sub plug_in_example_oo {
# object by calling 'new'. This is fairly standard PERL OO magic.
# instead of my $img=gimp_image_new(300,200,RGB)
- my $img=new Image(300,200,RGB);
+ my $img=new Gimp::Image(300,200,RGB);
# instead of my $bg=gimp_layer_new($img, ...)
- my $bg=new Layer($img,300,200,RGB_IMAGE,"Background",100,NORMAL_MODE);
+ my $bg=new Gimp::Layer($img,300,200,RGB_IMAGE,"Background",100,NORMAL_MODE);
# instead of gimp_display_new($img);
new Gimp::Display($img);
-# For any of Image, Drawable, Layer, Palette, Edit, Gradients, Patterns,
-# Progress, Channel, Selection, Display, Plugin, you can use a syntax
-# like Objtype->function, and it will be translated into
-# gimp_objtype_function
+# For any of Gimp::Image, Gimp::Drawable, Gimp::Layer, Gimp::Palette,
+# Gimp::Edit, Gimp::Gradients, Gimp::Patterns, Gimp::Progress,
+# Gimp::Channel, Gimp::Selection, Gimp::Display, Gimp::Plugin, you can
+# use a syntax like Gimp::Objtype->function, and it will be translated
+# into gimp_objtype_function
# instead of gimp_context_set_background() you can use
- Palette->set_background([200,200,100]);
+ Gimp::Palette->set_background([200,200,100]);
# Next, we have 2 examples of using the drawable or image as an object when
# its the first parameter to the PDB call.
@@ -73,4 +74,3 @@ Copyright Marc Lehman.
Distributed under the same terms as Gimp-Perl.
=cut
-
diff --git a/examples/fade-alpha b/examples/fade-alpha
index 9a4e0d9..cbfcc69 100755
--- a/examples/fade-alpha
+++ b/examples/fade-alpha
@@ -814,10 +814,10 @@ sub do_fade
$drawable->add_mask($mask);
}
- Context->push();
+ Gimp::Context->push();
- Context->set_background([0.0,0.0,0.0,1.0]);
- Context->set_foreground([1.0,1.0,1.0,1.0]);
+ Gimp::Context->set_background([0.0,0.0,0.0,1.0]);
+ Gimp::Context->set_foreground([1.0,1.0,1.0,1.0]);
# Direction Map
# 0 3 6
@@ -909,7 +909,7 @@ sub do_fade
$drawable->remove_mask(MASK_APPLY);
}
- Context->pop();
+ Gimp::Context->pop();
$image->undo_group_end;
}
diff --git a/examples/frame_filter b/examples/frame_filter
index 1e4f627..3509adf 100755
--- a/examples/frame_filter
+++ b/examples/frame_filter
@@ -17,7 +17,6 @@ register "layer_apply",
[PF_DRAWABLE, "drawable2", "an optional extra drawable for use by the code"],
],
[],
- ['gimp-1.1'],
sub {
my($image,$_drawable,$function,$d2) = @_;
diff --git a/examples/frame_reshuffle b/examples/frame_reshuffle
index ef9e95a..19b175c 100755
--- a/examples/frame_reshuffle
+++ b/examples/frame_reshuffle
@@ -23,7 +23,6 @@ register "layer_reorder",
[PF_STRING, "custom", "the (optional) custom function to use, e.g. 'n-i' reverses
the order"],
],
[],
- ['gimp-1.1'],
sub {
my($img,$drawable,$function,$custom) = @_;
diff --git a/examples/glowing_steel b/examples/glowing_steel
index d060f1a..75af086 100755
--- a/examples/glowing_steel
+++ b/examples/glowing_steel
@@ -6,16 +6,16 @@ eval 'exec /usr/bin/perl -S $0 ${1+"$@"}'
# A plug-in for GIMP for producing logos and other such nifty things
# which appear to be made of steel and floating over a glowing cloud.
# This plug-in also includes several filters and such for performing the
-# various stages of this logo (e.g. burshed steel, add glow, highlight edges).
+# various stages of this logo (e.g. brushed steel, add glow, highlight edges).
#
# Written in 1999 (c) by Aaron Sherman <ajs ajs com>.
-# This plugin may be distributed under the same terms as The Gimp itself.
-# See http://www.gimp.org/ for more information on The Gimp.
+# This plugin may be distributed under the same terms as Gimp itself.
+# See http://www.gimp.org/ for more information on Gimp.
=head1 LICENSE
Written in 1999 (c) by Aaron Sherman <ajs ajs com>.
-This plugin may be distributed under the same terms as The Gimp itself.
+This plugin may be distributed under the same terms as Gimp itself.
=cut
require 5.004;
@@ -121,12 +121,7 @@ sub perl_fu_add_glow {
my $glow = gimp_layer_new($image, gimp_image_width($image),
gimp_image_height($image), $type, "Glow layer",
100, NORMAL_MODE);
- my $lnum;
- if (!defined($lnum = gimp_layer_get_position($drawable))) {
- # Bug in Gimp::Util?
- warn("add_glow: gimp_layer_get_position failed");
- $lnum = 0;
- }
+ my $lnum = $image->get_item_position($drawable);
gimp_image_insert_layer($image, $glow, 0, $lnum);
# Clear out the new layer
@@ -196,10 +191,7 @@ sub perl_fu_brushed_metal {
gimp_brightness_contrast($templ, 50, 0);
plug_in_noisify($image, $templ, 0, 0.3, 0.3, 0.3, 0);
- if (gimp_version() gt "2.3") # make work for 2.2 or 2.3
- { plug_in_mblur($image, $templ, 0, $length, $angle, 0.0, 0.0, 1); }
- else
- { plug_in_mblur($image, $templ, 0, $length, $angle, 0.0, 0.0); }
+ plug_in_mblur($image, $templ, 0, $length, $angle, 0.0, 0.0);
# Now put it into the target layer
@@ -249,12 +241,7 @@ sub perl_fu_highlight_edges {
gimp_image_select_item($image, CHANNEL_OP_REPLACE, $drawable);
my $white = gimp_layer_copy($drawable,0);
my $black = gimp_layer_copy($drawable,0);
- my $lnum;
- if (!defined($lnum = gimp_layer_get_position($drawable))) {
- # Bug in Gimp::Util?
- warn("highlight_edges: gimp_layer_get_position failed");
- $lnum = 0;
- }
+ my $lnum = $image->get_item_position($drawable);
gimp_image_insert_layer($image, $black, 0, $lnum);
gimp_image_insert_layer($image, $white, 0, $lnum);
@@ -334,7 +321,7 @@ register
"a glowing surface. This effect was inspired by a poster for the ".
"film \"Lost In Space\".",
"Aaron Sherman", "Aaron Sherman (c)", "1999-06-14",
- N_"<Image>/Filters/Render/Logos/Glowing Steel",
+ N_"<Image>/File/Create/Logos/Glowing Steel",
undef,
[
@@ -479,4 +466,3 @@ TBD
L<gimp>, L<perl>, L<Gimp>: the Gimp module for perl.
=cut
-
diff --git a/examples/goldenmean b/examples/goldenmean
index 358985b..db46657 100755
--- a/examples/goldenmean
+++ b/examples/goldenmean
@@ -23,8 +23,9 @@ sub goldenmean {
$layer = gimp_layer_new($img, $width, $height, RGB_IMAGE, "Layer 1", 100, NORMAL_MODE);
gimp_image_insert_layer($layer, 0, -1);
- Context->push();
+ Gimp::Context->push();
$layer->gimp_edit_fill(BACKGROUND_FILL);
+ Gimp::Context->pop();
return $img;
}
@@ -35,7 +36,7 @@ register "golden_mean",
"Claes G Lindblad <claesg\ algonet se>",
"Claes G Lindblad <claesg\ algonet se>",
"990328",
- N_"<Image>/Filters/Render/Golden Mean...",
+ N_"<Image>/File/Create/Golden Mean...",
undef,
[
[PF_INT32, "short", "Shortest side", 233],
diff --git a/examples/gouge b/examples/gouge
index 7e3c2b7..e944f5f 100755
--- a/examples/gouge
+++ b/examples/gouge
@@ -5,8 +5,7 @@
# these are all simple 2x2 kernels, fast but relatively effective
-use Gimp::Feature 'pdl';
-use Gimp 1.098;
+use Gimp;
use Gimp::Fu;
use PDL::LiteF;
diff --git a/examples/guidegrid b/examples/guidegrid
index 953a528..082b91b 100755
--- a/examples/guidegrid
+++ b/examples/guidegrid
@@ -38,7 +38,6 @@ register "guide_grid",
[PF_TOGGLE, "remove_old_guides", "Remove existing guides?", 0],
],
[],
- ['gimp-1.1'],
sub {
my($img,$layer,$xspace, $yspace, $xoffset, $yoffset, $remove_old_guides) = _;
diff --git a/examples/guides_to_selection b/examples/guides_to_selection
index f7b20a9..6f3006c 100755
--- a/examples/guides_to_selection
+++ b/examples/guides_to_selection
@@ -26,10 +26,12 @@ register "guide_to_selection",
[PF_SPINNER, "feather_radius","Radius for feather operation", 1, [0, 1000, 1e0]],
],
[],
- ['gimp-1.1'],
sub {
my($img, $drawable, $operation, $feather, $radius) = @_;
my($W,$H) = ($img->width, $img->height);
+ Gimp::Context->push;
+ Gimp::Context->set_feather($feather);
+ Gimp::Context->set_feather_radius($radius, $radius);
$i = $img->find_next_guide(0);
while ($i) {
@@ -40,13 +42,12 @@ register "guide_to_selection",
} else {
($x,$y,$w,$h) = ($x,0,1,$H);
}
- gimp_context_set_feather($feather);
- gimp_context_set_feather_radius($radius);
$img->select_rectangle($operation,$x,$y,$w,$h);
$operation = CHANNEL_OP_ADD if $operation == CHANNEL_OP_REPLACE;
$i = $img->find_next_guide($i);
}
+ Gimp::Context->pop;
();
};
diff --git a/examples/iland b/examples/iland
index e5f74cc..1b33de7 100755
--- a/examples/iland
+++ b/examples/iland
@@ -11,7 +11,6 @@
#
#
-use Gimp::Feature 'pdl';
use Gimp qw(:auto __ N_);
use Gimp::Fu;
use PDL::LiteF;
diff --git a/examples/image_tile b/examples/image_tile
index 380a45e..06ba9df 100755
--- a/examples/image_tile
+++ b/examples/image_tile
@@ -31,9 +31,7 @@
use Gimp qw(:auto __ N_);
use Gimp::Fu;
use Fcntl qw(O_RDWR O_CREAT O_TRUNC);
-use Gimp::Feature;
-BEGIN { eval "use DB_File";
- $@ and Gimp::Feature::missing('Berkeley DB interface module') }
+use DB_File;
# use strict;
# use vars qw($DO_HSV $debug);
diff --git a/examples/innerbevel b/examples/innerbevel
index e07a5e2..e1c4c2a 100755
--- a/examples/innerbevel
+++ b/examples/innerbevel
@@ -11,13 +11,15 @@
use Gimp qw(:auto __ N_);
use Gimp::Fu;
use Gimp::Util;
+#Gimp::set_trace(TRACE_ALL);
+#$Gimp::verbose = 1;
N_"/Xtns/Render"; N_"/Xtns/Render/Logos"; # i18n workaround
$defaultcolor1 = [124,10,18];
$defaultcolor2 = [200,19,27];
-$path = N_"<Image>/Filters/Render/Logos/Inner Bevel...";
+$path = N_"<Image>/File/Create/Logos";
$shortdesc = "Perform an inner bevel on text";
$longdesc = "This uses tigert's inner bevel method on text, which can be found with his other excellent
tutorials at http://tigert.gimp.org/";
$date = "1999-03-23";
@@ -46,26 +48,15 @@ register $regname, $shortdesc, $longdesc, $authorname, $author, $date, $path, $i
[PF_SLIDER, "depth_shape", "Determines the final shape", 7 , [0,64,32]],
[PF_RADIO, "map", "The type of Map to use(0=Linear,1=Spherical,2=Sinusoidal)", 2, [Linear => 0, Spherical
=> 1, Sinusoidal => 2] ],
],[],
- [
- 'gimp-1.1',
- ], sub {
+ sub {
my ($font, $text, $color1, $color2, $azimuth, $elevation, $depth, $maptype) = @_;
-my $gimpversion = Gimp->version;
-$gimpversion =~ m/^(\d)\.(\d)\.\d/;
-my $gimpmajor = $1;
-my $gimpminor = $2;
-my $api22 = 0; my $api23 = 0;
-
-if ($gimpmajor == 2 && $gimpminor == 2) { $api22 = 1; }
-elsif ($gimpmajor == 2 && $gimpminor >= 3) { $api23 = 1; }
-else {die "Don't know how to handle gimp version $gimpversion with this plugin!\n"};
# -- step 1 --
-Context->push();
+Gimp::Context->push();
-Context->set_background($color1);
-Context->set_foreground($color2);
+Gimp::Context->set_background($color1);
+Gimp::Context->set_foreground($color2);
@dims = gimp20_text_wh($text, $font);
@@ -77,26 +68,23 @@ $img = gimp_image_new($dims[0]+30, $dims[1]+10, RGB);
# -- step 2 --
$img->add_new_layer(0,TRANSPARENT_FILL);
$img->text_fontname(-1, 10, 10, $text, 0, 1, (split / /,$font)[-1], PIXELS, $font);
-gimp_display_new($img); # display the image early
+Gimp::Display->new($img); # display the image early
$layer = $img->merge_visible_layers(EXPAND_AS_NECESSARY);
@pt1 = ($layer->width * 0.5 -1, 0);
@pt2 = ($layer->width * 0.5 +1, $layer->height);
# -- step 3 --
-if ($api22) { $layer->set_preserve_trans(1); }
-elsif ($api23) { $layer->set_lock_alpha(1); }
+$layer->set_lock_alpha(1);
$layer->edit_blend(FG_BG_RGB_MODE, NORMAL_MODE, GRADIENT_LINEAR, 100, 0, REPEAT_NONE, 0, 0, 0, 3, 0.20,
@pt1, @pt2);
# -- step 4 --
$layer2 = $layer->copy(0); # Can you override these to have a default? (would be nice)
$img->insert_layer($layer2, 0, 0);
# -- step 5 --
-if ($api22) { $layer2->set_preserve_trans(1); }
-elsif ($api23) { $layer2->set_lock_alpha(1); }
+$layer2->set_lock_alpha(1);
$img->selection_all;
-Context->set_background([1.0,1.0,1.0]);
+Gimp::Context->set_background([1.0,1.0,1.0]);
$layer2->edit_fill(BACKGROUND_FILL);
# -- step 6 --
-if ($api22) { $layer2->set_preserve_trans(0); }
-elsif ($api23) { $layer2->set_lock_alpha(0); }
+$layer2->set_lock_alpha(0);
$layer2->gauss_rle(6,1,1);
# -- step 7 --
$layer->plug_in_bump_map($layer2, $azimuth, $elevation, $depth, 0,0,0,0,1,0,$maptype);
@@ -110,7 +98,7 @@ $layer2->translate(2, 3);
$img->add_new_layer(2);
$img->gimp_selection_none();
-Context->pop();
+Gimp::Context->pop();
return();
};
diff --git a/examples/layerfuncs b/examples/layerfuncs
index 084e125..75fac9d 100755
--- a/examples/layerfuncs
+++ b/examples/layerfuncs
@@ -15,22 +15,12 @@ use Gimp::Util;
# These are a couple of one-liners that you might find handy. Both should
# be undoable w/o any special magick, and work with any gimp.
-# No reason to register this now - its equivalent in C is present now.
-#
-# register "layer_to_image_size", "Layer2ImageSize", "Expands layer to image size",
-# "Seth Burgess", "Seth Burgess <sjburges\ gimp org>", "1.0",
-# "<None>", "*", [ ], sub {
-# ($img, $layer) = @_;
-# $layer->resize($img->width, $img->height, $layer->offsets);
-# return();
-#};
-
register "center_layer", "Center Layer",
"Centers the current layer on the image",
"Seth Burgess", "Seth Burgess <sjburges\ gimp org>",
"1.0", N_"<Image>/Layer/Center Layer", "*", [], sub {
($img, $layer) = @_;
- $layer->set_offsets(($img->width - $layer->width )/2,
+ $layer->Gimp::Layer::set_offsets(($img->width - $layer->width )/2,
($img->height - $layer->height)/2);
return();
};
@@ -43,4 +33,3 @@ Copyright Seth Burgess.
Distributed under the same terms as Gimp-Perl.
=cut
-
diff --git a/examples/map_to_gradient b/examples/map_to_gradient
index 6fd77ae..489f42f 100755
--- a/examples/map_to_gradient
+++ b/examples/map_to_gradient
@@ -1,7 +1,6 @@
#!/usr/bin/perl
-use Gimp::Feature 'pdl';
-use Gimp 1.1;
+use Gimp;
use Gimp::Fu;
use PDL::LiteF;
diff --git a/examples/mirrorsplit b/examples/mirrorsplit
index 8294576..30a9bba 100755
--- a/examples/mirrorsplit
+++ b/examples/mirrorsplit
@@ -4,64 +4,68 @@ use Gimp qw(:auto __ N_);
use Gimp::Fu;
use Gimp::Util;
use strict;
-# Gimp::set_trace(TRACE_ALL);
+#Gimp::set_trace(TRACE_ALL);
#
# <sjburges gimp org> 2/25/04: changed specifiers to explictly reference
# the GIMP namespace, s/undo_push/undo/, now have to add layer to image in
# order to flip it, or you get a PDB error. So added, flipped, used, then
# removed.
-register "mirror_split",
- "Splits and mirrors half of the image, according to settings.",
- "Just tick appropriate radio button.",
- "Claes G Lindblad <claesg\ algonet se>",
- "Claes G Lindblad <claesg\ algonet se>",
- "990530",
- N_"<Image>/Filters/Distorts/MirrorSplit...",
- "*",
- [
- [PF_RADIO, "mirror", "Which half to mirror (0=U,1=D,2=L,3=R)", 0,
- [Upper => 0, Lower => 1, Left => 2, Right => 3]
- ]
- ],
- sub {
- my ($img, $layer, $mirror) = @_;
+register
+ "mirror_split",
+ "Splits and mirrors half of the image, according to settings.",
+ "Just tick appropriate radio button.",
+ "Claes G Lindblad <claesg\ algonet se>",
+ "Claes G Lindblad <claesg\ algonet se>",
+ "990530",
+ N_"<Image>/Filters/Distorts/MirrorSplit...",
+ "*",
+ [
+ [PF_RADIO, "mirror", "Which half to mirror (0=U,1=D,2=L,3=R)", 0,
+ [Upper => 0, Lower => 1, Left => 2, Right => 3]
+ ]
+ ],
+sub {
+ my ($img, $layer, $mirror) = @_;
- my $w = $layer->width();
- my $h = $layer->height();
- my $wspan = int ($w / 2 + 0.5);
- my $hspan = int ($h / 2 + 0.5);
+ my $w = $layer->width();
+ my $h = $layer->height();
+ my $wspan = int ($w / 2 + 0.5);
+ my $hspan = int ($h / 2 + 0.5);
- eval { $img->undo_group_start };
+ eval { $img->undo_group_start };
- my $temp1 = gimp_layer_copy($layer, 1);
- $img->insert_layer($temp1,0,-1);
- if ($mirror == 0) { # upper half
- $temp1 = $temp1->transform_flip_simple(&Gimp::ORIENTATION_VERTICAL, 1, 0.0, 1);
- gimp_image_select_rectangle(&Gimp::CHANNEL_OP_REPLACE, $img, 0, $hspan, $w, $h -
$hspan);
- };
- if ($mirror == 1) { # lower half
- $temp1 = $temp1->transform_flip_simple(&Gimp::ORIENTATION_VERTICAL, 1, 0.0, 1);
- gimp_image_select_rectangle(&Gimp::CHANNEL_OP_REPLACE, $img, 0, 0, $w, $hspan);
- };
- if ($mirror == 2) { # left half
- $temp1 = $temp1->transform_flip_simple(&Gimp::ORIENTATION_HORIZONTAL, 1, 0.0, 1);
- gimp_image_select_rectangle(&Gimp::CHANNEL_OP_REPLACE, $img, $wspan, 0, $w - $wspan,
$h);
- };
- if ($mirror == 3) { # right half
- $temp1 = $temp1->transform_flip_simple(&Gimp::ORIENTATION_HORIZONTAL, 1, 0.0, 1);
- gimp_image_select_rectangle(&Gimp::CHANNEL_OP_REPLACE, $img, 0, 0, $wspan, $h);
- };
+ my $temp1 = gimp_layer_copy($layer, 1);
+ $img->insert_layer($temp1,0,-1);
+ my $orientation = ($mirror < 2)
+ ? &Gimp::ORIENTATION_VERTICAL
+ : &Gimp::ORIENTATION_HORIZONTAL;
+ $temp1 = $temp1->transform_flip_simple($orientation, 1, 0.0, 1);
+ my @xywh;
+ if ($mirror == 0) {
+ # upper half
+ @xywh = (0, $hspan, $w, $h - $hspan);
+ } elsif ($mirror == 1) {
+ # lower half
+ @xywh = (0, 0, $w, $hspan);
+ } elsif ($mirror == 2) {
+ # left half
+ @xywh = ($wspan, 0, $w - $wspan, $h);
+ } elsif ($mirror == 3) {
+ # right half
+ @xywh = (0, 0, $wspan, $h);
+ };
+ $img->select_rectangle(&Gimp::CHANNEL_OP_REPLACE, @xywh);
- gimp_edit_copy($temp1);
- my $temp2 = gimp_edit_paste($layer, 1);
- gimp_floating_sel_anchor($temp2);
- $img->remove_layer($temp1);
- gimp_selection_none($img);
+ gimp_edit_copy($temp1);
+ my $temp2 = gimp_edit_paste($layer, 1);
+ gimp_floating_sel_anchor($temp2);
+ $img->remove_layer($temp1);
+ gimp_selection_none($img);
- eval { $img->undo_group_end };
- return $img;
- };
+ eval { $img->undo_group_end };
+ return $img;
+};
exit main;
=head1 LICENSE
diff --git a/examples/pixelmap b/examples/pixelmap
index 8fcadaa..667c5f5 100755
--- a/examples/pixelmap
+++ b/examples/pixelmap
@@ -1,7 +1,6 @@
#!/usr/bin/perl
-use Gimp::Feature 'pdl';
-use Gimp 1.099;
+use Gimp;
use Gimp::Fu;
use Gimp::Util;
use PDL;
@@ -70,7 +69,7 @@ register "pixelgen",
"Marc Lehmann",
"Marc Lehmann <pcg\ goof com>",
"19991115",
- N_"<Image>/Filters/Render/Pixelgenerator...",
+ N_"<Image>/File/Create/Logos/Pixelgenerator...",
undef,
[
[PF_SPINNER, "width" , "The width of the new image to generate", 512, [1,
4096, 1]],
diff --git a/examples/prep4gif b/examples/prep4gif
index 29509c6..55f83b7 100755
--- a/examples/prep4gif
+++ b/examples/prep4gif
@@ -44,7 +44,7 @@ sub prep {
}
# Show the image early - this makes debugging a breeze
- my $newdisplay = gimp_display_new($out);
+ my $newdisplay = Gimp::Display->new($out);
# Hide the bottom layer, so it doesn't get into the merge visible later.
@@ -88,7 +88,7 @@ sub prep {
}
# Show all the changes.
- gimp_displays_flush();
+ Gimp->displays_flush();
();
}
diff --git a/examples/randomart1 b/examples/randomart1
index 387b4d5..b114ffc 100755
--- a/examples/randomart1
+++ b/examples/randomart1
@@ -20,7 +20,7 @@ register "random_art_1", # Funktionsname
"Marc Lehmann", # Autor
"Marc Lehmann <pcg\ goof com", # Copyright
"0.4", # Version/Datum
- N_"<Image>/Filters/Render/Random Art #1...", # Men�pfad
+ N_"<Image>/File/Create/Logos/Random Art #1...", # Men�pfad
"", # Bildtypen
# Eingabeparameter
# Typ Name Beschreibung Wert
@@ -37,7 +37,7 @@ register "random_art_1", # Funktionsname
sub { # Perl-Code
# Die Parameter werden ganz "normal" �bergeben:
my ($w,$h,$num_poly,$edges,$revolutions,$feather,$super)= _;
- Context->push();
+ Gimp::Context->push();
# Erzeuge ein neues Bild
my $image = new Gimp::Image($w,$h,RGB);
@@ -51,7 +51,7 @@ register "random_art_1", # Funktionsname
$image->insert_layer($layer,0,0);
# Setze die Hintergrundfarben
- Context->set_background('white');
+ Gimp::Context->set_background('white');
# ...und l�sche die Ebene damit
$layer->fill(BACKGROUND_FILL);
@@ -71,12 +71,12 @@ register "random_art_1", # Funktionsname
}
# Selektiere die Region
- gimp_context_set_feather($feather);
+ Gimp::Context->set_feather($feather);
$image->select_polygon(CHANNEL_OP_REPLACE, \ ecken);
# W�hle zuf�llig zwei Farben aus
- Context->set_foreground([rand(256)/256.0,rand(256)/256.0,rand(256)/256.0]);
- Context->set_background([rand(256)/256.0,rand(256)/256.0,rand(256)/256.0]);
+ Gimp::Context->set_foreground([rand(256)/256.0,rand(256)/256.0,rand(256)/256.0]);
+ Gimp::Context->set_background([rand(256)/256.0,rand(256)/256.0,rand(256)/256.0]);
# Und erzeuge einen Farbverlauf �ber das Bild
$layer->edit_blend (FG_BG_HSV_MODE,
@@ -99,7 +99,7 @@ register "random_art_1", # Funktionsname
$layer->offset (1,0,(rand(0.8)+0.1)*$w,(rand(0.8)+0.1)*$h);
}
- Context->pop();
+ Gimp::Context->pop();
$image->selection_none;
$image->undo_enable;
diff --git a/examples/randomblends b/examples/randomblends
index d4a519f..887430c 100755
--- a/examples/randomblends
+++ b/examples/randomblends
@@ -27,11 +27,10 @@ register "random_blends",
[PF_SPINNER, "number", "How many gradients to apply", 7, [1,255,1]],
],
[],
- ['gimp-1.1'],
sub {
my($img,$layer,$numgradients) = _;
eval { $img->undo_group_start };
- Context->push();
+ Gimp::Context->push();
my $sel;
($sel,$x1,$y1,$x2,$y2) = $img->gimp_selection_bounds;
srand();
@@ -40,7 +39,7 @@ register "random_blends",
Gimp->progress_init("Random blends...");
for ($i=0; $i<$numgradients; $i++) {
- Context->set_gradient(@gradientlist[randint($#gradientlist)]);
+ Gimp::Context->set_gradient(@gradientlist[randint($#gradientlist)]);
$layer->edit_blend(CUSTOM_MODE,
DIFFERENCE_MODE,
randint(10), # gradient type
@@ -60,7 +59,7 @@ register "random_blends",
Gimp->progress_update($i/(1.0*$numgradients));
}
eval { $img->undo_group_end };
- Context->pop();
+ Gimp::Context->pop();
return();
};
exit main;
diff --git a/examples/redeye b/examples/redeye
index 1a567ad..ffff803 100755
--- a/examples/redeye
+++ b/examples/redeye
@@ -1,7 +1,6 @@
#!/usr/bin/perl -w
-use Gimp::Feature 'pdl';
-use Gimp 2.0;
+use Gimp;
use Gimp ":auto";
use Gimp::Fu;
use PDL::LiteF;
diff --git a/examples/repdup b/examples/repdup
index ca33a60..518cd2b 100755
--- a/examples/repdup
+++ b/examples/repdup
@@ -36,7 +36,7 @@ register "repdup",
for ($i = 0; $i < $repeats; $i++) {
$b[1] = $b[1] + $xoffset;
$b[2] = $b[2] + $yoffset;
- gimp_image_select_rectangle(CHANNEL_OP_REPLACE, $img, $b[1], $b[2], $w, $h);
+ $img->select_rectangle(CHANNEL_OP_REPLACE, $b[1], $b[2], $w, $h);
$bit_bucket = gimp_edit_paste($layer, 0);
gimp_floating_sel_anchor($bit_bucket);
gimp_selection_none($img);
diff --git a/examples/scratches b/examples/scratches
index ed57c0e..cc67f25 100755
--- a/examples/scratches
+++ b/examples/scratches
@@ -16,7 +16,7 @@ sub new_scratchlayer {
$layer->insert_layer(0, -1);
$layer->fill (WHITE_FILL);
$layer->noisify (0, 1, 1, 1, 0);
- $layer->mblur (0, $length, $angle, 0, 0, 0);
+ $layer->mblur (0, $length, $angle, 0, 0);
$layer->levels (HISTOGRAM_VALUE, 120, 255, 0.3, 0, 255);
$layer;
@@ -38,7 +38,6 @@ register "scratches",
[PF_SPINNER , "length" , "The scratch length" , 10, [ 0, 400]],
],
[],
- ['gimp-1.1'],
sub {
my ($image,$drawable,$anglex,$angley,$gamma,$length,$width) = @_;
@@ -50,7 +49,7 @@ register "scratches",
my $layer2 = new_scratchlayer ($image, $drawable, $length, $gamma, $angley);
# Verschmiere das Bild.
- $drawable->displace ($width, $width, 1, 1, $layer1, $layer2, WRAP);
+ $drawable->displace ($width, $width, 1, 1, $layer1, $layer2, 1);
# die beiden Ebenen werden nicht länger benötigt.
$layer1->remove_layer;
diff --git a/examples/selective_sharpen b/examples/selective_sharpen
index d9685c2..4fe4ffd 100755
--- a/examples/selective_sharpen
+++ b/examples/selective_sharpen
@@ -32,14 +32,14 @@ sub my_code {
$img->selection_none;
# 1) take the original photo, duplicate the layer
- $edge_layer = $original_layer->copy(1);
+ $edge_layer = $original_layer->Gimp::Layer::copy(1);
$img->insert_layer($edge_layer,0,-1);
# 2) convert the copy to grayscale
$edge_layer->desaturate;
# 3) run edge detect to the gray layer (default works)
- $edge_layer->edge(2.0, BLACK, SOBEL);
+ $edge_layer->edge(2.0, 3, 0);
# 4) blur it slightly
$edge_layer->gauss_iir2(3.0, 3.0);
diff --git a/examples/sethspin b/examples/sethspin
index 5a865e2..3906b49 100755
--- a/examples/sethspin
+++ b/examples/sethspin
@@ -3,12 +3,12 @@
eval 'exec /usr/bin/perl -S $0 ${1+"$@"}'
if 0; # not running under some shell
-#
+use constant { PI => 3.14159 };
+
# Note: Seth has transferred the maintainer `position' to me, so bother me
# instead of him now :-)
# - Steinar H. Gunderson <sgunderson bigfoot com>
-
# This one's all mine. Well, its GPL/Artistic but I'm the author and creator.
# You need gimp 1.1 or better for this; too much has changed, and I don't think
# 1.0.x had a perspective PDB function anyway
@@ -64,14 +64,14 @@ use Gimp::Util;
sub saw { # a sawtooth function on PI
($val) = @_;
- if ($val < 3.14159/2.0) {
- return ($val/3.14159);
- } elsif ($val < 3.14159) {
- return (-1+$val/3.14159);
- } elsif ($val < 3.14159+3.14159/2.0) {
- return ($val/3.14159);
+ if ($val < PI/2.0) {
+ return ($val/PI);
+ } elsif ($val < PI) {
+ return (-1+$val/PI);
+ } elsif ($val < PI*1.5) {
+ return ($val/PI);
} else {
- return (-1+$val/3.14159);
+ return (-1+$val/PI);
}
}
@@ -83,13 +83,13 @@ sub spin_layer { # the function for actually spinning the layer
$frameno); # The current frame
# Now let's spin it!
- $stepsize = 3.14159/$numframes; # in radians
+ $stepsize = PI/$numframes; # in radians
$frameno = 0;
- for ($i=0; $i<=3.14159; $i+=$stepsize) {
- Gimp->progress_update ($i/3.14159);
+ for ($i=0; $i<=PI; $i+=$stepsize) {
+ Gimp->progress_update ($i/PI);
# create a new layer for spinning
- $framelay = ($i < 3.14159/2.0) ? $spin->copy(1) : $dest->copy(1);
+ $framelay = ($i < PI/2.0) ? $spin->copy(1) : $dest->copy(1);
$img->insert_layer($framelay, 0, 0);
$floater = $framelay->copy(1);
$img->insert_layer($floater, 0, 0);
@@ -108,7 +108,8 @@ sub spin_layer { # the function for actually spinning the layer
# height must be != 0
$y3++ if ($y1 == $y3);
- $floater = $floater->transform_perspective(
+ # the drawable version (deprecated) has different params
+ $floater = $floater->Gimp::Item::transform_perspective(
$x[1]+saw($i)*$prp*$framelay->width,$y1,
$x[3]-saw($i)*$prp*$framelay->width,$y1,
$x[1]-saw($i)*$prp*$framelay->width,$y3,
@@ -134,7 +135,6 @@ register "seth_spin",
N_"<Image>/Filters/Animation/Seth Spin...",
"*",
[
- [PF_DRAWABLE, "source", "What drawable to spin from?"],
[PF_DRAWABLE, "destination","What drawable to spin to?"],
[PF_INT8, "frames", "How many frames to use?", 16],
[PF_COLOR, "background", "What color to use for background if not transparent", [0,0,0]],
@@ -143,14 +143,13 @@ register "seth_spin",
[PF_TOGGLE, "convert_indexed", "Convert to indexed?", 1],
],
[],
- ['gimp-1.1'],
sub {
- my($src,$dest,$frames,$color,$perspective,$spinback,$indexed) = @_;
+ my($startimage,$src,$dest,$frames,$color,$perspective,$spinback,$indexed) = @_;
- $oldbackground = Gimp->context_get_background();
- Gimp->context_set_background($color);
+ Gimp::Context->push;
+ Gimp::Context->set_background($color);
- $perspective = $perspective/255.0; # PF_SLIDER doesn't work right for < 1
+ $perspective /= 255.0; # PF_SLIDER doesn't work right for < 1
Gimp->progress_init(__"Seth Spin...");
@@ -186,10 +185,7 @@ register "seth_spin",
spin_layer($img, $spinlayer, $destlayer, $spinback ? $frames/2 : $frames, $perspective);
# go back from destination to spinlayer if spinning back
- if ($spinback) {
-# @layerlist = $img->get_layers();
- spin_layer($img, $destlayer, $spinlayer, $frames/2, $perspective);
- }
+ spin_layer($img, $destlayer, $spinlayer, $frames/2, $perspective) if $spinback;
# remove the original 2 pasted layers
$img->remove_layer($destlayer);
@@ -200,17 +196,12 @@ register "seth_spin",
@all_layers = $img->get_layers;
$img->set_visible(@all_layers);
- if ($spinback) {
- $all_layers[$frames/2-1]->set_name(__"Spin Layer DEST (250ms)");
- }
+ $all_layers[$frames/2-1]->set_name(__"Spin Layer DEST (250ms)") if $spinback;
$all_layers[$frames-1]->set_name(__"Spin Layer SRC (250ms)");
- # indexed conversion wants a display for some reason
- if ($indexed) {
- $img->convert_indexed(1,MAKE_PALETTE,255,0,1,"buffy" );
- }
+ $img->convert_indexed(1,MAKE_PALETTE,255,0,1,"buffy" ) if $indexed;
- Gimp->context_set_background($oldbackground);
+ Gimp::Context->pop;
return();
};
diff --git a/examples/stamps b/examples/stamps
index 99f3649..08318b2 100755
--- a/examples/stamps
+++ b/examples/stamps
@@ -47,7 +47,7 @@ register "stamps",
"Claes G Lindblad <claesg\ algonet se>",
"Claes G Lindblad <claesg\ algonet se>",
"990314",
- N_"<Image>/Filters/Render/Stamps...",
+ N_"<Image>/File/Create/Logos/Stamps...",
undef,
[
[PF_INT32, "size", "img size", 90],
diff --git a/examples/translogo b/examples/translogo
index cc15c81..1fcef01 100755
--- a/examples/translogo
+++ b/examples/translogo
@@ -10,7 +10,7 @@ use Gimp::Util;
sub my_code {
my ($image, $drawable, $rad_tog, $pattern, $txt_col) = @_;
- Context->push();
+ Gimp::Context->push();
$drawable->has_alpha or die __"You can't run this script without an ALPHA CHANNEL!!";
my $test = 0;
$test = $drawable->type_with_alpha;
@@ -31,7 +31,7 @@ sub my_code {
$img->resize($drawable->width,$drawable->height, 0, 0);
gimp_image_select_item($img, CHANNEL_OP_REPLACE, $layer);
gimp_selection_invert ($img);
- Context->set_background ([255, 255, 255]);
+ Gimp::Context->set_background ([255, 255, 255]);
gimp_edit_fill ($layer, BACKGROUND_FILL);
gimp_selection_none ($img);
gimp_invert ($layer);
@@ -41,10 +41,10 @@ sub my_code {
$bump_lay->drawable_fill(BACKGROUND_FILL);
$img->insert_layer($bump_lay,0,0);
if ($rad_tog == 1) {
- Context->set_pattern ($pattern);
+ Gimp::Context->set_pattern ($pattern);
gimp_edit_bucket_fill ($bump_lay, PATTERN_BUCKET_FILL, NORMAL_MODE, 100, 0, 0, 0, 0);
} else {
- Context->set_background ($txt_col);
+ Gimp::Context->set_background ($txt_col);
gimp_edit_fill ($bump_lay, BACKGROUND_FILL);
}
plug_in_bump_map ($img, $bump_lay, $layer, 110.0, 45.0, 4, 0, 0, 0, 0, 1, 0, 0);
diff --git a/examples/view3d b/examples/view3d
index 1cdc266..7ea1a47 100755
--- a/examples/view3d
+++ b/examples/view3d
@@ -1,10 +1,9 @@
#!/usr/bin/perl
-use Gimp::Feature qw(pdl);
-use PDL;
-BEGIN { eval "use PDL::Graphics::TriD"; $@ and Gimp::Feature::missing('PDL TriD (OpenGL) support') }
use Gimp;
use Gimp::Fu;
+use PDL;
+use PDL::Graphics::TriD;
register
'view3d',
diff --git a/examples/warp-sharp b/examples/warp-sharp
index 39f4a45..2bcccdc 100755
--- a/examples/warp-sharp
+++ b/examples/warp-sharp
@@ -89,7 +89,6 @@ register
[PF_SLIDER, "intensity", "Displace Intensity", 2.5, [0.1, 10, 0.1]]
],
[],
- ['gimp-1.1'],
\&warp_sharp;
diff --git a/examples/webify b/examples/webify
index 604d751..c37fac6 100755
--- a/examples/webify
+++ b/examples/webify
@@ -26,6 +26,7 @@ register "webify",
],
sub {
my($img,$drawable,$new,$alpha,$bg,$thresh,$colours,$autocrop)= _;
+ $thresh /= 255;
$img = $img->duplicate if $new;
@@ -35,11 +36,11 @@ register "webify",
if ($alpha) {
$drawable->add_alpha;
- gimp_context_set_sample_threshold($thresh);
+ Gimp::Context->set_sample_threshold($thresh);
$img->select_color(CHANNEL_OP_REPLACE,$drawable,$bg);
$drawable->edit_cut if $img->selection_bounds;
}
- Plugin->autocrop($drawable) if $autocrop;
+ Gimp::Plugin->autocrop($drawable) if $autocrop;
$img->convert_indexed (2, 0, $colours, 0, 0, '') if $colours;
eval { $img->undo_group_end };
diff --git a/examples/windify b/examples/windify
index 364700b..9199ccc 100755
--- a/examples/windify
+++ b/examples/windify
@@ -5,8 +5,7 @@ eval 'exec /usr/bin/perl -S $0 ${1+"$@"}'
# sent to me by Seth Burgess <sjburges gimp org>
# small changes my Marc Lehmann <pcg goof com>
-# 2014/03/17 ported to GIMP 2.8.10 by Ed J - ported to Scheme (see end
-# for Scheme script), changes back-ported to perl but not tested
+# 2014/03/17 ported to GIMP 2.8.10 by Ed J:
# - I think the fill with the foreground colour should be background
# since that's the colour expressly set, but didn't touch
# - adjusted the maths so inputs are in degrees
@@ -25,7 +24,6 @@ sub windify {
my $ysize = gimp_drawable_height($drawable);
my $out = gimp_image_new($xsize,$ysize,0);
- #gimp_display_new($out); # if do this, image_delete will fail
gimp_context_set_background([128,128,128]);
my $windlayer = gimp_layer_new($out,$xsize,$ysize,RGB_IMAGE,"Windlayer",100,NORMAL_MODE);
gimp_drawable_fill($windlayer, 0);
@@ -57,7 +55,6 @@ sub windify {
$distance*$ymult,
1,1, $newlay,$newlay, $wrap);
gimp_drawable_offset($drawable,1,0,$distance*$xmult,-$distance*$ymult);
- gimp_image_remove_layer($out,$newlay);
gimp_image_delete ($out);
gimp_displays_flush();
gimp_context_pop();
@@ -90,58 +87,3 @@ Copyright Seth Burgess.
Distributed under the same terms as Gimp-Perl.
=cut
-
-__END__
-; scheme version of above
-(define (script-fu-windify img drawable angle density distance wrap)
- (let* (
- (xsize (car (gimp-drawable-width drawable)))
- (ysize (car (gimp-drawable-height drawable)))
- (out 0)
- (windlayer 0)
- (windlayercopy 0)
- (scaledensity (/ density 255))
- (newlay 0)
- (xmult (cos (* (/ angle 180) 3.14159)))
- (ymult (sin (* (/ angle 180) 3.14159)))
- )
- (gimp-context-push)
- (set! out (car (gimp-image-new xsize ysize RGB)))
-; (gimp-display-new out)
- (gimp-context-set-background '(128 128 128))
- (set! windlayer (car (gimp-layer-new out xsize ysize RGB-IMAGE '"Windlayer" 100 NORMAL-MODE)))
- (gimp-drawable-fill windlayer 0)
- (gimp-image-add-layer out windlayer 0)
- (set! windlayercopy (car (gimp-layer-copy windlayer 1)))
- (gimp-image-add-layer out windlayercopy 0)
- (plug-in-noisify 1 out windlayercopy 0 scaledensity scaledensity scaledensity 1)
- (plug-in-mblur 1 out windlayercopy 0 15 angle (/ xsize 2) (/ ysize 2))
- (gimp-layer-set-mode windlayercopy 10) ; Lighten Only
- (gimp-image-merge-visible-layers out 0)
- (set! newlay (car (gimp-image-get-active-layer out)))
- (plug-in-displace 1 img drawable (* distance xmult) (* distance ymult) 1 1 newlay newlay wrap)
- (gimp-drawable-offset drawable 1 0 (* distance xmult) (* -1 distance ymult))
- (gimp-image-remove-layer out newlay)
- (gimp-image-delete out)
-;(gimp-message (number->string xsize))
- (gimp-displays-flush)
- (gimp-context-pop)
- )
-)
-
-(script-fu-register "script-fu-windify"
- "Windify (GP)..."
- "Add wind to an image"
- "Seth Burgess"
- "Seth Burgess <sjburges gimp org>"
- "1998-09-14"
- ""
- SF-IMAGE "Image" 0
- SF-DRAWABLE "Drawable" 0
- SF-ADJUSTMENT "Wind Angle in degrees, 0 is right, increases anticlockwise" '(120 1 1000 1 10 0 1)
- SF-ADJUSTMENT "How Much Is Blown" '(80 1 1000 1 10 0 1)
- SF-ADJUSTMENT "How Far It's Blown" '(30 1 1000 1 10 0 1)
- SF-TOGGLE "Smear on Edges (or Wrap)" TRUE
-)
-
-(script-fu-menu-register "script-fu-windify" "<Image>/Filters")
diff --git a/examples/xachlego b/examples/xachlego
index 568b316..4a67843 100755
--- a/examples/xachlego
+++ b/examples/xachlego
@@ -58,7 +58,7 @@ register "xach_blocks",
$img->selection_all;
$selection_flag = 1;
}
- Context->push();
+ Gimp::Context->push();
# Now the fun begins :)
$selection = $img->selection_save;
@@ -108,7 +108,7 @@ register "xach_blocks",
if ($selection_flag ==1) {
$img->selection_none;
}
- Context->pop();
+ Gimp::Context->pop();
eval { $img->undo_group_end };
return ();
};
diff --git a/examples/xachshadow b/examples/xachshadow
index f0fa753..0f88468 100755
--- a/examples/xachshadow
+++ b/examples/xachshadow
@@ -41,13 +41,13 @@ register "xach_shadows",
my($img,$drawable,$blocksize) = _;
eval { $img->undo_group_start };
- Context->push();
+ Gimp::Context->push();
# $selection_flag = 0;
if (!$drawable->has_alpha) {
$drawable->add_alpha;
};
- Context->set_foreground('white');
- Context->set_background('black');
+ Gimp::Context->set_foreground('white');
+ Gimp::Context->set_background('black');
# This only can be applied to an entire image right now..
# $selection = $img->selection_save;
$img->selection_all;
@@ -61,7 +61,7 @@ register "xach_shadows",
$frontlayer = $shadowlayer->layer_copy(0);
$img->insert_layer($frontlayer,0,0);
- Context->set_background([0,0,0]);
+ Gimp::Context->set_background([0,0,0]);
$shadowlayer->fill(BACKGROUND_FILL);
$checkmask->plug_in_gauss_iir(0.3*$blocksize, 1, 1);
$checkmask->offset (1, 0, 0.2*$blocksize, 0.2*$blocksize);
@@ -71,13 +71,13 @@ register "xach_shadows",
$img->insert_layer($gridlayer,0,0);
$img->selection_all;
gimp_edit_clear($gridlayer);
- Context->set_background([255,255,255]);
+ Gimp::Context->set_background([255,255,255]);
gimp_edit_fill($gridlayer, BACKGROUND_FILL);
$gridlayer->plug_in_grid((1, $blocksize, 0, [0,0,0], 255) x 3);
gimp_layer_set_mode($gridlayer, 3);
# Clean up stuff
- Context->pop();
+ Gimp::Context->pop();
$img->selection_none;
eval { $img->undo_group_end };
gimp_displays_flush();
diff --git a/examples/xachvision b/examples/xachvision
index aff53b0..1fdb7fb 100755
--- a/examples/xachvision
+++ b/examples/xachvision
@@ -22,7 +22,7 @@ register "xachvision",
my($img,$drawable,$color,$amt) = _;
eval { $img->undo_group_start };
- Context->push();
+ Gimp::Context->push();
$midlayer = $drawable->gimp_layer_copy(1);
$img->insert_layer($midlayer, 0, 0);
@@ -30,11 +30,11 @@ register "xachvision",
$toplayer = $drawable->gimp_layer_copy(1);
$img->insert_layer($toplayer, 0, 0);
- Context->set_background($color);
+ Gimp::Context->set_background($color);
$toplayer->edit_fill(BACKGROUND_FILL);
$toplayer->set_mode(COLOR_MODE);
- Context->set_background([0,0,0]);
+ Gimp::Context->set_background([0,0,0]);
$drawable->edit_fill(BACKGROUND_FILL);
$amt = $amt/255;
@@ -46,7 +46,7 @@ register "xachvision",
0,0,0,[0,0,0],255 );
$midmask->plug_in_gauss_iir(1.01, 1, 1);
- Context->pop();
+ Gimp::Context->pop();
eval { $img->undo_group_end };
gimp_displays_flush();
return();
diff --git a/examples/yinyang b/examples/yinyang
index 99f009e..99aa774 100755
--- a/examples/yinyang
+++ b/examples/yinyang
@@ -113,7 +113,7 @@ register("yinyang",
"Aaron Sherman",
"(c) 1998, Aaron Sherman",
"1999b",
- N_"<Image>/Filters/Render/Yin-Yang...",
+ N_"<Image>/File/Create/Logos/Yin-Yang...",
undef,
[
[PF_INT32, "width", "Width", 256],
diff --git a/po/Makefile.PL b/po/Makefile.PL
index cc11e5a..2212316 100644
--- a/po/Makefile.PL
+++ b/po/Makefile.PL
@@ -1,6 +1,6 @@
use ExtUtils::MakeMaker;
-do '../config.pl';
+require '../config.pl';
print "Portable message objects...";
if ($MSGFMT =~ /./ && $MSGFMT ne "no") {
diff --git a/t/gimpsetup.pl b/t/gimpsetup.pl
index cc0e72b..9ae2be1 100644
--- a/t/gimpsetup.pl
+++ b/t/gimpsetup.pl
@@ -14,7 +14,7 @@ use IO::All;
our $DEBUG = 0 unless defined $DEBUG;
our %cfg;
-require './config.pl';
+require 'config.pl';
my $sysplugins = $cfg{gimpplugindir} . '/plug-ins';
die "plugins dir: $!" unless -d $sysplugins;
@@ -26,9 +26,7 @@ our $blibplugins = "blib/plugins";
die "mkdir $myplugins: $!\n" unless mkdir $myplugins;
my $s = io("$blibplugins/Perl-Server")->all or die "unable to read the Perl-Server: $!";
write_plugin($DEBUG, 'Perl-Server', $s);
-map {
- die "symlink $_: $!" unless symlink("$sysplugins/$_", "$myplugins/$_");
-} qw(script-fu sharpen);
+map { symlink_sysplugin($_) } qw(script-fu sharpen);
map { die "mkdir $dir/$_: $!" unless mkdir "$dir/$_"; }
qw(palettes gradients patterns brushes dynamics);
my %files = (
@@ -42,6 +40,12 @@ $ENV{GIMP2_DIRECTORY} = $dir;
ok(1, 'gimp set up');
+sub symlink_sysplugin {
+ local $_ = shift;
+ s#.*/##;
+ die "symlink $_: $!" unless symlink "$sysplugins/$_", "$myplugins/$_";
+}
+
sub make_executable {
my $file = shift;
my $newfile = "$file.pl";
diff --git a/t/supplied.t b/t/supplied.t
new file mode 100644
index 0000000..0916762
--- /dev/null
+++ b/t/supplied.t
@@ -0,0 +1,140 @@
+use strict;
+use Test::More;
+our ($dir, $DEBUG);
+BEGIN {
+# $Gimp::verbose = 1;
+ $DEBUG = 0;
+ require 't/gimpsetup.pl';
+ # most minimal and elegant would be to symlink sandbox gimp-dir's
+ # plug-ins to our blib/plugins dir, but not portable to windows
+ my $blibdir = 'blib/plugins';
+ my @plugins = grep { !/Perl-Server/ } glob "$blibdir/*";
+ map {
+ warn "inst $_\n" if $Gimp::verbose;
+ write_plugin($DEBUG, $_, io($_)->all);
+ } @plugins;
+ map { symlink_sysplugin($_) }
+ qw(
+ noise-rgb noise-solid blur-gauss grid pixelize blur-motion displace
+ bump-map checkerboard edge file-png unsharp-mask crop-auto
+ );
+}
+use Gimp qw(:auto), "net_init=spawn/";
+#Gimp::set_trace(TRACE_ALL);
+
+sub newimage {
+ my $numlayers = shift;
+ my $i = Gimp::Image->new(200,200,RGB);
+ for my $layernum (1..$numlayers) {
+ my $l0 = $i->layer_new(200,200,RGBA_IMAGE,"layer $layernum",100,VALUE_MODE);
+ $i->insert_layer($l0,0,0);
+ }
+ $i;
+}
+
+use constant {
+ REQ_NONE => 0,
+ REQ_ALPHA => 1 << 0,
+ REQ_SEL => 1 << 1,
+ REQ_GUIDE => 1 << 2,
+ REQ_DIR => 1 << 3,
+ REQ_LAYER => 1 << 4,
+};
+
+my $color1 = [0,0,1.0];
+my $color2 = [0.4,0,1.0];
+my $black = [0,0,0];
+my $white = [1,1,1];
+my $gradient1 = "Burning Paper";
+my $width = 10;
+my $height = 10;
+
+my @testbench = (
+["add_glow" , 2, REQ_ALPHA, [$color1, 5] ],
+["animate_cells" , 3, REQ_ALPHA, [0] ],
+["auto_red_eye" , 1, REQ_NONE , [] ],
+["blowinout" , 1, REQ_NONE , [ 30, 8, "30", 0, 0] ],
+["blur_2x2" , 1, REQ_NONE , [] ],
+["brushed_metal" , 1, REQ_NONE , [40,120,1,$gradient1] ],
+["burst" , 1, REQ_NONE , [0,0,14,30,50,80,140] ],
+["center_guide" , 1, REQ_NONE , [0] ],
+["center_layer" , 2, REQ_ALPHA, [] ],
+["contrast_enhance_2x2" , 1, REQ_NONE , [] ],
+["do_bricks" , 0, REQ_NONE , ["Leather","unused yet","",[0.5,0.5,0.5],1,8,16,256,256,0] ],
+["dots" , 1, REQ_NONE , [8,$color1,80,20,16,0,0] ],
+["dust" , 1, REQ_NONE , [0.0005,0,50] ],
+["edge_detect_2x2" , 1, REQ_NONE , [] ],
+["glowing_steel" , 0, REQ_NONE , ["GET LOST","Bitstream Charter Bold 72",100,$color1,$black,4,0,0]
],
+["golden_mean" , 0, REQ_NONE , [233, 0] ],
+["guide_grid" , 1, REQ_NONE , [24,14,0,0,0] ],
+["guide_to_selection" , 1, REQ_GUIDE, [CHANNEL_OP_REPLACE,0,0] ],
+["highlight_edges" , 1, REQ_ALPHA, [ 10] ],
+["inner_bevel" , 0, REQ_NONE , ["URW Bookman L, Bold 80","INNERBEVEL",$color1,$color2,132,30,7,2]
],
+["layer_apply" , 1, REQ_NONE , ['$d->gauss_rle($P*100+1,1,1)',""] ],
+["layer_reorder" , 3, REQ_ALPHA, [1,""] ],
+["make_bevel_logos" , 1, REQ_ALPHA, [$white,$color1,$color2,45,4,0] ],
+["make_trans_logos" , 1, REQ_ALPHA, [0,$gradient1,$color1] ],
+["map_to_gradient" , 1, REQ_NONE , [$gradient1] ],
+["mirror_split" , 1, REQ_NONE , [0] ],
+["perlotine" , 1, REQ_GUIDE|REQ_DIR, ["foo.html","t","png",0,"",1,0] ],
+["pixelgen" , 0, REQ_NONE , [$width,$height,RGB_IMAGE,'($x*$y*0.01)->slice("*$bpp")'] ],
+["pixelmap" , 1, REQ_NONE , ['($x*$y*0.01)->slice("*$bpp")'] ],
+["prep4gif" , 2, REQ_ALPHA, [64,1,0,1,255] ],
+["random_art_1" , 0, REQ_NONE , [$width,$height,20,10,1,30,0] ],
+["random_blends" , 1, REQ_NONE , [7] ],
+["red_eye" , 1, REQ_NONE , [0] ],
+["repdup" , 1, REQ_SEL , [3,50,50] ],
+["round_sel" , 1, REQ_SEL , [16] ],
+["scratches" , 1, REQ_NONE , [30,70,0.3,15,10] ],
+["selective_sharpen" , 1, REQ_NONE , [5.0,1.0,20] ],
+["seth_spin" , 2, REQ_LAYER, [16,$color1,40,1,1] ],
+["stamps" , 0, REQ_NONE , [90,$white,$color1,10,5] ],
+# ["tex_string_to_float" , 1, REQ_NONE , ["","I can write \\\\TeX",72,6,4] ],
+# ["view3d" , 1, REQ_NONE , [0,1,1] ],
+["webify" , 1, REQ_NONE , [1,1,$white,3,32,1] ],
+["windify" , 1, REQ_NONE , [120,80,30,1] ],
+["xach_blocks" , 1, REQ_NONE , [10,40] ],
+["xach_shadows" , 1, REQ_NONE , [10] ],
+["xachvision" , 1, REQ_NONE , [$color1,25] ],
+["yinyang" , 0, REQ_NONE , [$width,$height,1,0,"","",1] ],
+);
+
+for my $test (@testbench) {
+ my ($name, $numlays, $flags, $params) = @$test;
+ my @actualparams = @$params;
+ my $tempdir;
+ if ($flags & REQ_DIR) {
+ $tempdir = File::Temp->newdir($DEBUG ? (CLEANUP => 0) : ());
+ unshift @actualparams, $tempdir.'';
+ }
+ if ($numlays > 0) {
+ my $img = newimage($numlays);
+ my $drw = $img->get_active_layer;
+ unshift @actualparams, ($img->get_layers)[1] if $flags & REQ_LAYER;
+ unshift @actualparams, $img, $drw;
+ Gimp::Display->new($img);
+ if ($flags & REQ_ALPHA) {
+ $drw->add_alpha;
+ $img->select_rectangle(CHANNEL_OP_REPLACE,0.1*$height,0.1*$width,0.8*$height,0.8*$width);
+ $img->selection_invert;
+ $drw->edit_cut;
+ $img->selection_none;
+ }
+ $img->select_rectangle(
+ CHANNEL_OP_REPLACE,0.2*$height,0.2*$width,0.6*$height,0.6*$width
+ ) if $flags & REQ_SEL;
+ map {
+ $img->add_hguide($width * $_); $img->add_vguide($height * $_);
+ } (0.3, 0.6, 0.9) if $flags & REQ_GUIDE;
+ }
+ warn "Running $name\n" if $Gimp::verbose;
+#use Data::Dumper;warn Dumper(Gimp->procedural_db_proc_info("perl_fu_$name"));
+ my $img = eval { Gimp::Plugin->$name(@actualparams); };
+ is($@, '', "plugin $name");
+ $img->delete if defined $img;
+}
+
+Gimp::Net::server_quit;
+Gimp::Net::server_wait;
+
+done_testing;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]