Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWalter Bender <walter@walter-laptop.(none)>2010-01-29 22:14:15 (GMT)
committer Walter Bender <walter@walter-laptop.(none)>2010-01-29 22:14:15 (GMT)
commit259f968184d27a9f5fd3007f99a5d0ef525072aa (patch)
tree70d752835cc70dfbc0b5e71a936276056c223d8e
parent4f49bb9b466afa833be37bceecadb8f7b843d62e (diff)
palette hide button
-rw-r--r--sprites.py18
-rw-r--r--tawindow.py4
2 files changed, 15 insertions, 7 deletions
diff --git a/sprites.py b/sprites.py
index e6969cc..6d5c942 100644
--- a/sprites.py
+++ b/sprites.py
@@ -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