Draw a rotating cube: Difference between revisions
Content added Content deleted
Thundergnat (talk | contribs) m (→{{header|Raku}}: Tweak for stricter List / Array semantics) |
|||
Line 2,074: | Line 2,074: | ||
Raku has no native graphics libraries built in, but makes it fairly easy to bind to third party libraries. Here we'll use bindings to [[wp:Libcaca|Libcaca]], the '''C'''olor '''A'''S'''C'''II '''A'''rt library to generate a rotating cube in an ASCII terminal. |
Raku has no native graphics libraries built in, but makes it fairly easy to bind to third party libraries. Here we'll use bindings to [[wp:Libcaca|Libcaca]], the '''C'''olor '''A'''S'''C'''II '''A'''rt library to generate a rotating cube in an ASCII terminal. |
||
<lang perl6>use |
<lang perl6>use Terminal::Caca; |
||
use Terminal::Caca; |
|||
given my $canvas = Terminal::Caca.new { |
given my $canvas = Terminal::Caca.new { |
||
.title('Rosetta Code - Rotating cube - Press any key to exit'); |
.title('Rosetta Code - Rotating cube - Press any key to exit'); |
||
Line 2,112: | Line 2,111: | ||
[ [1, 1, 1], [-1, -1, 1], [-1, 1, 1] ], # near face |
[ [1, 1, 1], [-1, -1, 1], [-1, 1, 1] ], # near face |
||
[ [1, 1, 1], [-1, -1, 1], [ 1, -1, 1] ]; |
[ [1, 1, 1], [-1, -1, 1], [ 1, -1, 1] ]; |
||
@mesh.push: [$_».rotate( 1)] for @mesh[^4]; # positive and |
@mesh.push: [$_».rotate( 1)».Array] for @mesh[^4]; # positive and |
||
@mesh.push: [$_».rotate(-1)] for @mesh[^4]; # negative rotations |
@mesh.push: [$_».rotate(-1)».Array] for @mesh[^4]; # negative rotations |
||
# Rotate to correct orientation for task |
# Rotate to correct orientation for task |