1#!/usr/bin/perl -w
2
3use Gimp;
4use Gimp::Fu;
5use strict;
6use warnings;
7
8podregister {
9  Gimp::Context->push();
10  my $xsize = $drawable->width;
11  my $ysize = $drawable->height;
12  my $out = Gimp::Image->new($xsize,$ysize,0);
13  Gimp::Context->set_background([128,128,128]);
14  my $windlayer = $out->layer_new($xsize,$ysize,RGB_IMAGE,"Windlayer",100,NORMAL_MODE);
15  $windlayer->fill(0);
16  $out->insert_layer($windlayer,0,0);
17  my $windlayercopy = $windlayer->copy(1);
18  $out->insert_layer($windlayercopy,0,0);
19  $windlayercopy->noisify(0,$density/255, $density/255, $density/255, 1);
20  $windlayercopy->mblur(
21    0, 15, $angle, $windlayercopy->width/2, $windlayercopy->height/2
22  );
23  $windlayercopy->set_mode(10); # Lighten Only
24  $out->merge_visible_layers(0);
25
26# many thanks to Dov for this suggestion as a workaround to the
27# gimp_image_merge_visible_layers bug
28  my $newlay = $out->get_active_layer;
29  my $xmult = cos(3.14159*$angle/180);
30  my $ymult = sin(3.14159*$angle/180);
31  $drawable->displace(
32    -$distance*$xmult, $distance*$ymult, 1, 1, $newlay, $newlay, $wrap
33  );
34  $drawable->offset(1,0,$distance*$xmult,-$distance*$ymult);
35  $out->delete;
36  Gimp::Context->pop();
37  ();
38};
39
40exit main;
41__END__
42
43=head1 NAME
44
45windify - Add wind to an image
46
47=head1 SYNOPSIS
48
49<Image>/Filters/Distorts/Windify...
50
51=head1 DESCRIPTION
52
53Blow your image all over!
54
55=head1 PARAMETERS
56
57 [PF_INT32, "angle", "Wind Angle in degrees, 0 is right, increases anticlockwise", 120],
58 [PF_INT32, "density", "How Much Is Blown",80],
59 [PF_VALUE, "distance", "How Far It's Blown",30],
60 [PF_TOGGLE, "wrap", "Smear on Edges (or Wrap)",1]
61
62=head1 IMAGE TYPES
63
64*
65
66=head1 HISTORY
67
68 sent to me by Seth Burgess <sjburges@gimp.org>
69 small changes my Marc Lehmann <pcg@goof.com>
70 2014/03/17 ported to GIMP 2.8.10 by Ed J:
71   - I think the fill with the foreground colour should be background
72     since that's the colour expressly set, but didn't touch
73   - adjusted the maths so inputs are in degrees
74
75 There's corruption on the edges of this in smear mode.  Yuck.
76
77=head1 AUTHOR
78
79Seth Burgess <sjburges@gimp.org>
80
81=head1 DATE
82
831998-09-14
84
85=head1 LICENSE
86
87Distributed under the same terms as Gimp-Perl.
88