Draw a cuboid: Difference between revisions
Content deleted Content added
Added Algol 68 |
|||
Line 203: | Line 203: | ||
| |/ |
| |/ |
||
+----+ </pre> |
+----+ </pre> |
||
=={{header|ALGOL 68}}== |
|||
Draws a static cuboid using ASCII art - orientated in the same fashion as in the Befunge sample. |
|||
<syntaxhighlight lang="algol68"> |
|||
BEGIN # draw some cuboids using ASCII art # |
|||
# draws a cuboid standing on one edge using ASCII art # |
|||
PROC aa cuboid = ( INT h, w, l )VOID: |
|||
BEGIN |
|||
# top line # |
|||
FOR i TO l DO print( ( " " ) ) OD; |
|||
FOR i TO w + 1 DO print( ( "_" ) ) OD; |
|||
print( ( newline ) ); |
|||
# rest of the top face and part of the visible side # |
|||
INT face width := 0; |
|||
INT edge pos := 0; |
|||
FOR i TO l DO |
|||
FOR j TO l - i DO print( ( " " ) ) OD; |
|||
print( ( "/" ) ); |
|||
FOR j TO w DO print( ( IF i = l THEN "_" ELSE " " FI ) ) OD; |
|||
print( ( "/" ) ); |
|||
edge pos +:= 1; |
|||
IF edge pos <= h THEN |
|||
# drsw the back edge # |
|||
face width := 2 * ( edge pos - 1 ); |
|||
FOR j TO face width DO print( ( " " ) ) OD; |
|||
print( ( "\" ) ) |
|||
ELSE |
|||
# draw the bottom edge # |
|||
FOR j TO face width + 1 DO print( ( " " ) ) OD; |
|||
print( ( "/" ) ) |
|||
FI; |
|||
print( ( newline ) ) |
|||
OD; |
|||
# other vidible face # |
|||
FOR i TO h DO |
|||
FOR j TO i - 1 DO print( ( " " ) ) OD; |
|||
print( ( "\" ) ); |
|||
FOR j TO w DO print( ( IF i = h THEN "_" ELSE " " FI ) ) OD; |
|||
print( ( "\" ) ); |
|||
edge pos +:= 1; |
|||
IF edge pos <= h THEN |
|||
# drsw the back edge # |
|||
FOR j TO face width + 1 DO print( ( " " ) ) OD; |
|||
print( ( "\" ) ) |
|||
ELSE |
|||
# draw the bottom edge # |
|||
FOR j TO face width DO print( ( " " ) ) OD; |
|||
face width -:= 2; |
|||
print( ( "/" ) ) |
|||
FI; |
|||
print( ( newline ) ) |
|||
OD |
|||
END # aa cuboid # ; |
|||
aa cuboid( 3, 2, 4 ); |
|||
aa cuboid( 4, 3, 2 ); |
|||
aa cuboid( 2, 4, 3 ); |
|||
aa cuboid( 2, 3, 4 ) |
|||
END |
|||
</syntaxhighlight> |
|||
{{out}} |
|||
<pre> |
|||
___ |
|||
/ /\ |
|||
/ / \ |
|||
/ / \ |
|||
/__/ / |
|||
\ \ / |
|||
\ \ / |
|||
\__\/ |
|||
____ |
|||
/ /\ |
|||
/___/ \ |
|||
\ \ \ |
|||
\ \ \ |
|||
\ \ / |
|||
\___\/ |
|||
_____ |
|||
/ /\ |
|||
/ / \ |
|||
/____/ / |
|||
\ \ / |
|||
\____\/ |
|||
____ |
|||
/ /\ |
|||
/ / \ |
|||
/ / / |
|||
/___/ / |
|||
\ \ / |
|||
\___\/ |
|||
</pre> |
|||
=={{header|Arturo}}== |
=={{header|Arturo}}== |