#!/usr/bin/perl use warnings; use strict; use PDL::LiteF; use PDL::Graphics::TriD; # Need this to display use PDL::NiceSlice; use PDL::IO::GD; my $image = PDL::IO::GD->new( { x => 200, y => 200, true_color => 1 } ); # Allocate some colors: # my $black = $image->ColorAllocate( 0, 0, 0 ); my $white = $image->ColorAllocate( 255, 255, 255 ); my $red = $image->ColorAllocate( 255, 0, 0 ); my $green = $image->ColorAllocate( 0, 255, 0 ); my $blue = $image->ColorAllocate( 0, 0, 255 ); my $yellow = $image->ColorAllocate( 255, 255, 0 ); my $grey = $image->ColorAllocate( 200, 200, 200 ); my %pdls; my %color = ( 1 => [ 'white', $white ], 2 => [ 'red', $red ], 3 => [ 'green', $green ], 4 => [ 'blue', $blue ], 5 => [ 'yellow', $yellow ], 6 => [ 'grey', $grey ], ); foreach my $num ( keys %color ) { $image->FilledRectangle( 0, 0, 200, 200, $color{ $num }[ 1 ] ); # Add some text: my @brect; $image->StringFT( \@brect, $black, "./Generic.ttf", 120, 0, 50, 150, $num ); $pdls{ $num } = $image->to_pdl(); } nokeeptwiddling3d(); hold3d(); # side 1 of space imagrgb3d $pdls{ 1 }->mv( 2, 0 )->( :, -1 : 0, : )->float / 256, { Points => [ [ 0, 0, 1 ], [ 0, 0, 0 ], [ 1, 0, 0 ], [ 1, 0, 1 ] ] }; #side 2 of space imagrgb3d $pdls{ 2 }->mv( 2, 0 )->( :, -1 : 0, : )->float / 256, { Points => [ [ 0, 1, 0 ], [ 1, 1, 0 ], [ 1, 0, 0 ], [ 0, 0, 0 ] ] }; #side 3 of space imagrgb3d $pdls{ 3 }->mv( 2, 0 )->( :, -1 : 0, : )->float / 256, { Points => [ [ 1, 1, 0 ], [ 1, 1, 1 ], [ 1, 0, 1 ], [ 1, 0, 0 ] ] }; #side 4 of space imagrgb3d $pdls{ 4 }->mv( 2, 0 )->( :, -1 : 0, : )->float / 256, { Points => [ [ 1, 1, 1 ], [ 0, 1, 1 ], [ 0, 0, 1 ], [ 1, 0, 1 ] ] }; #good #side 5 of space imagrgb3d $pdls{ 5 }->mv( 2, 0 )->( :, -1 : 0, : )->float / 256, # {Points => [[0,0,0],[0,0,1],[0,1,1],[0,1,0]]}; { Points => [ [ 0, 1, 1 ], [ 0, 1, 0 ], [ 0, 0, 0 ], [ 0, 0, 1 ] ] }; #side 6 of space imagrgb3d $pdls{ 6 }->mv( 2, 0 )->( :, -1 : 0, : )->float / 256, { Points => [ [ 1, 1, 1 ], [ 1, 1, 0 ], [ 0, 1, 0 ], [ 0, 1, 1 ] ] }; keeptwiddling3d(); twiddle3d();