Kaleidoscope

Here’s some code for a kaleidoscope. I didn’t put much time into it so it can probably be improved. Change the value of a to increase or decrease to number of images used. Make it 10, 15, 20, 30, 45, 60, 90, 120. It uses the camera so point it at something colorful.

displayMode(FULLSCREEN)

function setup()
    cameraSource(CAMERA_BACK)
    a=20    -- change this in multiples of 360
    x=math.cos(math.rad(a))*WIDTH
    y=math.sin(math.rad(a))*WIDTH
    myMesh = mesh()
    myMesh.vertices = {vec2(0,0),vec2(WIDTH,0),vec2(x,y)}
    myMesh.texCoords = {vec2(0,0),vec2(1,0),vec2(0,1)}
end

function draw()
    background(40, 40, 50)
    collectgarbage()
    img=image(CAMERA)
    translate(WIDTH/2,HEIGHT/2)
    if img~=nil then
        myMesh.texture = img
        for z=1,360/a do
            rotate(a)
            myMesh:draw()
        end
    end
end

Made changes to the above code. Tap the left side of the screen to reduce the number of angles. Tap the right side to increase the number of angles.

displayMode(FULLSCREEN)

function setup()
    tab={}
    for z=3,120 do
        if 360%z==0 then
            table.insert(tab,z)
        end
    end
    cameraSource(CAMERA_BACK)
    offset=15
    setup1()
end

function setup1()
    a=tab[offset]
    x=math.cos(math.rad(a))*WIDTH
    y=math.sin(math.rad(a))*WIDTH
    myMesh = mesh()
    myMesh.vertices = {vec2(0,0),vec2(WIDTH,0),vec2(x,y)}
    myMesh.texCoords = {vec2(0,0),vec2(1,0),vec2(0,1)}
end

function draw()
    background(40, 40, 50)
    collectgarbage()
    img=image(CAMERA)
    translate(WIDTH/2,HEIGHT/2)
    if img~=nil then
        myMesh.texture = img
        for z=1,360/a do
            rotate(a)
            myMesh:draw()
        end
    end
end

function touched(t)
    if t.state==BEGAN then
        if t.x>WIDTH/2 then
            if offset>1 then
                offset=offset-1
            end
        elseif offset<#tab then
            offset=offset+1
        end
        setup1()
    end
end