user
Task

Draw a   cuboid   with relative dimensions of    2 × 3 × 4.

The cuboid can be represented graphically, or in   ASCII art,   depending on the language capabilities.

To fulfill the criteria of being a cuboid, three faces must be visible.

Either static or rotational projection is acceptable for this task.

Related tasks

* draw a sphere
* draw a rotating cube
* write language name in 3D ASCII
* draw a Deathstar
assistant
(formerly Perl 6)

**Works with**: moar version 2015-11-27

```
sub braille-graphics (%a) {
    my ($ylo, $yhi, $xlo, $xhi);
    for %a.keys -> $y {
	$ylo min= +$y; $yhi max= +$y;
	for %a{$y}.keys -> $x {
	    $xlo min= +$x; $xhi max= +$x;
	}
    }

    for $ylo, $ylo + 4 ...^ * > $yhi -> \y {
	for $xlo, $xlo + 2 ...^ * > $xhi -> \x {
	    my $cell = 0x2800;
	    $cell += 1   if %a{y + 0}{x + 0};
	    $cell += 2   if %a{y + 1}{x + 0};
	    $cell += 4   if %a{y + 2}{x + 0};
	    $cell += 8   if %a{y + 0}{x + 1};
	    $cell += 16  if %a{y + 1}{x + 1};
	    $cell += 32  if %a{y + 2}{x + 1};
	    $cell += 64  if %a{y + 3}{x + 0};
	    $cell += 128 if %a{y + 3}{x + 1};
	    print chr($cell);
	}
	print "\n";
    }
}

sub cuboid ( [$x, $y, $z] ) {
    my \x = $x * 4;
    my \y = $y * 4;
    my \z = $z * 2;
    my %t;
    sub horz ($X, $Y) { %t{$Y     }{$X + $_} = True for 0 .. x }
    sub vert ($X, $Y) { %t{$Y + $_}{$X     } = True for 0 .. y }
    sub diag ($X, $Y) { %t{$Y - $_}{$X + $_} = True for 0 .. z }
 
    horz(0, z); horz(z, 0); horz(  0, z+y);
    vert(0, z); vert(x, z); vert(z+x,   0);
    diag(0, z); diag(x, z); diag(  x, z+y);
 
    say "[$x, $y, $z]";
    braille-graphics %t;
}
 
cuboid $_ for [2,3,4], [3,4,2], [4,2,3], [1,1,1], [8,1,1], [1,8,1], [1,1,8];

```

Output: