public (int, int, double) ClosestColorPalettePositionWithDistance(BrickadiaColor color, ColorSpaceSetting colorSpace)
        {
            int    x             = -1;
            int    y             = -1;
            double colorDistance = double.MaxValue;

            for (int colx = 0; colx < Colors.Count; colx++)
            {
                for (int coly = 0; coly < Colors[colx].Count; coly++)
                {
                    BrickadiaColor bColor   = Colors[colx][coly];
                    double         distance = double.MaxValue;

                    switch (colorSpace)
                    {
                    case ColorSpaceSetting.sRGB:
                        distance = color.DistanceSrgb(bColor);
                        break;

                    case ColorSpaceSetting.Oklab:
                        distance = color.DistanceOklab(bColor);
                        break;
                    }

                    if (distance < colorDistance)
                    {
                        x             = colx;
                        y             = coly;
                        colorDistance = distance;
                    }
                }
            }

            return(x, y, colorDistance);
        }
        public BrickadiaColor ClosestColor(BrickadiaColor color, ColorSpaceSetting colorSpace)
        {
            BrickadiaColor nearColor     = default;
            double         colorDistance = double.MaxValue;

            for (int x = 0; x < Colors.Count; x++)
            {
                for (int y = 0; y < Colors[x].Count; y++)
                {
                    BrickadiaColor bColor   = Colors[x][y];
                    double         distance = double.MaxValue;

                    switch (colorSpace)
                    {
                    case ColorSpaceSetting.sRGB:
                        distance = color.DistanceSrgb(bColor);
                        break;

                    case ColorSpaceSetting.Oklab:
                        distance = color.DistanceOklab(bColor);
                        break;
                    }

                    if (distance < colorDistance)
                    {
                        nearColor     = bColor;
                        colorDistance = distance;
                    }
                }
            }

            return(nearColor);
        }
        public double DistanceOklab(BrickadiaColor other)
        {
            var(aa, ab, ac) = ToOklab();
            var(ba, bb, bc) = other.ToOklab();
            var adiff = ba - aa;
            var bdiff = bb - ab;
            var cdiff = bc - ac;

            return(Math.Sqrt(adiff * adiff + bdiff * bdiff + cdiff * cdiff));
        }
 public (int, int) ClosestColorPalettePosition(BrickadiaColor color, ColorSpaceSetting colorSpace)
 {
     (int x, int y, double _) = ClosestColorPalettePositionWithDistance(color, colorSpace);
     return(x, y);
 }