[gimp-perl] Tidy-up for repdup, stamps, stampify
- From: Ed J <edj src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp-perl] Tidy-up for repdup, stamps, stampify
- Date: Fri, 13 Jun 2014 02:45:27 +0000 (UTC)
commit 55c24bb3553646f5ff00d0156d6e76ad5dfda752
Author: Michele <michele gherlone liceoberchet it>
Date: Fri Jun 13 04:41:32 2014 +0200
Tidy-up for repdup, stamps, stampify
Signed-off-by: Ed J <edj src gnome org>
examples/repdup | 17 ++++++++---------
examples/stampify | 49 ++++++++++++++++++++++---------------------------
examples/stamps | 27 +++++++++++++--------------
3 files changed, 43 insertions(+), 50 deletions(-)
---
diff --git a/examples/repdup b/examples/repdup
index 2bb81b2..42995c3 100755
--- a/examples/repdup
+++ b/examples/repdup
@@ -1,24 +1,23 @@
#!/usr/bin/perl -w
-use Gimp qw(:auto __ N_);
+use Gimp;
use Gimp::Fu;
use strict;
use warnings;
podregister {
$image->undo_group_start;
- my @b = gimp_selection_bounds($image);
+ my @b = $image->selection_bounds;
my $w = $b[3] - $b[1];
my $h = $b[4] - $b[2];
- gimp_edit_copy($drawable);
- gimp_selection_none($image);
+ $drawable->edit_copy;
+ $image->selection_none;
for (my $i = 0; $i < $repeats; $i++) {
- $b[1] = $b[1] + $xoffset;
- $b[2] = $b[2] + $yoffset;
+ $b[1] += $xoffset;
+ $b[2] += $yoffset;
$image->select_rectangle(CHANNEL_OP_REPLACE, @b[1,2], $w, $h);
- my $bit_bucket = gimp_edit_paste($drawable, 0);
- gimp_floating_sel_anchor($bit_bucket);
- gimp_selection_none($image);
+ $drawable->edit_paste(FALSE)->floating_sel_anchor;
+ $image->selection_none
}
$image->undo_group_end;
return;
diff --git a/examples/stampify b/examples/stampify
index de819f3..df5567c 100755
--- a/examples/stampify
+++ b/examples/stampify
@@ -1,25 +1,25 @@
#!/usr/bin/perl -w
-use Gimp qw(:auto __ N_);
+use Gimp;
use Gimp::Fu;
use strict;
use warnings;
podregister {
- $nw = int(gimp_image_width($image) + 2 * $marg + $diameter);
- $nh = int(gimp_image_height($image) + 2 * $marg + $diameter);
- my $img2 = gimp_image_new($nw, $nh, RGB);
- my $layer1 = gimp_layer_new($img2, $nw, $nh, RGBA_IMAGE, "Layer 1", 100, NORMAL_MODE);
- gimp_image_insert_layer($img2, $layer1, 0, 0);
- gimp_image_set_active_layer($img2, $layer1);
- gimp_context_set_background($paper);
- gimp_drawable_fill($layer1, 1);
+ my $nw = int($image->width + 2 * $marg + $diameter);
+ my $nh = int($image->height + 2 * $marg + $diameter);
+ my $img2 = Gimp::Image->new($nw, $nh, RGB);
+ my $layer1 = $img2->layer_new($nw, $nh, RGBA_IMAGE, "Layer 1", 100, NORMAL_MODE);
+ $img2->insert_layer($layer1, 0, 0);
+ $img2->set_active_layer($layer1);
+ Gimp::Context->set_background($paper);
+ $layer1->edit_fill(BACKGROUND_FILL);
# create horisontal holes
- gimp_selection_none($img2);
+ $img2->selection_none;
my $nholes = int (($nw + $gap) / ($diameter + $gap) + 0.5);
- $pos = 0;
- for ($i = 0; $i<$nholes; $i++) {
- gimp_image_select_ellipse($img2,
+ my $pos = 0;
+ for (my $i = 0; $i<$nholes; $i++) {
+ $img2->select_ellipse(
CHANNEL_OP_ADD, $pos, 0,
$diameter, $diameter,
);
@@ -27,24 +27,19 @@ podregister {
}
# create vertical holes
$pos = 0;
- for ($i = 0; $i<$nholes; $i++) {
- gimp_image_select_ellipse(
- $img2, CHANNEL_OP_ADD, 0, $pos,
- $diameter, $diameter,
- );
+ for (my $i = 0; $i<$nholes; $i++) {
+ $img2->select_ellipse(CHANNEL_OP_ADD, 0, $pos, $diameter, $diameter);
$pos = $pos + $diameter + $gap;
}
- gimp_context_set_background($hole);
- gimp_edit_fill($layer1, BACKGROUND_FILL);
- gimp_selection_none($img2);
+ Gimp::Context->set_background($hole);
+ $layer1->edit_fill(BACKGROUND_FILL);
+ $img2->selection_none;
# here comes the clever part! :-)
# offset horis and vert holes by half the diameter
- gimp_drawable_offset($layer1, 1, 0, -($diameter / 2), -($diameter / 2));
-# insert $image into a new layer in $img2
-# gimp_selection_all($image);
- gimp_edit_copy($drawable);
- my $float = gimp_edit_paste($layer1, 0);
- gimp_floating_sel_anchor($float);
+ $layer1->offset(TRUE, OFFSET_BACKGROUND, -($diameter / 2), -($diameter / 2));
+ $image->selection_all;
+ $drawable->edit_copy;
+ $layer1->edit_paste(FALSE)->floating_sel_anchor;
# and return command to The Gimp.
eval { Gimp::Display->new($img2); };
return $img2;
diff --git a/examples/stamps b/examples/stamps
index 0bb0767..18fb20a 100755
--- a/examples/stamps
+++ b/examples/stamps
@@ -1,6 +1,6 @@
#!/usr/bin/perl -w
-use Gimp qw(:auto __ N_);
+use Gimp;
use Gimp::Fu;
use strict;
use warnings;
@@ -8,13 +8,13 @@ use warnings;
N_"/Xtns/Render"; # dummy translation for i18n bugs
podregister {
- gimp_context_set_background($paper);
- my $img = gimp_image_new($size, $size, RGB);
- my $layer = gimp_layer_new($img, $size, $size, RGB_IMAGE, "Layer 1", 100, NORMAL_MODE);
- gimp_image_insert_layer($layer, 0, -1);
- gimp_context_set_background($hole);
- $layer->gimp_edit_fill(BACKGROUND_FILL);
- gimp_selection_none($img);
+ Gimp::Context->set_background($paper);
+ my $img = Gimp::Image->new($size, $size, RGB);
+ my $layer = $img->layer_new($size, $size, RGB_IMAGE, "Layer 1", 100, NORMAL_MODE);
+ $img->insert_layer($layer, 0, -1);
+ Gimp::Context->set_background($hole);
+ $layer->edit_fill(BACKGROUND_FILL);
+ $img->selection_none;
my $ncircles = int(($size + $gap) / ($diameter + $gap));
my $x = 0;
for (my $i=0; $i<$ncircles; $i++) {
@@ -22,12 +22,12 @@ podregister {
$img->select_ellipse( CHANNEL_OP_ADD, 0, $x, $diameter, $diameter);
$x += $diameter + $gap;
}
- gimp_context_set_background($paper);
- gimp_edit_fill($layer, BACKGROUND_FILL);
- gimp_selection_none($img);
+ Gimp::Context->set_background($paper);
+ $layer->edit_fill(BACKGROUND_FILL);
+ $img->selection_none;
# here, at last, comes the clever part! :-)
$layer->offset(1, 0, -($diameter / 2), -($diameter / 2));
- eval { gimp_display_new($img); };
+ eval { Gimp::Display->new($img); };
return $img;
};
@@ -65,5 +65,4 @@ Claes G Lindblad <claesg algonet se>
=head1 LICENSE
Claes G Lindblad <claesg algonet se>
-
-Distributed under the terms of the GNU public license, v2 or higher.
+Distributed under the terms of the GNU Public License, v2 or higher.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]