Exemplo n.º 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.Single(elementToPack);
            Assert.Single(maxRectPacker.PackedElements);
        }
Exemplo n.º 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.Empty(packRectangles);
            Assert.Equal(2, maxRectPacker.PackedElements.Count);
            Assert.True(maxRectPacker.PackedElements.Find(e => e.Name == "B").DestinationRegion.IsRotated);
        }
Exemplo n.º 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.Single(packRectangles);
            Assert.Equal(6, maxRectPacker.PackedElements.Count);
        }