Пример #1
0
        public void TestMaxRectsPackWithoutRotation()
        {
            var maxRectPacker = new MaxRectanglesBinPack();
            maxRectPacker.Initialize(100, 100, false);

            // This data set remain only 1 rectangle that cant be packed
            var elementToPack = new List<AtlasTextureElement>
            {
                CreateElement(null, 80, 100),
                CreateElement(null, 100, 20),
            };

            maxRectPacker.PackRectangles(elementToPack);

            Assert.AreEqual(1, elementToPack.Count);
            Assert.AreEqual(1, maxRectPacker.PackedElements.Count);
        }
Пример #2
0
        public void TestMaxRectsPackWithRotation()
        {
            var maxRectPacker = new MaxRectanglesBinPack();
            maxRectPacker.Initialize(100, 100, true);

            // This data set remain only 1 rectangle that cant be packed
            var packRectangles = new List<AtlasTextureElement>
            {
                CreateElement("A", 80, 100),
                CreateElement("B", 100, 20),
            };

            maxRectPacker.PackRectangles(packRectangles);

            Assert.AreEqual(0, packRectangles.Count);
            Assert.AreEqual(2, maxRectPacker.PackedElements.Count);
            Assert.IsTrue(maxRectPacker.PackedElements.Find(e => e.Name == "B").DestinationRegion.IsRotated);
        }
Пример #3
0
        public void TestMaxRectsPackArbitaryRectangles()
        {
            var maxRectPacker = new MaxRectanglesBinPack();
            maxRectPacker.Initialize(100, 100, true);

            // This data set remain only 1 rectangle that cant be packed
            var packRectangles = new List<AtlasTextureElement>
            {
                CreateElement(null, 55, 70),
                CreateElement(null, 55, 30),
                CreateElement(null, 25, 30),
                CreateElement(null, 20, 30),
                CreateElement(null, 45, 30),
                CreateElement(null, 25, 40),
                CreateElement(null, 20, 40),
            };

            maxRectPacker.PackRectangles(packRectangles);

            Assert.AreEqual(1, packRectangles.Count);
            Assert.AreEqual(6, maxRectPacker.PackedElements.Count);
        }