Mercurial > boomslang
comparison pyntnclick/resources.py @ 593:1eb1537173ef pyntnclick
Add some image transforms.
author | Jeremy Thurgood <firxen@gmail.com> |
---|---|
date | Sat, 11 Feb 2012 17:41:35 +0200 |
parents | 4117d7b201a4 |
children | 38f75cef86d0 |
comparison
equal
deleted
inserted
replaced
592:4e9178215e75 | 593:1eb1537173ef |
---|---|
64 The `image_name_fragments` parameter may be either a string or a list | 64 The `image_name_fragments` parameter may be either a string or a list |
65 of strings. The latter is a convenience for things that compose an | 65 of strings. The latter is a convenience for things that compose an |
66 image name out of several fragments. | 66 image name out of several fragments. |
67 | 67 |
68 The `transforms` param may contain transforms, which modify an image | 68 The `transforms` param may contain transforms, which modify an image |
69 in-place to apply various effects. TODO: Implement transforms | 69 in-place to apply various effects. |
70 somewhere, so this becomes useful. | |
71 | 70 |
72 The `basedir` param defaults to 'images', but may be overriden to load | 71 The `basedir` param defaults to 'images', but may be overriden to load |
73 images from other places. ('icons', for example.) | 72 images from other places. ('icons', for example.) |
74 """ | 73 """ |
75 | 74 |
88 if self.CONVERT_ALPHA: | 87 if self.CONVERT_ALPHA: |
89 image = image.convert_alpha(pygame.display.get_surface()) | 88 image = image.convert_alpha(pygame.display.get_surface()) |
90 self._image_cache[image_path] = image | 89 self._image_cache[image_path] = image |
91 image = self._image_cache[image_path] | 90 image = self._image_cache[image_path] |
92 | 91 |
93 # Apply any mutators we're given. | 92 # Apply any transforms we're given. |
94 for transform in transforms: | 93 for transform in transforms: |
95 image = transform(image) | 94 image = transform(image) |
96 self._transformed_image_cache[key] = image | 95 self._transformed_image_cache[key] = image |
97 | 96 |
98 return image | 97 return image |