示例#1
0
    public KeyValuePair <T, Color> GetClosest(Color32 c, ColorMatchMethod m)
    {
        Beri.Drawing.Color beriCol = c.ToBeriColor();
        int index = beriCol.GetColorMatch(ColorOnlyPallete, m);

        return(Pallette.ElementAt(index));
    }
示例#2
0
    public List <KeyValuePair <Item, Color> > TextureToFlowers(Texture2D texture, int size, ColorMatchMethod m)
    {
        int       count       = size * size;
        Texture2D internalImg = MapGraphicGenerator.Resize(texture, size, size);

        internalImg = MapGraphicGenerator.FlipTexture(internalImg);
        var colors = internalImg.GetPixels32();
        var toRet  = new List <KeyValuePair <Item, Color> >();

        for (int i = 0; i < count; ++i)
        {
            Color32 currentCol = colors[i];
            if (currentCol.a > 50)
            {
                var c = ItemColorSolver.GetClosest(currentCol, m);
                toRet.Add(new KeyValuePair <Item, Color>(c.Key, c.Value));
            }
            else
            {
                toRet.Add(new KeyValuePair <Item, Color>(new Item(Item.NONE), new Color()));
            }
        }

        return(toRet);
    }
示例#3
0
    public List <KeyValuePair <Item, Color> > TextureToFlowers(byte[] texture, int size, ColorMatchMethod m)
    {
        try
        {
            Texture2D t2d = new Texture2D(1, 1);
            t2d.LoadImage(texture);
            if (t2d.width < 2)
            {
                throw new Exception("Specified image is not valid.");
            }
            return(TextureToFlowers(t2d, size, m));
        }
        catch (Exception e)
        {
            PopupHelper.CreateError(e.Message, 3f, false);
        }

        return(null);
    }
示例#4
0
    /// <returns>index</returns>
    public static int GetColorMatch(this Color col, IReadOnlyCollection <Color> colors, ColorMatchMethod method)
    {
        switch (method)
        {
        case ColorMatchMethod.Hues: return(ClosestColor1(colors, col));

        case ColorMatchMethod.Distance: return(ClosestColor2(colors, col));

        case ColorMatchMethod.Weight: return(ClosestColor3(colors, col));

        default: return(ClosestColor2(colors, col));
        }
    }