Core guide

2D cameras

Transform world-space drawing with synchronous position, zoom, and rotation scopes.

Live example

See 2D cameras in action

See world-space shapes rendered through a rotated and zoomed camera scope.

live rendering loading ticks 0

How it works

camera.draw temporarily maps world coordinates into the logical viewport. It restores the previous camera synchronously, even when the callback throws. Drawing outside the scope remains in screen space.

Public types

  • Camera
  • CameraOptions
  • CameraViewport
  • Bounds
  • Point

Minimum viable example

const camera = create_camera({ x: 400, y: 225, zoom: 2, rotation: degrees(10), viewport });
camera.draw(() => {
  renderer.draw_texture(hero, { x: 400, y: 225 });
});

Scope and limitations

Advanced projections, cursor-anchored zoom, and automatic culling are deferred.