示例#1
0
    def add(self, img):
        '''Add an image to the atlas.

        This method will fail if the given image cannot be transferred
        directly to a texture (for example, if it is another texture).
        `SurfaceData` is the usual image type for this method.

        `AllocatorException` will be raised if there is no room in the atlas
        for the image.

        :Parameters:
            `img` : `AbstractSurface`
                The image to add.

        :rtype: `SurfaceRegion`
        :return: The region of the atlas containing the newly added image.
        '''

        x, y = self.allocator.alloc(img.width, img.height)
        draw.blit_into(self.surface, img, x, y)
        region = self.surface.get_region(x, y, img.width, img.height)
        return region
示例#2
0
文件: atlas.py 项目: kloptops/pyglame
    def add(self, img):
        '''Add an image to the atlas.

        This method will fail if the given image cannot be transferred
        directly to a texture (for example, if it is another texture).
        `SurfaceData` is the usual image type for this method.

        `AllocatorException` will be raised if there is no room in the atlas
        for the image.

        :Parameters:
            `img` : `AbstractSurface`
                The image to add.

        :rtype: `SurfaceRegion`
        :return: The region of the atlas containing the newly added image.
        '''

        x, y = self.allocator.alloc(img.width, img.height)
        draw.blit_into(self.surface, img, x, y)
        region = self.surface.get_region(x, y, img.width, img.height)
        return region
示例#3
0
 def blit_into(self, surface, x, y, area=None):
     draw.blit_into(self, surface, x, y, area)
示例#4
0
 def blit_into(self, surface, x, y, area=None):
     draw.blit_into(self, surface, x, y, area)