File: windify

package info (click to toggle)
libgimp-perl 2.0.dfsg-5
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 2,112 kB
  • ctags: 462
  • sloc: perl: 10,026; sh: 207; ansic: 207; makefile: 70
file content (74 lines) | stat: -rwxr-xr-x 2,180 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#!/opt/bin/perl

eval 'exec /opt/bin/perl  -S $0 ${1+"$@"}'
    if 0; # not running under some shell

# sent to me by Seth Burgess <sjburges@gimp.org>
# small changes my Marc Lehmann <pcg@goof.com>

use Gimp qw(:auto N_ __);
use Gimp::Fu;

#Gimp::set_trace(TRACE_CALL);

sub windify {
	my ($img, $drawable, $angle, $density, $distance, $wrap) = @_;
	my $oldbg = gimp_palette_get_background();
	my $xsize = gimp_drawable_width($drawable);
	my $ysize = gimp_drawable_height($drawable);

	my $out = gimp_image_new($xsize,$ysize,0);
	gimp_palette_set_background([128,128,128]);
	my $windlayer = gimp_layer_new($out,$xsize,$ysize,RGB_IMAGE,"Windlayer",100,NORMAL_MODE);
	gimp_drawable_fill($windlayer, 0);
	gimp_image_add_layer($out,$windlayer,0);
	my $windlayercopy = gimp_layer_copy($windlayer, 1);
	gimp_image_add_layer($out,$windlayercopy,0);
	plug_in_noisify($out,$windlayercopy,0,$density/255,
                                                $density/255,
                                                $density/255,1);

	plug_in_mblur($out,$windlayercopy,0,15,$angle);
	gimp_layer_set_mode($windlayercopy, 10); # Lighten Only
	gimp_image_merge_visible_layers($out,0);

# many thanks to Dov for this suggestion as a workaround to the 
# gimp_image_merge_visible_layers bug

	my $newlay = gimp_image_get_active_layer ($out);
	plug_in_displace($img,$drawable,-$distance*cos($angle*180/3.14159),
                                          $distance*sin($angle*180/3.14159),
					  1,1, $newlay,$newlay, $wrap);
	gimp_image_remove_layer($out,$newlay);
	gimp_image_delete ($out);
	gimp_palette_set_background($oldbg);
	gimp_displays_flush();
	
	undef;
	}

register
	"windify",
	"Add wind to an image",
	"Blow your image all over :)",
	"Seth Burgess",
	"Seth Burgess <sjburges\@gimp.org>",
	"1998-09-14",
	N_"<Image>/Filters/Distorts/Windify...",
	"*",
	[
	 [PF_INT32, "angle", "Wind Angle, 0 is left", 120],
	 [PF_INT32, "density", "How Much Is Blown",80],
	 [PF_VALUE, "distance", "How Far Its Blown",30],
	 [PF_TOGGLE, "smear", "Smear on Edges (or Wrap)",0]
	],
	\&windify;

exit main;

=head1 LICENSE

Copyright Seth Burgess.  
Distrubuted under the same terms as Gimp-Perl.

=cut