[gimp-perl] Update examples/windify to GIMP 2.8.10. Bug 534130
- From: Ed J <edj src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp-perl] Update examples/windify to GIMP 2.8.10. Bug 534130
- Date: Wed, 23 Apr 2014 04:07:31 +0000 (UTC)
commit 1cf6a048e3b590323f276b01a625e8104832a45e
Author: Ed J <m8r-35s8eo mailinator com>
Date: Mon Mar 17 22:44:26 2014 +0000
Update examples/windify to GIMP 2.8.10. Bug 534130
examples/windify | 78 +++++++++++++++++++++++++++++++++++++++++++++++------
1 files changed, 69 insertions(+), 9 deletions(-)
---
diff --git a/examples/windify b/examples/windify
index cc448f9..b54c718 100755
--- a/examples/windify
+++ b/examples/windify
@@ -5,6 +5,11 @@ 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
+# - 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
# There's corruption on the edges of this in smear mode. Yuck.
@@ -20,7 +25,7 @@ sub windify {
my $ysize = gimp_drawable_height($drawable);
my $out = gimp_image_new($xsize,$ysize,0);
- gimp_display_new($out);
+ #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);
@@ -34,7 +39,7 @@ sub windify {
plug_in_mblur($out,$windlayercopy,
0, #0=linear
15, #length
- $angle,
+ $angle,
gimp_drawable_width($windlayercopy)/2,
gimp_drawable_height($windlayercopy)/2
);
@@ -45,16 +50,16 @@ sub windify {
# gimp_image_merge_visible_layers bug
my $newlay = gimp_image_get_active_layer ($out);
- my $xmult = cos($angle*180/3.14159);
- my $ymult = sin($angle*180/3.14159);
+ my $xmult = cos(3.14159*$angle/180);
+ my $ymult = sin(3.14159*$angle/180);
plug_in_displace($img,$drawable,-$distance*$xmult,
$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_image_remove_layer($out,$newlay);
+ gimp_image_delete ($out);
+ gimp_displays_flush();
gimp_context_pop();
undef;
@@ -70,9 +75,9 @@ register
N_"<Image>/Filters/Distorts/Windify...",
"*",
[
- [PF_INT32, "angle", "Wind Angle, 0 is left", 120],
+ [PF_INT32, "angle", "Wind Angle in degrees, 0 is right, increases anticlockwise", 120],
[PF_INT32, "density", "How Much Is Blown",80],
- [PF_VALUE, "distance", "How Far Its Blown",30],
+ [PF_VALUE, "distance", "How Far It's Blown",30],
[PF_TOGGLE, "wrap", "Smear on Edges (or Wrap)",1]
],
\&windify;
@@ -85,3 +90,58 @@ 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")
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]