@amplib/photography

GitHub ↗

Camera

A camera stream with what a photograph needs: an element to sample, mirroring, the granted frame rate, and shutter time in milliseconds.

new Camera({ facingMode?: "environment" | "user"; width?: number; height?: number; frameRate?: number; followOrientation?: boolean; })

Darkroom

Assembling long exposures from many frames. expose method captures the burst, develop method re-renders it live. keepNegative optionally saves the burst, so restack can change frames and stack after the fact.

new Darkroom(canvas?: HTMLCanvasElement)

darkroom.expose(video: HTMLVideoElement, options: ExposeOptions): Promise<Exposure>

darkroom.develop(params: DevelopParams, scale?: number): void

darkroom.restack({ frames?: number; stack?: "mean" | "max" }): Exposure

const camera = new Camera({ facingMode: "environment" });
const darkroom = new Darkroom(canvas);

await camera.start();
// capture — only the light is unrepeatable
await darkroom.expose(camera.video, {
  frames: 8, // shutter time = frames over the camera's rate
  stack: "mean", // "mean" spreads motion; "max" keeps light trails
  mirror: camera.mirrored,
  keepNegative: true, // hold the burst — frames/stack restack() live
});
// post — re-renders the held exposure; free to call live
darkroom.develop({
  trail: 0.55, // -1 trails lead, 1 they follow — "mean" only
  exposure: 0.00, // stops, before the shoulder
  rolloff: 0.55, // how far into the filmic shoulder
  halation: 0.30, // light bleeding past its own edges
  headroom: 0.35, // re-expands near-clipped values into the bloom
  halationHue: 0.50, // 0 film red-orange, 1 the source's own hue
  black: 0.15, // black point, after the split tone
  softness: 0.38, // travel toward a blurred copy
  grain: 0.35,
  drift: 0.30, // sub-degree rotation + chromatic aberration
  aperture: 0.00, // 0 pinhole-sharp, 1 shallowest focus
  focalPlane: 0.50, // the sharp band — 0 bottom, 1 top
  split: 0.40, // strength of the shadow/highlight tone split
  shadowHue: 196, // degrees
  highlightHue: 38, // degrees
  vignette: 0.12,
});
// Enable the camera to begin.

A parameter that does nothing in the current mode is marked inert by the schema and its control leaves; the reasons print below.