frame method
Tells it the last frame took seconds. Once a second it lowers the
scale if most frames missed the target, or raises it if nearly all
had a fifth of their time to spare.
Implementation
void frame(double seconds) {
if (!enabled || seconds <= 0 || seconds > 0.5) return;
final budget = 1 / targetFps;
_frames++;
_window += seconds;
if (seconds > budget * 1.1) _slow++;
if (seconds < budget * 0.8) _fast++;
if (_window < 1) return;
if (_slow > _frames / 2) {
_scale = (_scale - step).clamp(minScale, maxScale);
} else if (_fast > _frames * 0.9) {
_scale = (_scale + step).clamp(minScale, maxScale);
}
_window = 0;
_frames = _slow = _fast = 0;
}