[gimp-perl] Final tidy-ups of different plugins in the examples directory



commit b72701e62d2b9f4d55a42476f78a226ce0cf6660
Author: Michele <michele gherlone liceoberchet it>
Date:   Sun Jun 8 20:25:16 2014 +0200

    Final tidy-ups of different plugins in the examples directory
    
    Signed-off-by: Ed J <edj src gnome org>

 examples/innerbevel  |    7 +++----
 examples/mirrorsplit |   24 ++++++++++--------------
 examples/prep4gif    |   38 +++++++++++++++++++-------------------
 examples/translogo   |    2 +-
 examples/warp-sharp  |    3 ++-
 examples/xachshadow  |   13 +++++--------
 examples/xachvision  |    5 +++--
 7 files changed, 43 insertions(+), 49 deletions(-)
---
diff --git a/examples/innerbevel b/examples/innerbevel
index a042a30..72d5a8f 100755
--- a/examples/innerbevel
+++ b/examples/innerbevel
@@ -1,11 +1,10 @@
 #!/usr/bin/perl -w
 
-use Gimp qw(:auto __ N_);
+use Gimp;
 use Gimp::Fu;
 use Gimp::Util;
 use strict;
 use warnings;
-#$Gimp::verbose = 1;
 
 N_"/Xtns/Render"; N_"/Xtns/Render/Logos"; # i18n workaround
 
