Jump to content

Draw a rotating cube: Difference between revisions

m
→‎{{header|Raku}}: Tweak for stricter List / Array semantics
m (→‎{{header|Raku}}: Tweak for stricter List / Array semantics)
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.
 
<lang perl6>use lib 'lib'Terminal::Caca;
use Terminal::Caca;
given my $canvas = Terminal::Caca.new {
.title('Rosetta Code - Rotating cube - Press any key to exit');
Line 2,112 ⟶ 2,111:
[ [1, 1, 1], [-1, -1, 1], [-1, 1, 1] ], # near face
[ [1, 1, 1], [-1, -1, 1], [ 1, -1, 1] ];
@mesh.push: [$_».rotate( 1)».Array] for @mesh[^4]; # positive and
@mesh.push: [$_».rotate(-1)».Array] for @mesh[^4]; # negative rotations
 
# Rotate to correct orientation for task
10,339

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.