コード例 #1
0
    def test_getChildSlotTotalAndBiasStart(self):
        layout = Layout((100, 100))
        self.assertEqual(0, layout._getChildSlotTotal())

        layout.addLayer(packingBias=3)
        self.assertEqual(3, layout._getChildSlotTotal())

        layout.addLayer(packingBias=3)
        self.assertEqual(6, layout._getChildSlotTotal())

        self.assertEqual(0, layout._getChildSlotStart(0))
        self.assertEqual(3, layout._getChildSlotStart(1))
コード例 #2
0
    def test_getChildSlotTotalAndBiasStart(self):
        layout = Layout((100, 100))
        self.assertEqual(0, layout._getChildSlotTotal())

        layout1 = layout.addLayer(packingMode='h')
        self.assertEqual(1, layout._getChildSlotTotal())
        self.assertEqual((100, 100), layout.size)
        self.assertEqual((100, 100), layout1.size)

        layout11 = layout1.addLayer()
        layout12 = layout1.addLayer()
        self.assertEqual((100, 100), layout.size)
        self.assertEqual((100, 100), layout1.size)
        self.assertEqual((50, 100), layout11.size)
        self.assertEqual((50, 100), layout12.size)

        layout2 = layout.addLayer(packingMode='v')
        self.assertEqual((100, 100), layout.size)
        self.assertEqual((50, 100), layout1.size)
        self.assertEqual((50, 100), layout2.size)
        self.assertEqual((25, 100), layout11.size)
        self.assertEqual((25, 100), layout12.size)

        layout21 = layout2.addLayer()
        layout22 = layout2.addLayer()

        self.assertEqual((100, 100), layout.size)
        self.assertEqual((50, 100), layout1.size)
        self.assertEqual((25, 100), layout11.size)
        self.assertEqual((25, 100), layout12.size)
        self.assertEqual((50, 100), layout2.size)
        self.assertEqual((50, 50), layout21.size)
        self.assertEqual((50, 50), layout22.size)
        layouts = (layout11, layout12, layout21, layout22)
        [
            self._setImage(layout, (0x40*index, 0xff, 0xff), str(layout._id))
            for index, layout in enumerate(layouts)
        ]
        self.writeImage(layout, "test-alternatePackingMode.png")