# gizgame/picture

The picture of one frame: the passes a game draws, in order.

```gizlang
import * as Picture from "gizgame/picture";
```

## Types

### `Picture`

```gizlang
class Picture { game: Game; screen: Screen; resources: Resources; graph: Graph = new Graph(); time: f64; width: f64; height: f64; passes: i64 = 0; private last: string = ""; constructor(game: Game, screen: Screen, resources: Resources) { this.game = game; this.screen = screen; this.resources = resources; this.time = game.time(); this.width = f64(screen.width); this.height = f64(screen.height); } stage(stage: Stage, camera: Camera, environment: Environment): void throws string { const s = this.screen.scale; const lit: Environment = environment.directions !== undefined || s> = 0.9 ? environment: { ...environment, directions: 6 }; this.last = stage.draw(this.graph, Math.maxI64(1, i64(Math.round(this.width*s))), Math.maxI64(1, i64(Math.round(this.height*s))), camera, lit, this.time); } lights(lights: Lights2D, canvas: Canvas2D, ambient: Vec<f64>): void throws string { const name = `lights${this.passes }`; this.passes+ = 1; lights.draw(this.graph, canvas, ambient, name, this.last === "" ? []: [this.last]); this.last = name; } batch(batch: Batch2D, quads: Vec<Quad>, clear: Vec<f64> = [0, 0, 0, 1]): void throws string { const name = `canvas${this.passes }`; this.passes+ = 1; batch.draw(this.graph, quads, this.screen.width, this.screen.height, clear, name, this.last !== "", this.last === "" ? []: [this.last]); this.last = name; } }
```

One frame's picture: its passes in order, each drawn over the one before. TIME is the simulation's, between ticks.

- `game`: `Ref<M201.Game>`
- `screen`: `M201.Screen`
- `resources`: `gizlang_render.Resources`
- `graph`: `gizlang_render.Graph`
- `time`: `f64`
- `width`: `f64` — The surface's size in pixels.
- `height`: `f64`
- `passes`: `i64` — The 2D passes drawn so far (batch).
- `last`: `string`

## Functions

### `constructor`

```gizlang
constructor(game: Game, screen: Screen, resources: Resources)
```

An empty picture of GAME on SCREEN, its passes made of RESOURCES.

Effects: fail, read, write, alloc.

## Methods

### `Picture.stage`

```gizlang
stage(stage: Stage, camera: Camera, environment: Environment): void throws string
```

STAGE drawn from CAMERA under ENVIRONMENT, at the screen's scale: the frame path spreads the scene over the
surface, and what is drawn after it (the display) keeps the surface's own pixels.

Effects: fail, read, write, console, io, alloc.

### `Picture.lights`

```gizlang
lights(lights: Lights2D, canvas: Canvas2D, ambient: Vec<f64>): void throws string
```

The light of CANVAS's lamps over AMBIENT, multiplying the passes drawn so far, its walls casting shadows.

Effects: fail, read, write, console, io, alloc.

### `Picture.batch`

```gizlang
batch(batch: Batch2D, quads: Vec<Quad>, clear: Vec<f64> = [0, 0, 0, 1]): void throws string
```

QUADS drawn with BATCH: over the passes before it, or on CLEAR when it is the first.

Effects: fail, read, write, alloc.

