Changeset - 8da5f6699d57
[Not reviewed]
default
0 1 0
Jason Maltzen - 3 years ago 2021-09-09 23:55:08
jason@hiddenachievement.com
Add constructor / setter to PaintColor to copy another paint color and assign a different name to it.
1 file changed with 16 insertions and 0 deletions:
0 comments (0 inline, 0 general)
Models/PaintColor.cs
Show inline comments
...
 
@@ -27,48 +27,64 @@ namespace DesertPaintCodex.Models
 
        public PaintColor(string name, string hexRed, string hexGreen, string hexBlue)
 
        {
 
            Name = name;
 
            Red =   byte.Parse(hexRed,   System.Globalization.NumberStyles.AllowHexSpecifier);
 
            Green = byte.Parse(hexGreen, System.Globalization.NumberStyles.AllowHexSpecifier);
 
            Blue =  byte.Parse(hexBlue,  System.Globalization.NumberStyles.AllowHexSpecifier);
 
        }
 

	
 
        public PaintColor(byte red, byte green, byte blue)
 
        {
 
            Name  = "Undefined";
 
            Red   = red;
 
            Green = green;
 
            Blue  = blue;
 
        }
 

	
 
        public PaintColor(PaintColor other)
 
        {
 
            Name  = other.Name;
 
            Red   = other.Red;
 
            Green = other.Green;
 
            Blue  = other.Blue;
 
        }
 

	
 
        public PaintColor(string name, PaintColor other)
 
        {
 
            Name  = name;
 
            Red   = other.Red;
 
            Green = other.Green;
 
            Blue  = other.Blue;
 
        }
 

	
 
        public void Set(string name, PaintColor other)
 
        {
 
            Name  = name;
 
            Red   = other.Red;
 
            Green = other.Green;
 
            Blue  = other.Blue;
 
        }
 

	
 
        public int GetDistanceSquared(PaintColor otherColor)
 
        {
 
            return (int)(Math.Pow(Red - otherColor.Red, 2) +
 
                Math.Pow(Green - otherColor.Green, 2) +
 
                Math.Pow(Blue - otherColor.Blue, 2));
 
        }
 

	
 
        public void Clear()
 
        {
 
            Red   = 0;
 
            Green = 0;
 
            Blue  = 0;
 
        }
 

	
 
        public void Set(PaintColor other)
 
        {
 
            Red   = other.Red;
 
            Green = other.Green;
 
            Blue  = other.Blue;
 
            Name  = other.Name;
 
        }
 

	
 
        public string ToHexString()
 
        {
0 comments (0 inline, 0 general)