Changeset - a1bd6e3474d6
[Not reviewed]
default
0 1 0
Tess Snider (Malkyne) - 3 years ago 2021-07-24 10:55:15
this@malkyne.org
Should now extraplate white reactions if any of the channels didn't clip.
1 file changed with 39 insertions and 1 deletions:
0 comments (0 inline, 0 general)
Models/ReactionTest.cs
Show inline comments
...
 
@@ -179,2 +179,3 @@ namespace DesertPaintCodex.Models
 
            State = TestState.Scanning;
 
            bool testing3Way = Requires3Way && BufferIsSelected;
 
            bool foundLab = await ReactionScannerService.Instance.CaptureReactionAsync(this);
...
 
@@ -185,3 +186,2 @@ namespace DesertPaintCodex.Models
 
                {
 
                    // Handle the normal case.
 
                    Clipped = _observedColor.Red switch
...
 
@@ -214,2 +214,28 @@ namespace DesertPaintCodex.Models
 
                        BadReaction = CalculateReaction();
 

	
 
                        // 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))
 
                        {
 
                            PaintColor baseColor = _recipe.BaseColor;
 
                            if ((BadReaction.Red < baseColor.Red) &&
 
                                (BadReaction.Green < baseColor.Green) &&
 
                                (BadReaction.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);
 
                            }
 
                            else if ((BadReaction.Red > baseColor.Red) &&
 
                                (BadReaction.Green > baseColor.Green) &&
 
                                (BadReaction.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);
 
                            }
 
                        }
 
                    }
...
 
@@ -227,2 +253,14 @@ namespace DesertPaintCodex.Models
 

	
 
        private bool ExtrapolateWhiteFromOneChannel(int result, int clipBound, int reaction)
 
        {
 
            if (result == clipBound) return false;
 
            
 
            Clipped  = ClipType.None;
 
            Reaction = new Reaction(reaction, reaction, reaction);
 
            BadReaction = null;
 
            State    = TestState.GoodResult;
 
            return true;
 
        }
 

	
 

	
 
        public void CancelScan()
0 comments (0 inline, 0 general)