A way to dynamically zoom the entire screen

Could I tell Codea to zoom into a part of the app without actually changing the true size of anything on screen? That way I could write the code for it to follow an object, but not manipulate any variables already set.

Maybe instead of drawing directly on the screen, draw on a image object and sizing it?

Scale : http://twolivesleft.com/Codea/Reference/Graphics.html#scale

function setup()
    e = { x = WIDTH*.5, y = HEIGHT*.5, r = 50 }
end

function draw()
    background(0)
    pushMatrix()
    scale(4)
    fill(125)
    ellipse(e.x, e.y. e.r)
    popMatrix()
    fill(255)
    ellipse(e.x, e.y. e.r)
end

@Batman I’m not sure I understand what you want. Is this something like what you’re after.

http://codea.io/talk/discussion/2165/image-magnifier#Item_5

I understand… So “translate” is for move the background in a character moving…
@dave1707 i think he means the way a platformer game does… He draws the entire level, but the screen only shows the part the character is.

@Andresan. Yes that’s what I’m referring to.

@Batman Try this. Just move your finger on the screen to move the character. The grid is a lot larger than the screen.


displayMode(FULLSCREEN)

function setup()
    w2=WIDTH/2
    h2=HEIGHT/2
    gdx=w2
    gdy=h2
    dx=0
    dy=0
    size=3000
    move=false
    gSize=100
    
    r={}    -- table of random key locations
    for z=1,50 do
        r[z]=vec2(math.random(-size,size),math.random(-size,size))
    end
end

function removeKey()    -- remove key when character is over it
    for z=1,#r do
        if math.abs(dx-r[z].x)<10 and math.abs(dy-r[z].y)<10 then
            table.remove(r,z)
            return
        end
    end
end

function draw()
    background(40, 40, 50)
    
    if move then    -- move the character
        dx=dx-(sx-mx)/8
        dy=dy-(sy-my)/8
        removeKey()
    end
    
    -- scroll the grid and character left or right
    if dx>WIDTH-50-gdx then
        gdx=WIDTH-50-dx
    elseif dx<gdx*-1+50 then
        gdx=50-dx
    end  
    
    -- scroll the grid and character up or down
    if dy>HEIGHT-50-gdy then
        gdy=HEIGHT-50-dy
    elseif dy<gdy*-1+50 then
        gdy=50-dy
    end  

    pushMatrix()
    translate(gdx,gdy)    -- move grid and character
    
    sprite("SpaceCute:Background",0,0,size*2,size*2)    -- draw background
    
    stroke(255)    -- draw grid lines and grid values
    strokeWidth(4) 
    fontSize(30)
    fill(0, 255, 15, 255)
    for z=-size,size,gSize do
        line(z,-size,z,size)
        line(-size,z,size,z)
        text(z,z,0)
        text(z,0,z)
    end

    for z=1,#r do    -- draw random keys
        sprite("Planet Cute:Key",r[z].x,r[z].y) 
    end
    
    sprite("Planet Cute:Character Boy",dx,dy)    -- draw character
    popMatrix()
    
    fill(250, 13, 13, 255)    -- show number of keys still on the screen
    text(#r,w2,1000)
    
end

function touched(t)
    if t.tapCount==2 then    -- double tap to move character back to center position
        dx=0
        dy=0
        gdx=w2
        gdy=h2
        --gSize=gSize*2
    end
    if t.state==BEGAN then    -- finger starting x,y position
        sx=t.x
        sy=t.y
    elseif t.state==MOVING then    -- finger direction to move character
        move=true
        mx=t.x
        my=t.y
    elseif t.state==ENDED then    -- finger raised, stop moving character
        move=false
    end
end