[gimp-perl] update scripts to 2.10 PDB calls



commit 6c721fe5b96c1c3a5b84a0ec01d8f377718f8006
Author: Ed J <mohawk2 users noreply github com>
Date:   Sat Apr 17 20:51:16 2021 +0100

    update scripts to 2.10 PDB calls

 Changes                    |  1 +
 examples/blowinout         |  8 ++++----
 examples/bricks            | 12 ++++++------
 examples/glowing_steel     | 15 ++++++++-------
 examples/innerbevel        | 15 ++++++++++++---
 examples/prep4gif          |  2 +-
 examples/randomart1        | 10 +++-------
 examples/randomblends      | 12 ++++--------
 examples/scratches         |  2 +-
 examples/selective_sharpen |  2 +-
 examples/xachlego          |  2 +-
 examples/yinyang           |  2 +-
 t/02-netplugin.t           |  2 +-
 t/02-supplied.t            |  2 +-
 14 files changed, 45 insertions(+), 42 deletions(-)
---
diff --git a/Changes b/Changes
index 56b12496..0da2ae02 100644
--- a/Changes
+++ b/Changes
@@ -1,5 +1,6 @@
 - updated constants to GIMP 2.10 versions
 - remove menu path up to last / and call gimp_plugin_menu_register with that
+- updated scripts to 2.10 PDB calls
 
 2.33 2019-04-11
  - Makefile.PL survive non-conf deps so can say what deps are
