diff options
-rw-r--r-- | sprites.py | 18 | ||||
-rw-r--r-- | tawindow.py | 4 |
2 files changed, 15 insertions, 7 deletions
@@ -323,15 +323,21 @@ class Sprite: return((self._width-self._margins[0]-self._margins[2], self._width-self._margins[1]-self._margins[3])) - def get_pixel(self, image, x, y): + def get_pixel(self, pos): + x, y = pos + x = x-self._x + y = y-self._y + if y > self.image.get_height()-1: + return (-1,-1,-1,-1) try: - array = image.get_pixels() + array = self.image.get_pixels() if array is not None: - offset = (y*image.get_width()+x)*4 + offset = (y*self.image.get_width()+x)*4 r,g,b,a = ord(array[offset]), ord(array[offset+1]),\ ord(array[offset+2]), ord(array[offset+3]) - return (a<<24)+(b<<16)+(g<<8)+r - return 0 + return (r,g,b,a) + else: + return (-1,-1,-1,-1) except IndexError: print "Index Error: %d %d" % (len(array), offset) - return 0 + return (-1,-1,-1,-1) diff --git a/tawindow.py b/tawindow.py index 7ab79e0..8c15123 100644 --- a/tawindow.py +++ b/tawindow.py @@ -838,7 +838,9 @@ class TurtleArtWindow(): elif spr.type == 'selector': self._select_category(spr) elif spr.type == 'category': - pass + r,g,b,a = spr.get_pixel((x, y)) + if (r == 255 and g == 0) or g == 255: + self._hide_palette() """ Block pressed |