Ignore:
Timestamp:
Sep 7, 2013, 8:03:09 PM (7 years ago)
Author:
Stefano Rivera <stefano@…>
Branch:
default
rebase_source:
8e7b1799412b3374e05c95406aec0f073471ced7
Message:

Inventory

File:
1 edited

Legend:

Unmodified
Added
Removed
  • nagslang/mutators.py

    r519 r555  
    5858
    5959
     60class ImageCentre(Mutator):
     61    def __init__(self, size):
     62        super(ImageCentre, self).__init__(ImageCentre.centre, size)
     63
     64    @classmethod
     65    def centre(cls, image, size):
     66        if image.get_size() == size:
     67            return image
     68        surf = pygame.surface.Surface(size, pygame.locals.SRCALPHA, image)
     69        surf.blit(image, ((size[0] - image.get_width()) / 2,
     70                          (size[1] - image.get_height()) / 2))
     71        return surf
     72
     73
    6074def rotator(angle):
    6175    return Mutator(rotate, angle)
     76
     77
     78def scaler(size):
     79    return Mutator(scale, size)
    6280
    6381
Note: See TracChangeset for help on using the changeset viewer.