diff --git a/examples/blowinout b/examples/blowinout
index b6fe9871..11483756 100755
--- a/examples/blowinout
+++ b/examples/blowinout
@@ -33,8 +33,8 @@ podregister {
     $i * $distance / $nsteps * sin($angle * 3.14159 / 180) :
     $distance ** ($i/$nsteps) * sin($angle * 3.14159 / 180);
   $dmlayer->edit_clear;
-  $dmlayer->noisify(0, 255, 255, 255, 0);
-  $dmlayer->levels(0, 0, 255, 1.0, 128, 255);
+  $dmlayer->noisify(0, 1.0, 1.0, 1.0, 0);
+  $dmlayer->levels(0, 0, 1.0, 1, 1.0, 0.5, 1.0, 1);
   $drawable = $drawable->copy(0);
   $image->insert_layer($drawable, 0, -1);
   $drawable->displace($xdist, $ydist, 1, 1, $dmlayer, $dmlayer, 1);
@@ -47,8 +47,8 @@ podregister {
       $i * $distance / $nsteps * sin($angle * 3.14159 / 180) :
       $distance ** ($i/$nsteps) * sin($angle * 3.14159 / 180);
     $dmlayer->edit_clear;
-    $dmlayer->noisify(0, 255, 255, 255, 0);
-    $dmlayer->levels(0, 0, 255, 1.0, 128, 255);
+    $dmlayer->noisify(0, 1.0, 1.0, 1.0, 0);
+    $dmlayer->levels(0, 0, 1.0, 1, 1.0, 0.5, 1.0, 1);
     $drawable = $drawable->copy(0);
     $image->insert_layer($drawable, 0, -1);
     $drawable->displace($xdist, $ydist, 1, 1, $dmlayer, $dmlayer, 1);
diff --git a/examples/bricks b/examples/bricks
index 5c9fcf95..2e06c1f5 100755
--- a/examples/bricks
+++ b/examples/bricks
@@ -18,7 +18,7 @@ podregister {
   Gimp::Context->set_pattern($pattern);
   my $layerpat = $image->add_new_layer(0,0,0);
   $image->selection_all;
-  $layerpat->edit_bucket_fill(2,0,100,0,0,1,1);
+  $layerpat->edit_bucket_fill(FILL_WHITE,0,0);
   # make border lines
   Gimp::Context->set_foreground ([1,1,1]);
   my $layer = $image->add_new_layer(0,0,0);
@@ -28,12 +28,12 @@ podregister {
   $image->undo_group_start;
   while ($h < $imageh) {
     $image->select_rectangle(2,0,$h,$imagew,$borderwidth);
-    $layer->edit_bucket_fill(0,0,100,0,0,0,0);
+    $layer->edit_bucket_fill(FILL_FOREGROUND,0,0);
     $w = 1;
     $wo = 0; $wo = ($brickw / 2) if ($j == 1);
     while ($w < $imagew) {
       $image->select_rectangle(2,$w+$wo,$h,$borderwidth,$brickh+1);
-      $layer->edit_bucket_fill(0,0,100,0,0,1,1);
+      $layer->edit_bucket_fill(FILL_FOREGROUND,0,0);
 #      print "$h $w\n";
       $w += $brickw;
     }
@@ -62,11 +62,11 @@ podregister {
        Gimp::Context->set_foreground ("#ffffff") if ($r > 0);
        Gimp::Context->set_foreground ("#000000") if ($r < 0);
        $image->select_rectangle(2,$w+$wo,$h,$brickw,$brickh);
-       $layerpat->edit_bucket_fill(0,0,4*abs($r),0,0,1,1);
+       $layerpat->edit_bucket_fill(FILL_FOREGROUND,0,0);
        # halves
        if (($j == 1) && ($w+$wo+$brickw > $imagew)) {
          $image->select_rectangle(2,0,$h,$brickw/2,$brickh);
-         $layerpat->edit_bucket_fill(0,0,4*abs($r),0,0,1,1);
+         $layerpat->edit_bucket_fill(FILL_FOREGROUND,0,0);
        }
       }
       $w += $brickw;
@@ -80,7 +80,7 @@ podregister {
   $image->selection_all;
   if ($borderpatuse) {
     Gimp::Context->set_pattern($borderpattern);
-    $layerb->edit_bucket_fill(2,0,100,0,0,1,1);
+    $layerb->edit_bucket_fill(FILL_WHITE,0,0);
   }
   $border->edit_copy();
   $layerb->add_alpha;
diff --git a/examples/glowing_steel b/examples/glowing_steel
index 84fcd405..98c5dab4 100755
--- a/examples/glowing_steel
+++ b/examples/glowing_steel
@@ -49,7 +49,7 @@ sub perl_fu_glowing_steel {
   # Fill the background
   $image->selection_all;
   Gimp::Context->set_foreground($background);
-  $backlayer->edit_bucket_fill(BUCKET_FILL_FG, LAYER_MODE_NORMAL_LEGACY, 100, 0, 1, 0, 0);
+  $backlayer->edit_bucket_fill(BUCKET_FILL_FG, 0, 0);
 
   # Make the glow:
   perl_fu_add_glow($image, $textlayer, $glow, $radius);
@@ -100,7 +100,7 @@ sub perl_fu_add_glow {
   $image->select_item(CHANNEL_OP_REPLACE, $drawable);
   $image->selection_grow($radius);
   $image->selection_feather($radius*1.5);
-  $glow->edit_bucket_fill(BUCKET_FILL_FG, LAYER_MODE_NORMAL_LEGACY, 100, 255, 0, 0, 0);
+  $glow->edit_bucket_fill(BUCKET_FILL_FG, 0, 0);
   $image->select_item(CHANNEL_OP_REPLACE, $drawable);
   $glow->edit_clear;
   $image->select_item(CHANNEL_OP_REPLACE, $old_sel);
@@ -152,7 +152,7 @@ sub perl_fu_brushed_metal {
   $image->map_to_gradient($templ, $gradient)
     if $use_gradient && defined($gradient) && $gradient ne '';
 
-  $templ->brightness_contrast(50, 0);
+  $templ->brightness_contrast(50/255, 0);
   $image->noisify($templ, 0, 0.3, 0.3, 0.3, 0);
   $image->mblur($templ, 0, $length, $angle, 0.0, 0.0);
 
@@ -199,11 +199,12 @@ sub perl_fu_highlight_edges {
   Gimp::Context->push();
 
   Gimp::Context->set_foreground([255,255,255]);
-  $white->edit_bucket_fill(BUCKET_FILL_FG, LAYER_MODE_NORMAL_LEGACY, 100, 255, 0, 0, 0);
+  $white->edit_bucket_fill(BUCKET_FILL_FG, 0, 0);
   Gimp::Context->set_foreground([0,0,0]);
-  $black->edit_bucket_fill(BUCKET_FILL_FG, LAYER_MODE_NORMAL_LEGACY, 100, 255, 0, 0, 0);
-  $white->translate(-1*$pixels, -1*$pixels);
-  $black->translate(1*$pixels, 1*$pixels);
+  $black->edit_bucket_fill(BUCKET_FILL_FG, 0, 0);
+  $pixels /= $image->width; # make into a float
+  $white->transform_translate(-1*$pixels, -1*$pixels);
+  $black->transform_translate(1*$pixels, 1*$pixels);
   $white = $image->merge_down($white, EXPAND_AS_NECESSARY);
   $white->set_name("Edge Highlight");
   $image->select_item(CHANNEL_OP_REPLACE, $drawable);
diff --git a/examples/innerbevel b/examples/innerbevel
index 504f81f8..813e1904 100755
--- a/examples/innerbevel
+++ b/examples/innerbevel
@@ -28,7 +28,16 @@ podregister {
   my @pt2 = ($layer->width * 0.5 +1, $layer->height);
   # -- step 3 --
   $layer->set_lock_alpha(1);
-  $layer->edit_blend(BLEND_FG_BG_RGB, LAYER_MODE_NORMAL_LEGACY, GRADIENT_LINEAR, 100, 0, REPEAT_NONE, 0, 0, 
0, 3, 0.20, @pt1, @pt2);
+  $layer->edit_gradient_fill(
+    GRADIENT_LINEAR,
+    0, # offset
+    0, # supersample
+    0, # supersample
+    3, # supersample
+    0, # dither
+    @pt1,
+    @pt2,
+  );
   # -- step 4 --
   my $layer2 = $layer->copy(0);     # Can you override these to have a default? (would be nice)
   $img->insert_layer($layer2, 0, 0);
@@ -43,10 +52,10 @@ podregister {
   # -- step 7 --
   $layer->plug_in_bump_map($layer2, $azimuth, $elevation, $depth, 0,0,0,0,1,0,$maptype);
   # -- step 8 --
-  $layer2->invert;
+  $layer2->invert(1);
   $img->lower_item($layer2);
   # -- step 9 --
-  $layer2->translate(2, 3);
+  $layer2->transform_translate(2/$img->width, 3/$img->height);
   # extra stuff
   $img->add_new_layer(2);
   $img->gimp_selection_none();
diff --git a/examples/prep4gif b/examples/prep4gif
index b1a61714..d166bc98 100755
--- a/examples/prep4gif
+++ b/examples/prep4gif
@@ -25,7 +25,7 @@ podregister {
 
   my $layer_mask = $foreground->create_mask(ADD_MASK_ALPHA);
   $foreground->add_mask ($layer_mask);
-  $layer_mask->threshold($threshold, 255);
+  $layer_mask->threshold(HISTOGRAM_VALUE, $threshold/255, 1.0);
 
 # Transfer layer mask to selection, and grow the selection
   $out->select_item(CHANNEL_OP_REPLACE, $foreground);
diff --git a/examples/randomart1 b/examples/randomart1
index 10985280..cfa30e3d 100755
--- a/examples/randomart1
+++ b/examples/randomart1
@@ -51,16 +51,12 @@ podregister {
       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 (BLEND_FG_BG_HSV,
-                    LAYER_MODE_DIFFERENCE_LEGACY,
+      $layer->edit_gradient_fill(
                     GRADIENT_LINEAR,         # gradient type
-                    100,                     # opacity
                     0,                       # offset
-                    REPEAT_TRIANGULAR,       # repeat
-                    0,                       # reverse
                     $super,                  # supersampling
-                    2,
-                    3,
+                    2, # supersample offset
+                    3, # supersample threshold
                     0,                       # no dithering
                     $width/2,                    # x1
                     $height/2,                    # y1
diff --git a/examples/randomblends b/examples/randomblends
index 9d93db54..2e961a4b 100755
--- a/examples/randomblends
+++ b/examples/randomblends
@@ -20,16 +20,12 @@ podregister {
     Gimp::Progress->init("Random blends...");
     for (my $i=0; $i<$numgradients; $i++) {
         Gimp::Context->set_gradient(@gradientlist[randint($#gradientlist)]);
-       $drawable->edit_blend(BLEND_CUSTOM,
-                       LAYER_MODE_DIFFERENCE_LEGACY,
+       $drawable->edit_gradient_fill(
                        randint(10),      # gradient type
-                       randint(100),     # opacity
                        0,                # offset
-                       randint(2),       # repeat
-                      0,                # reverse
                        0,                # disable supersampling..
-                      1,
-                      0.1,
+                       0,                # supersample offset
+                       0,                # supersample threshold
                       0,                # no dithering
                        randint($x2-$x1)+$x1, # x1
                        randint($y2-$y1)+$y1, # y1
@@ -55,7 +51,7 @@ random_blends - Perform N random blends
 
 =head1 DESCRIPTION
 
-A random approach to art, using the blend tool with LAYER_MODE_DIFFERENCE_LEGACY.
+A random approach to art, using the gradient fill tool.
 Alpha is not affected; best used on opaque background.
 Just try it. It might be good.
 
diff --git a/examples/scratches b/examples/scratches
index ca1b1746..e4308b8f 100755
--- a/examples/scratches
+++ b/examples/scratches
@@ -19,7 +19,7 @@ sub new_scratchlayer {
     $layer->fill (FILL_WHITE);
     $layer->noisify (0, 1, 1, 1, 0);
     $layer->mblur (0, $length, $angle, 0, 0);
-    $layer->levels (HISTOGRAM_VALUE, 120, 255, 0.3, 0, 255);
+    $layer->levels(HISTOGRAM_VALUE, 120/255, 1.0, 1, 0.3, 0, 1.0, 1);
     $layer;
 }
 
diff --git a/examples/selective_sharpen b/examples/selective_sharpen
index f7d0be9b..d7ee0950 100755
--- a/examples/selective_sharpen
+++ b/examples/selective_sharpen
@@ -22,7 +22,7 @@ podregister {
   $image->insert_layer($edge_layer,0,-1);
 
   # 2) convert the copy to grayscale
-  $edge_layer->desaturate;
+  $edge_layer->desaturate(DESATURATE_LIGHTNESS);
 
   # 3) run edge detect to the gray layer (default works)
   $edge_layer->edge(2.0, 2, 0);
diff --git a/examples/xachlego b/examples/xachlego
index 2409f3b1..03e462d3 100755
--- a/examples/xachlego
+++ b/examples/xachlego
@@ -36,7 +36,7 @@ podregister {
 #   grid until you get a roundish blob in the center of each square (you
 #   may need to repeat a few times).
 
-  $gridlayer->levels(0, 196, 234, $knobfactor/100.0 , 0, 255);
+  $gridlayer->levels(0, 196/255, 234/255, 1, $knobfactor/100.0 , 0, 1.0, 1);
 
 # <Xach> sjburges: meanwhile, back at the pixelized image, bumpmap it with
 # itself and a depth of about 5. do this twice.
diff --git a/examples/yinyang b/examples/yinyang
index 955114a9..facae4e7 100755
--- a/examples/yinyang
+++ b/examples/yinyang
@@ -6,7 +6,7 @@ use strict;
 use warnings;
 #$Gimp::verbose = 1;
 
-my @BUCKET_ARGS = (BUCKET_FILL_FG,LAYER_MODE_NORMAL_LEGACY,100,0,0,0,0);
+my @BUCKET_ARGS = (BUCKET_FILL_FG,0,0);
 
 podregister {
   # Create new image
diff --git a/t/02-netplugin.t b/t/02-netplugin.t
index e8c3ab88..fe473924 100644
--- a/t/02-netplugin.t
+++ b/t/02-netplugin.t
@@ -29,7 +29,7 @@ use Symbol 'gensym';
 use IO::Select; # needed because output can be big and it can block!
 
 our (@testbench, %proc2file, %file2procs);
-require 't/examples-api.pl';
+require './t/examples-api.pl';
 
 my %plug2yes = map { ($_=>1) } @PLUGINS;
 @testbench = grep { $plug2yes{$_->[0]} } @testbench;
diff --git a/t/02-supplied.t b/t/02-supplied.t
index 4759e7a8..3dbc271c 100644
--- a/t/02-supplied.t
+++ b/t/02-supplied.t
@@ -26,7 +26,7 @@ BEGIN {
 use Gimp qw(:consts), "net_init=spawn/";
 
 our @testbench;
-require 't/examples-api.pl';
+require './t/examples-api.pl';
 
 for my $test (@testbench) {
   my ($actualparams, $tempdir, $tempfile) = setup_args(@$test);


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