scale

Scaling allows you to multiply both axis. All locations and sizes are then multiplied by the amount given. So scaling an axis by 2, will double all locations, and all sizes, when drawing. Conversely scaling by 0.5 will half all values.

It is a very useful transformation to use for performing lots of effects, such as having an image scale in or out from 0.

Note that you can also scale images as they are drawn, using 'drawImage', and this is a much simpler if that is all you wish to do.

scale( xy )

Scales both axis by the value given.

scale( x, y )

This call to scale allows you to scale each axis independently.

/* 
 * Draws an unhappy face, scaling in and out.
 */

angle = 0
setFont( 'Segoe UI', 200, 'bold' )

onEachFrame() do |delta|
    fill( :black )
    
    angle = angle + delta/24
    scale = angle.cos()
    alpha = angle.cos().abs()
    
    // move to the centre of the screen, and scale
    translate( getScreenWidth()/2, getScreenHeight()/2 )
    scale( scale )
    
    // draw our scene
    setColor( :blue, alpha )
    fillRect( 0, 0, getScreenWidth(), getScreenHeight(), true )
    
    setColor( :white, alpha )
    fillText( ":(", 0, 0, true )
end

See also

rotate - translate - drawImage