new

new Image( name )

Creates a new Image, loaded from the images uploaded to the Asset Manager.

playerImg = new Image( 'player.png' )

onEachFrame() do
    controls = getControls()
    drawImage( playerImg, controls.getMouseX(), controls.getMouseY(), true )
end

new Image( width, height )

Creates a new, blank image. It's contents is entirely empty. All pixels are fully transparent black colour.

This is very useful for using Images as intermediate buffers, and targets to render to. This allows you to implement visuals, such as blurs, and other advanced effects.

// Uses a secondary 'back' image to create a blur effect
back = new Image( getScreenWidth(), getScreenHeight() )
back.fill( :black )

OFFSET = 3

onEachFrame() do
    back.fill( :black, 0.1 )
    
    back.setColor( :red ) do
        controls = getControls()
        back.fillRect( controls.getMouseX(), controls.getMouseY(), 40, 40, true )
    end
    
    (-OFFSET).to(OFFSET) do |x|
        (-OFFSET).to(OFFSET) do |y|
            delta = (x+y) / (OFFSET*OFFSET)
            
            setAlpha( 0.1 + delta*0.3 ) do
                drawImage( back, x*3, y*3 )
            end
        end
    end
end