simple 3D illusion

Here’s something that I stumbled upon writing other code. I rewrote it to make it more straight forward. Just drag your finger around the screen a little then remove it and wait. Depending on the trail you left, you get a 3D illusion. To start another trail, just drag your finger again.


displayMode(FULLSCREEN)

function setup()
    tab={}
end

function draw()
    background(40, 40, 50)
    for a,b in pairs(tab) do
        fill(b.color)
        ellipse(b.x,b.y,b.size)
        b.size=b.size+.5
    end
end

function touched(t)
    if t.state==BEGAN then
        tab={}
    end
    if t.state==MOVING then
        table.insert(tab,{x=t.x,y=t.y,size=10,
            color=color(math.random(255),math.random(255),math.random(255))})
    end
end

Nice effect

Simple, yet great.

Quite cool.