API Reference › Camera › Camera.zoom
method

Camera.zoom

Camera.zoom(scale)

Sets a render-time zoom: every draw is scaled about the screen centre by scale, a Q16.16 fixed factor. 1.0 is no zoom (and turns the zoom path back off, restoring the byte-identical un-zoomed blit); 2.0 is 2x in; 0.5 is 2x out. It composes with Camera.set / Camera.follow (which move the view) and Camera.shake.

Zoom is a *render-time transform*, not a change to the world coordinate types — those stay integer pixels + Q16.16 velocity so lockstep, replay and world_save hold (see the position-types RFC, #78). Because it rides on fixed-point, the zoom is itself deterministic: the same scale produces the same pixels on every machine and headless.

Parameters

scalethe zoom factor (fixed); 1.0 = no zoom, >1 zooms in, <1 zooms out

Example

program Demo {
  property Cam { z: fixed = 1.0 }
  model View { Cam }
  handler DrawWorld phase Render {
    Camera.zoom(2.0)
    Screen.fill_rectangle(150, 110, 20, 20, 0xffcc00)
    Screen.show()
  }
}
← All symbols