Created
June 17, 2024 20:59
-
-
Save pauljonescodes/0f7ec4c022d4cd0e32b32f67b8ff4d7c 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