Created
June 17, 2024 21:00
-
-
Save pauljonescodes/337dc956dacc400d2387bcedeca1b3a6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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