Screen helpers · function

clipFpsFor

The highest rate on the ladder this device can actually deliver, at this size.

Explained in Recording and clips.

function clipFpsFor(width: number, height: number, measuredFps: number,
import { clipFpsFor } from '@driftengine/core';

Parameters

ParameterTypeDescription
widthnumber
heightnumber
measuredFpsnumber
/** Pixels the measurement was taken at. Zero trusts the raw number
as above. */ measuredAtPixels?: number
ladder?readonly number[]

In depth

The default is the device's own maximum rather than a fixed rate. The ladder therefore starts above any panel this is likely to meet and walks down, so a 165 Hz monitor records 165 rather than being rounded to the nearest tidy number. The rungs are the rates real displays actually run at; anything between them is served by the next one down, which the pacer can hit with a whole stride.

Two ceilings, and both are hard. A clip cannot be captured faster than the game is drawn, because FramePacer takes every n-th animation frame, so a 60 Hz panel cannot produce a 120 fps file however fast the machine is; asking anyway would write a file claiming 120 while holding 60, which is precisely the lie the frame schedule exists to prevent. And the export size is not the window size, so the measured rate is scaled by pixel count exactly as exportSizeFor scales it, or a machine comfortable in a small window is credited with a 1080x1920 frame it cannot push.

Returns the lowest rung when nothing clears, rather than nothing: at that point the device is slow enough that exportSizeFor is about to reduce the frame, and the lower rate is what makes that reduction sufficient.