File: test5.p

package info (click to toggle)
libpdl-graphics-trid-perl 2.102-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 476 kB
  • sloc: perl: 5,082; ansic: 683; makefile: 8
file content (43 lines) | stat: -rw-r--r-- 1,105 bytes parent folder | download | duplicates (2)
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
use strict;
use warnings;
use PDL;
use PDL::Graphics::TriD;
use PDL::Graphics::TriD::Graph;

my $size = 30;
my $y = PDL->zeroes(3,$size,$size);
axisvalues($y->slice("(0)")->inplace);
axisvalues($y->slice("(1)")->transpose->inplace);
$y /= $size;
random($y->slice("(2)")->inplace);
(my $tmp = $y->slice("(2)")) /= 5;
my $c = PDL->zeroes(3,$size,$size);
random($c->inplace);

my @objs = (
  ['Lattice'],
  ['SCLattice'],
  ['SLattice'],
  ['SLattice_S', {Smooth=>0}],
  ['SLattice_S'],
);
my $i = 0;
@objs = map [$i++, @$_], @objs;
my ($below_obj, $above_obj) = map [$_, 'Lines'], -1, 0+@objs;

sub mk_trid { "PDL::Graphics::TriD::$_[1]"->new($y+pdl(0,0,$_[0]),$c,$_[2]) }

my $win = PDL::Graphics::TriD::get_current_window();
my $g = PDL::Graphics::TriD::Graph->new;
my @all = [map mk_trid(@$_), $below_obj, @objs, $above_obj];
push @all, map [map mk_trid(@$_), $below_obj, $_, $above_obj], @objs;
for my $these (@all) {
  $g->clear_data;
  $win->clear_viewport;
  $g->default_axes;
  $g->add_dataseries($_) for @$these;
  $g->scalethings;
  $win->clear_objects;
  $win->add_object($g);
  $win->twiddle;
}