File: view3d

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 (44 lines) | stat: -rwxr-xr-x 1,159 bytes parent folder | download | duplicates (3)
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
#!/opt/bin/perl

use Gimp::Feature qw(pdl);
use PDL;
BEGIN { eval "use PDL::Graphics::TriD"; $@ and Gimp::Feature::missing('PDL TriD (OpenGL) support') }
use Gimp;
use Gimp::Fu;

register
    'view3d',
    'View grayscale drawable in 3D',
    'This script uses PDL::Graphics:TriD to view a grayscale drawable in 3D. You can choose a Cartesian (default) or Polar projection, toggle the drawing of lines, and toggle normal smoothing.',
    'Tom Rathborne', 'GPLv2', '1999-03-11',
    N_"<Image>/View/3D Surface...",
    'RGB*,GRAY*', [
        [ PF_BOOL, 'polar', 'Radial view', 0],
        [ PF_BOOL, 'lines', 'Draw grid lines', 0],
        [ PF_BOOL, 'smooth', 'Smooth surface normals', 1]
    ], [],
sub {
    my ($img, $dwb, $polar, $lines, $smooth) = @_;

    my $w = $dwb->width;
    my $h = $dwb->height;

    my $regn = $dwb->pixel_rgn (0, 0, $w, $h, 0, 0);
    my $surf = $regn->get_rect (0, 0, $w, $h);
    $surf=$surf->slice("(0)");

    imag3d [ $polar ? 'POLAR2D' : 'SURF2D', $surf ],
           { 'Lines' => $lines, 'Smooth' => $smooth };

    ();
};

exit main;

=head1 LICENSE

(c) Tom Rathborne

Released under the GNU Public License v2.

=cut