Пример #1
0
    public void PrepareCopy(byte[] pixels)
    {
        Color32 paintColor = this.paintEngine.paintColor;

        this.paintEngine.paintColor = Color.black;
        ChopFillAlgorithm.FindAndFillId(this.paintEngine, pixels, short.MaxValue);
        this.paintEngine.paintColor = paintColor;
    }
Пример #2
0
    public void Create(Texture2D l, PaletteData p, bool writeData = true)
    {
        this.paletteData = p;
        this.lineTex     = l;
        Color[] pixels = this.lineTex.GetPixels();
        short[] array  = new short[pixels.Length];
        this.paintEngine           = new ChopMobilePaint();
        this.paintEngine.pixels    = new byte[this.lineTex.width * this.lineTex.height * 4];
        this.paintEngine.texHeight = this.lineTex.height;
        this.paintEngine.texWidth  = this.lineTex.width;
        this.paintEngine.source    = array;
        this.paintEngine.zones     = new List <List <int> >();
        this.drawText            = new Texture2D(this.lineTex.width, this.lineTex.height, TextureFormat.RGBA32, false);
        this.drawText.filterMode = FilterMode.Bilinear;
        this.drawText.wrapMode   = TextureWrapMode.Clamp;
        for (int i = 0; i < pixels.Length; i++)
        {
            if (pixels[i].a >= 0.99f)
            {
                array[i] = short.MaxValue;
            }
            else
            {
                array[i] = this.emptyPixelTag;
            }
        }
        this.paintEngine.paintColor = Color.black;
        ChopFillAlgorithm.FindAndFillId(this.paintEngine, this.paintEngine.pixels, short.MaxValue);
        if (writeData)
        {
            this.drawText.LoadRawTextureData(this.paintEngine.pixels);
            this.drawText.Apply();
        }
        PaletteData paletteData = p;
        short       num         = 0;

        for (int j = 0; j < paletteData.entities.Length; j++)
        {
            for (int k = 0; k < paletteData.entities[j].indexes.Length; k++)
            {
                Point      point = this.paintEngine.TextureArrayIndexToMatrix(paletteData.entities[j].indexes[k]);
                List <int> list  = ChopFillAlgorithm.MarkArea(point.j, point.i, this.paintEngine, this.emptyPixelTag, num);
                if (list != null && list.Count > 0)
                {
                    this.paintedMap.Add(false);
                    this.colorMap.Add(j);
                    this.paintEngine.zones.Add(list);
                    num += 1;
                }
                else
                {
                    UnityEngine.Debug.Log("Error marking area");
                }
            }
        }
    }