Changeset - 11d11a57837d
[Not reviewed]
default
0 1 0
Tess Snider (Malkyne) - 3 years ago 2021-07-24 11:25:18
this@malkyne.org
Reorganizing the white-reaction clip extrapolation to see if it works better.
1 file changed with 24 insertions and 19 deletions:
0 comments (0 inline, 0 general)
Models/ReactionTest.cs
Show inline comments
...
 
@@ -209,36 +209,42 @@ namespace DesertPaintCodex.Models
 
                        Reaction = CalculateReaction();
 
                    }
 
                    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;
 
                    profile?.SetPairClipStatus(Reagent1, Reagent2, Clipped);
...
 
@@ -254,12 +260,11 @@ namespace DesertPaintCodex.Models
 
        private bool ExtrapolateWhiteFromOneChannel(int result, int clipBound, int reaction)
 
        {
 
            if (result == clipBound) return false;
 
            
 
            Clipped  = ClipType.None;
 
            State = TestState.GoodResult;
 
            Reaction = new Reaction(reaction, reaction, reaction);
 
            BadReaction = null;
 
            State    = TestState.GoodResult;
 

	
 
            return true;
 
        }
 

	
 

	
0 comments (0 inline, 0 general)