Features/GTK3/Porting: Difference between revisions
| Line 259: | Line 259: | ||
<pre> | <pre> | ||
# | # create a new 1x1 cairo surface | ||
cs = cairo.ImageSurface(cairo.FORMAT_RGB24, 1, 1); | |||
cr = cairo.Context(cs) | |||
# translate surface so that target pixel is at 0, 0 | |||
cr.set_source_surface(self.tw.turtle_canvas, -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 | # Read the pixel | ||
return (ord(pixels[2]), ord(pixels[1]), ord(pixels[0]), 0) | |||
return( | |||
</pre> | </pre> | ||