@@ -15,7 +14,7 @@ podregister {
   Gimp::Context->set_background($color1);
   Gimp::Context->set_foreground($color2);
   my @dims = Gimp->text_get_extents_fontname($text, $fontsize, PIXELS,$font);
-  my $img = gimp_image_new($dims[0]+30, $dims[1]+10, RGB);
+  my $img = Gimp::Image->new($dims[0]+30, $dims[1]+10, RGB_IMAGE);
 
   # none of the macro's did quite what I was looking for here.
   # i.e. create a text layer on transparent only...
@@ -52,7 +51,7 @@ podregister {
   $img->add_new_layer(2);
   $img->gimp_selection_none();
   Gimp::Context->pop();
-  return($img);
+  return $img
 };
 
 exit main;
diff --git a/examples/mirrorsplit b/examples/mirrorsplit
index 0d0017c..34a8bf0 100755
--- a/examples/mirrorsplit
+++ b/examples/mirrorsplit
@@ -1,25 +1,24 @@
 #!/usr/bin/perl -w
 
-use Gimp qw(:auto __ N_);
+use Gimp;
 use Gimp::Fu;
 use Gimp::Util;
 use strict;
 use warnings;
 
 podregister {
+  $drawable->become('Gimp::Layer');
   my $w = $drawable->width();
   my $h = $drawable->height();
   my $wspan = int ($w / 2 + 0.5);
   my $hspan = int ($h / 2 + 0.5);
-
-  eval { $image->undo_group_start };
-
-  my $temp1 = gimp_layer_copy($drawable, 1);
-  $image->insert_layer($temp1,0,-1);
+  $image->undo_group_start;
+  my $temp1 = $drawable->copy(1);
+  $image->insert_layer($temp1, 0, -1);
   my $orientation = ($mirror < 2)
     ? &Gimp::ORIENTATION_VERTICAL
     : &Gimp::ORIENTATION_HORIZONTAL;
-  $temp1 = $temp1->transform_flip_simple($orientation, 1, 0.0);
+  $temp1 = $temp1->item_transform_flip_simple($orientation, TRUE, 0.0);
   my @xywh;
   if ($mirror == 0) {
     # upper half
@@ -35,14 +34,11 @@ podregister {
     @xywh = (0, 0, $wspan, $h);
   };
   $image->select_rectangle(&Gimp::CHANNEL_OP_REPLACE, @xywh);
-
-  gimp_edit_copy($temp1);
-  my $temp2 = gimp_edit_paste($drawable, 1);
-  gimp_floating_sel_anchor($temp2);
+  $temp1->edit_copy;
+  my $temp2 = $drawable->edit_paste(1)->floating_sel_anchor;
   $image->remove_layer($temp1);
-  gimp_selection_none($image);
-
-  eval { $image->undo_group_end };
+  $image->selection_none;
+  $image->undo_group_end;
   return;
 };
 exit main;
diff --git a/examples/prep4gif b/examples/prep4gif
index 9085abd..36d150e 100755
--- a/examples/prep4gif
+++ b/examples/prep4gif
@@ -1,48 +1,48 @@
 #!/usr/bin/perl -w
 
-use Gimp qw(:auto N_ __);
+use Gimp;
 use Gimp::Fu;
 use strict;
 use warnings;
 
 podregister {
   my $out = $image->duplicate; # only work on duplicate
-  my @layers = gimp_image_get_layers($out);
+  my @layers = $out->get_layers;
   die __"You need at least 2 layers to perform prep4gif\n" if @layers < 2;
 
 # Show the image early - this makes debugging a breeze
   eval { Gimp::Display->new($out); };
 # Hide the bottom layer, so it doesn't get into the merge visible later.
   my $bottomlayer = $layers[$#layers];
-  gimp_item_set_visible($bottomlayer, 0);
-  gimp_layer_add_alpha($bottomlayer);
+  $bottomlayer->set_visible(FALSE);
+  $bottomlayer->add_alpha;
   my $foreground;
   if ($#layers > 1) {
-    $foreground = gimp_image_merge_visible_layers($out, 0);
+    $foreground = $out->merge_visible_layers(EXPAND_AS_NECESSARY);
   } else {
     $foreground = $layers[0];
   }
 
-  my $layer_mask = gimp_layer_create_mask($foreground,2);
-  gimp_layer_add_mask ($foreground, $layer_mask);
-  gimp_threshold($layer_mask,$threshold,255);
+  my $layer_mask = $foreground->create_mask(ADD_ALPHA_MASK);
+  $foreground->add_mask ($layer_mask);
+  $layer_mask->threshold($threshold, 255);
 
 # Transfer layer mask to selection, and grow the selection
-  gimp_image_select_item($out, CHANNEL_OP_REPLACE, $foreground);
-  gimp_selection_grow($out,$growth);
+  $out->select_item(CHANNEL_OP_REPLACE, $foreground);
+  $out->selection_grow($growth);
 
 # Apply this selection to the background
-  gimp_item_set_visible($bottomlayer, 1);
-  gimp_image_set_active_layer($out, $bottomlayer);
-  gimp_selection_invert($out);
-  gimp_edit_cut($bottomlayer);
+  $bottomlayer->set_visible(TRUE);
+  $out->set_active_layer($bottomlayer);
+  $out->selection_invert;
+  $bottomlayer->edit_cut;
 
 # Clean up after yourself
-  gimp_layer_remove_mask($foreground, 1);
-  my $outlayer = gimp_image_merge_visible_layers($out,0);
+  $foreground->remove_mask(MASK_DISCARD);
+  my $outlayer = $out->merge_visible_layers(EXPAND_AS_NECESSARY);
 
 # Convert to indexed
-  gimp_image_convert_indexed($out,1, MAKE_PALETTE, $colors, $dither, 1, "")
+  $out->convert_indexed(FS_DITHER, MAKE_PALETTE, $colors, $dither, TRUE, "")
     if $index;
   ();
 };
@@ -82,8 +82,8 @@ RGB*
  June 29, 1998
 
  This perl plug-in prepares a multilayer RGB image for use as a
- transparent gif.  To use this prpoerly, you want to have something
- close to the intended background as the bottom layer.  If convert
+ transparent gif. To use this properly, you want to have something
+ close to the intended background as the bottom layer. If convert
  to indexed is not selected, the bottom two options are unused.
 
  12/5/03: <sjburges gimp org>
diff --git a/examples/translogo b/examples/translogo
index 2599c08..3e283b5 100755
--- a/examples/translogo
+++ b/examples/translogo
@@ -35,7 +35,7 @@ podregister {
   $img->insert_layer($bump_lay,0,0);
   if ($color_or_pattern == 1) {
     Gimp::Context->set_pattern ($pattern);
-    $bump_lay->bucket_fill(PATTERN_BUCKET_FILL, NORMAL_MODE, 100, 0, 0, 0, 0);
+    $bump_lay->edit_bucket_fill(PATTERN_BUCKET_FILL, NORMAL_MODE, 100, 0, 0, 0, 0);
   } else {
     Gimp::Context->set_background ($txt_col);
     $bump_lay->edit_fill(BACKGROUND_FILL);
diff --git a/examples/warp-sharp b/examples/warp-sharp
index ef50637..ac6ad3e 100755
--- a/examples/warp-sharp
+++ b/examples/warp-sharp
@@ -6,10 +6,11 @@ use strict;
 use warnings;
 
 podregister {
+  $drawable->become('Gimp::Layer');
   my $drawable_width=$drawable->width;
   my $drawable_height=$drawable->height;
   my $drawable_type=($drawable->type);
-  my $edge_layer = $drawable->copy(0);
+  my $edge_layer = $drawable->copy(FALSE);
   my $x_displace_layer=
     $image->layer_new($drawable_width, $drawable_height,
                    $drawable_type, "Displace X", 100, 0);
diff --git a/examples/xachshadow b/examples/xachshadow
index e066dc9..acbea60 100755
--- a/examples/xachshadow
+++ b/examples/xachshadow
@@ -9,22 +9,19 @@ podregister {
   $drawable->become('Gimp::Layer');
   $image->undo_group_start;
   Gimp::Context->push();
-#      $selection_flag = 0;
   $drawable->add_alpha unless $drawable->has_alpha;
   Gimp::Context->set_foreground('white');
   Gimp::Context->set_background('black');
-# This only can be applied to an entire image right now..
-#      $selection = $image->selection_save;
-$image->selection_all;
-# Now the fun begins :)
+  $image->selection_all;
+  # Now the fun begins :)
   $drawable->pixelize($blocksize);
-  my $shadowlayer = $drawable->layer_copy(0);
+  my $shadowlayer = $drawable->copy(FALSE);
   $image->insert_layer($shadowlayer,0,0);
   my $checkmask = $shadowlayer->create_mask(ADD_WHITE_MASK);
   $shadowlayer->add_mask($checkmask);
   $image->checkerboard($checkmask, 0, $blocksize);
 
-  my $frontlayer = $shadowlayer->layer_copy(0);
+  my $frontlayer = $shadowlayer->copy(0);
   $image->insert_layer($frontlayer,0,0);
   Gimp::Context->set_background([0,0,0]);
   $shadowlayer->fill(BACKGROUND_FILL);
@@ -40,7 +37,7 @@ $image->selection_all;
   $gridlayer->grid((1, $blocksize, 0, [0,0,0], 255) x 3);
 
   $gridlayer->set_mode(3);
-# Clean up stuff
+  # Clean up stuff
   Gimp::Context->pop;
   $image->selection_none;
   $image->undo_group_end;
diff --git a/examples/xachvision b/examples/xachvision
index c1579aa..64aa166 100755
--- a/examples/xachvision
+++ b/examples/xachvision
@@ -6,11 +6,12 @@ use strict;
 use warnings;
 
 podregister {
+  $drawable->become('Gimp::Layer');
   $image->undo_group_start;
   Gimp::Context->push();
-  my $midlayer = $drawable->gimp_layer_copy(1);
+  my $midlayer = $drawable->copy(TRUE);
   $image->insert_layer($midlayer, 0, 0);
-  my $toplayer = $drawable->gimp_layer_copy(1);
+  my $toplayer = $drawable->copy(TRUE);
   $image->insert_layer($toplayer, 0, 0);
   Gimp::Context->set_background($color);
   $toplayer->edit_fill(BACKGROUND_FILL);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]