Example #1
0
 public static Color[,] Fill(this Color c, int w, int h)
 {
     Color[,] cs = new Color[w, h];
     for (int i = 0; i < w; ++i)
     {
         for (int j = 0; j < h; ++j)
         {
             cs[i, j] = c;
         }
     }
     return(cs);
 }
Example #2
0
    public static Color[,] GetBixels(this Texture2D t)
    {
        int w = t.width, h = t.height;

        Color[,] cs = new Color[w, h];
        for (int i = 0; i < w; ++i)
        {
            for (int j = 0; j < h; ++j)
            {
                cs[i, j] = (Color)t.GetPixel(i, h - j - 1); //c[i + j * w];
            }
        }
        return(cs);
    }
Example #3
0
    public static Texture2D ToTexture(this Color c)
    {
        Texture2D t = new Texture2D(1, 1);

        t.SetPixel(0, 0, c);
        t.Apply();
        if (assocColor.ContainsKey(c.ToString()))
        {
            return(assocColor[c.ToString()]);
        }
        else
        {
            assocColor.Add(c.ToString(), t);
            return(t);
        }
    }
Example #4
0
    public static IEnumerator Clone(this Color[,] c, int w, int h, int step, Action upt, Action <Color[, ]> f)
    {
        Color[,] nc = new Color[w, h];
        int k = 0;

        for (int i = 0; i < w; ++i)
        {
            for (int j = 0; j < h; ++j)
            {
                //Color cc = ((Color[])new Color[] { c[i, j] }.Clone())[0];
                nc[i, j] = (Color)c[i, j].Clone(); //new Color(cc.r, cc.g, cc.b);
                upt();
                ++k;
                if (k % step == 0)
                {
                    yield return(null);
                }
            }
        }
        f(nc);
    }
Example #5
0
 public static void UptPixel(this Texture2D t, Point p, Color c)
 {
     t.SetPixel(p.x, t.height - p.y - 1, c);
     t.Apply();
 }