Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/TurtleArt/sprites.py
diff options
context:
space:
mode:
Diffstat (limited to 'TurtleArt/sprites.py')
-rw-r--r--TurtleArt/sprites.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/TurtleArt/sprites.py b/TurtleArt/sprites.py
index ace99c9..412e3bd 100644
--- a/TurtleArt/sprites.py
+++ b/TurtleArt/sprites.py
@@ -440,6 +440,18 @@ class Sprite:
y < 0 or y > (self.rect.height - 1):
return(-1, -1, -1, -1)
+ # create a new 1x1 cairo surface
+ cs = cairo.ImageSurface(cairo.FORMAT_RGB24, 1, 1);
+ cr = cairo.Context(cs)
+ cr.set_source_surface(self.cached_surfaces[i], -x, -y)
+ cr.rectangle(0,0,1,1)
+ cr.set_operator(cairo.OPERATOR_SOURCE)
+ cr.fill()
+ cs.flush() # ensure all writing is done
+ # Read the pixel
+ pixels = cs.get_data()
+ return (ord(pixels[0]), ord(pixels[1]), ord(pixels[2]), 0)
+ '''
# Map the cairo surface onto a pixmap
pixmap = gtk.gdk.Pixmap(None, self.rect.width, self.rect.height, 24)
cr = pixmap.cairo_create()
@@ -450,3 +462,4 @@ class Sprite:
return(int((pixel & 0xFF0000) >> 16),
int((pixel & 0x00FF00) >> 8),
int((pixel & 0x0000FF) >> 0), 0)
+ '''