feat: ui rework and gear generator

This commit is contained in:
2026-04-28 17:13:30 +02:00
parent 82ea8125e1
commit 57a14134a6
300 changed files with 2901 additions and 135 deletions

View File

@ -0,0 +1,31 @@
const double gearRatioMin = 0.25;
const double gearRatioMax = 5.75;
const int gearRatioEmptyRaw = 0;
const int gearRatioMinRaw = 1;
const int gearRatioMaxRaw = 255;
const double gearRatioStep =
(gearRatioMax - gearRatioMin) / (gearRatioMaxRaw - gearRatioMinRaw);
int encodeGearRatioByte(double value) {
if (value <= 0) {
return gearRatioEmptyRaw;
}
final clamped = value.clamp(gearRatioMin, gearRatioMax);
final scaled = ((clamped - gearRatioMin) / gearRatioStep).round();
return (gearRatioMinRaw + scaled)
.clamp(gearRatioMinRaw, gearRatioMaxRaw)
.toInt();
}
double decodeGearRatioByte(int raw) {
if (raw <= gearRatioEmptyRaw) {
return 0;
}
final clamped = raw.clamp(gearRatioMinRaw, gearRatioMaxRaw).toInt();
return gearRatioMin + (clamped - gearRatioMinRaw) * gearRatioStep;
}
double quantizeGearRatio(double value) {
return decodeGearRatioByte(encodeGearRatioByte(value));
}