Task
Draw a rotating cube.

It should be oriented with one vertex pointing straight up, and its opposite vertex on the main diagonal (the one farthest away) straight down. It can be solid or wire-frame, and you can use ASCII art if your language doesn't have graphical capabilities. Perspective is optional.




Related tasks
 Draw a cuboid
 write language name in 3D ASCII


global escala
global tam
global zoff
global cylr
 
escala = 50
tam = 320
zoff = 0.5773502691896257645091487805019574556
cylr = 1.6329931618554520654648560498039275946
 
clg
graphsize tam, tam
 
dim x(6)
theta = 0.0
dtheta = 1.5
dt = 1.0 / 30
dim cylphi = {PI/6, 5*PI/6, 3*PI/2, 11*PI/6, PI/2, 7*PI/6}
 
while key = ""
    lasttime = msec
    for i = 0 to 5
        x[i] = tam/2 + escala *cylr * cos(cylphi[i] + theta)
    next i
    clg
    call drawcube(x)
 
    while msec < lasttime + dt
    end while
    theta += dtheta*(msec-lasttime)
    pause .4
    call drawcube(x)
end while
 
subroutine drawcube(x)
    for i = 0 to 2
        color rgb(0,0,0)  #black
        line tam/2, tam/2 - escala / zoff, x[i], tam/2 - escala * zoff
        line tam/2, tam/2 + escala / zoff, x[5-i], tam/2 + escala * zoff
        line  x[i], tam/2 - escala * zoff, x[(i % 3) + 3], tam/2 + escala * zoff
        line  x[i], tam/2 - escala * zoff, x[((i+1)%3) + 3], tam/2 + escala * zoff
    next i
end subroutine