diff --git a/Models/ReactionTest.cs b/Models/ReactionTest.cs --- a/Models/ReactionTest.cs +++ b/Models/ReactionTest.cs @@ -210,34 +210,40 @@ namespace DesertPaintCodex.Models } else { - State = TestState.ClippedResult; - BadReaction = CalculateReaction(); - + Reaction? reaction = CalculateReaction(); + bool extrapolated = false; + // SPECIAL CASE: // Check to see if we've got a white-shift reaction that's partially clipped, where we can // still extrapolate the reaction, based on the available information. - if (!testing3Way && (BadReaction != null)) + if (!testing3Way && (reaction != null)) { PaintColor baseColor = _recipe.BaseColor; - if ((BadReaction.Red < baseColor.Red) && - (BadReaction.Green < baseColor.Green) && - (BadReaction.Blue < baseColor.Blue)) + if ((reaction.Red < baseColor.Red) && + (reaction.Green < baseColor.Green) && + (reaction.Blue < baseColor.Blue)) { // White-shift down clip. - bool extrapolated = ExtrapolateWhiteFromOneChannel(_observedColor.Red, 0, BadReaction.Red); - if (!extrapolated) extrapolated = ExtrapolateWhiteFromOneChannel(_observedColor.Green, 0, BadReaction.Green); - if (!extrapolated) ExtrapolateWhiteFromOneChannel(_observedColor.Blue, 0, BadReaction.Blue); + extrapolated = ExtrapolateWhiteFromOneChannel(_observedColor.Red, 0, reaction.Red); + if (!extrapolated) extrapolated = ExtrapolateWhiteFromOneChannel(_observedColor.Green, 0, reaction.Green); + if (!extrapolated) ExtrapolateWhiteFromOneChannel(_observedColor.Blue, 0, reaction.Blue); } - else if ((BadReaction.Red > baseColor.Red) && - (BadReaction.Green > baseColor.Green) && - (BadReaction.Blue > baseColor.Blue)) + else if ((reaction.Red > baseColor.Red) && + (reaction.Green > baseColor.Green) && + (reaction.Blue > baseColor.Blue)) { // White-shift up clip. - bool extrapolated = ExtrapolateWhiteFromOneChannel(_observedColor.Red, 255, BadReaction.Red); - if (!extrapolated) extrapolated = ExtrapolateWhiteFromOneChannel(_observedColor.Green, 255, BadReaction.Green); - if (!extrapolated) ExtrapolateWhiteFromOneChannel(_observedColor.Blue, 255, BadReaction.Blue); + extrapolated = ExtrapolateWhiteFromOneChannel(_observedColor.Red, 255, reaction.Red); + if (!extrapolated) extrapolated = ExtrapolateWhiteFromOneChannel(_observedColor.Green, 255, reaction.Green); + if (!extrapolated) ExtrapolateWhiteFromOneChannel(_observedColor.Blue, 255, reaction.Blue); } } + + if (!extrapolated) + { + State = TestState.ClippedResult; + BadReaction = CalculateReaction(); + } } PlayerProfile? profile = ProfileManager.CurrentProfile; @@ -255,10 +261,9 @@ namespace DesertPaintCodex.Models { if (result == clipBound) return false; - Clipped = ClipType.None; + State = TestState.GoodResult; Reaction = new Reaction(reaction, reaction, reaction); - BadReaction = null; - State = TestState.GoodResult; + return true; }