Exemple #1
0
 private static void printTree(Node r, string spc)
 {
     if (r.child[0] != null)
     {
         TexPacker.printTree(r.child[0], spc + "  ");
     }
     if (r.child[1] != null)
     {
         TexPacker.printTree(r.child[1], spc + "  ");
     }
 }
Exemple #2
0
 private static void flattenTree(Node r, List <Image> putHere)
 {
     if (r.img != null)
     {
         r.img.x = r.pixRect.x;
         r.img.y = r.pixRect.y;
         putHere.Add(r.img);
     }
     if (r.child[0] != null)
     {
         TexPacker.flattenTree(r.child[0], putHere);
     }
     if (r.child[1] != null)
     {
         TexPacker.flattenTree(r.child[1], putHere);
     }
 }
Exemple #3
0
        public Image[] GetRects(Image[] imgsToAdd, int maxDimension, int padding, out int outW, out int outH)
        {
            ProbeResult probeResult = null;
            float       num         = 0f;
            int         num2        = 0;
            int         num3        = 0;

            for (int i = 0; i < imgsToAdd.Length; i++)
            {
                Image image = imgsToAdd[i];
                num += (float)(image.width * image.height);
                num2 = Mathf.Max(num2, image.width);
                num3 = Mathf.Max(num3, image.height);
            }
            int num4 = (int)Mathf.Sqrt(num);
            int num5 = num4;
            int num6 = num4;

            if (num2 > num4)
            {
                num5 = num2;
                num6 = Mathf.Max(Mathf.CeilToInt(num / (float)num2), num3);
            }
            if (num3 > num4)
            {
                num5 = Mathf.Max(Mathf.CeilToInt(num / (float)num3), num2);
                num6 = num3;
            }
            if (num5 == 0)
            {
                num5 = 1;
            }
            if (num6 == 0)
            {
                num6 = 1;
            }
            int num7 = (int)((float)num5 * 0.15f);
            int num8 = (int)((float)num6 * 0.15f);

            if (num7 == 0)
            {
            }
            if (num8 == 0)
            {
            }
            ProbeResult probeResult2 = new ProbeResult();

            if (this.Probe(imgsToAdd, maxDimension, maxDimension, num, maxDimension, probeResult2))
            {
                probeResult = probeResult2;
            }
            outW = 0;
            outH = 0;
            if (probeResult == null)
            {
                return(null);
            }
            outW = probeResult.width;
            outH = probeResult.height;
            List <Image> list = new List <Image>();

            TexPacker.flattenTree(probeResult.root, list);
            list.Sort(new TexPacker.ImgIDComparer());
            if (list.Count != imgsToAdd.Length)
            {
                LogSystem.LogWarning(new object[]
                {
                    "Result images not the same lentgh as source"
                });
            }
            return(list.ToArray());
        }