generate exposures > 1"

This commit is contained in:
Vadim 2024-04-22 14:04:19 +02:00
parent ec1f1eeeb4
commit afbd28155a

View file

@ -158,22 +158,42 @@ class MeteringContainerBuidler extends StatelessWidget {
shutterSpeedOffset = 0; shutterSpeedOffset = 0;
} }
final int itemsCount = min( int itemsCount = min(
apertureValues.length + shutterSpeedOffset, apertureValues.length + shutterSpeedOffset,
shutterSpeedValues.length + apertureOffset, shutterSpeedValues.length + apertureOffset,
) - ) -
max(apertureOffset, shutterSpeedOffset); max(apertureOffset, shutterSpeedOffset);
if (itemsCount <= 0) { if (apertureOffset == apertureValues.length) {
return List.empty(); return List.empty();
} }
final lastPreCalcShutterSpeed =
shutterSpeedValues.elementAtOrNull(itemsCount - 1 + shutterSpeedOffset) ?? shutterSpeedValues.last;
final preCalculatedItemsCount = itemsCount;
if (itemsCount <= 0) {
itemsCount = apertureValues.length;
} else {
while (apertureValues[itemsCount - 1 + apertureOffset] != apertureValues.last) {
itemsCount += 1;
}
}
final exposurePairs = List.generate( final exposurePairs = List.generate(
itemsCount, itemsCount,
(index) => ExposurePair( (index) {
final stopDifference = (index - (preCalculatedItemsCount - 1)) / (stopType.index + 1);
final newShutterSpeed = log2(lastPreCalcShutterSpeed.rawValue) + stopDifference;
return ExposurePair(
apertureValues[index + apertureOffset], apertureValues[index + apertureOffset],
shutterSpeedValues[index + shutterSpeedOffset], shutterSpeedValues.elementAtOrNull(index + shutterSpeedOffset) ??
ShutterSpeedValue(
calcShutterSpeed(newShutterSpeed),
false,
stopDifference == stopDifference.roundToDouble() ? StopType.full : stopType,
), ),
);
},
growable: false, growable: false,
); );
@ -191,7 +211,9 @@ class MeteringContainerBuidler extends StatelessWidget {
); );
final endCutEV = max( final endCutEV = max(
equipmentApertureValues.last.difference(exposurePairs.last.aperture), equipmentApertureValues.last.difference(exposurePairs.last.aperture),
equipmentShutterSpeedValues.last.difference(exposurePairs.last.shutterSpeed), equipmentShutterSpeedValues.last != ShutterSpeedValue.values.last
? equipmentShutterSpeedValues.last.difference(exposurePairs.last.shutterSpeed)
: double.negativeInfinity,
); );
final startCut = (startCutEV * (stopType.index + 1)).round().clamp(0, itemsCount); final startCut = (startCutEV * (stopType.index + 1)).round().clamp(0, itemsCount);
@ -203,3 +225,12 @@ class MeteringContainerBuidler extends StatelessWidget {
return exposurePairs.sublist(startCut, itemsCount - endCut); return exposurePairs.sublist(startCut, itemsCount - endCut);
} }
} }
double calcShutterSpeed(double stopValue) {
final shutterSpeed = pow(2, stopValue);
if (stopValue < 1.5) {
return (shutterSpeed * 10).round() / 10;
} else {
return shutterSpeed.roundToDouble();
}
}