Files @ 40eaee10ae56
Branch filter:

Location: ATITD-Tools/Desert-Paint-Codex/Util/PixelColor.cs

Malkyne
First commit. New UI.
using System;
using System.Drawing;
using DesertPaintCodex.Services;

namespace DesertPaintCodex.Util
{
    public class PixelColor
    {
        private const int ColorTolerance = 3;
        
        public static bool IsMatch(Color colorA, Color colorB)
        {
            return ((Math.Abs(colorA.R - colorB.R) <= ColorTolerance) &&
                (Math.Abs(colorA.G - colorB.G) <= ColorTolerance) &&
                (Math.Abs(colorA.B - colorB.B) <= ColorTolerance));
        }

        public static bool IsDark(Color color)
        {
            return (color.R < 0x47) && (color.G < 0x47) && (color.B < 0x47);
        }

        public static bool IsPapyrus(Color color)
        {
            // red between 208 and 244
            // 240 and 255
            // green between 192 and 237
            // 223 and 250
            // blue between 145 and 205
            // 178 and 232
            //return ((r > 0xD0) && (g >= 0xC0) && (b >= 0x91)) &&
            //       ((r < 0xF4) && (g <= 0xED) && (b <= 0xCD));
            return ((color.R >= 0xD0) && (color.R <= 0xFF) && (color.G >= 0xC0) && (color.G <= 0xFA) && (color.B >= 0x91) && (color.B <= 0xE8));
        }

        public static bool IsRed(Color color)
        {
            return (color.R > 0x9F) && (color.G < 0x70) && (color.B < 0x70);
        }
        public static bool IsGreen(Color color)
        {
            return (color.R < 0x70) && (color.G > 0x9F) && (color.B < 0x70);
        }
        public static bool IsBlue(Color color)
        {
            return (color.R < 0x70) && (color.G < 0x70) && (color.B > 0x9F);
        }

    }
}