Skip to content

Instantly share code, notes, and snippets.

@pauljonescodes
Created June 17, 2024 21:00
Show Gist options
  • Save pauljonescodes/337dc956dacc400d2387bcedeca1b3a6 to your computer and use it in GitHub Desktop.
Save pauljonescodes/337dc956dacc400d2387bcedeca1b3a6 to your computer and use it in GitHub Desktop.
import 'dart:ui';
const List<double> zoomLevels = [15, 16, 17, 18, 19, 20];
const List<double> iconSizes = [32, 48, 56, 64, 72, 80];
double? interpolateDouble(double value, double minInput, double maxInput, double minOutput, double maxOutput) {
double t = (value - minInput) / (maxInput - minInput);
return lerpDouble(minOutput, maxOutput, t);
}
void main() {
for (double zoom in zoomLevels) {
double? size = interpolateDouble(
zoom,
zoomLevels.first,
zoomLevels.last,
iconSizes.first,
iconSizes.last,
);
print('Zoom level: $zoom -> Icon size: ${size!.toStringAsFixed(2)}');
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment