From bc6ec37e87d81367f97157dfd3366f4938c8af00 Mon Sep 17 00:00:00 2001 From: Walter Bender Date: Thu, 12 Aug 2010 22:41:29 +0000 Subject: Turtle 'sees' --- (limited to 'TurtleArt/talogo.py') diff --git a/TurtleArt/talogo.py b/TurtleArt/talogo.py index 84da6d3..5f2a6d5 100644 --- a/TurtleArt/talogo.py +++ b/TurtleArt/talogo.py @@ -324,6 +324,7 @@ class LogoCode: 'savepix':[1, lambda self, x: self.save_picture(x)], 'savesvg':[1, lambda self, x: self.save_svg(x)], 'scale':[0, lambda self: self.scale], + 'see':[0, lambda self: self.see()], 'setcolor':[1, lambda self, x: self.tw.canvas.setcolor(x)], 'setgray':[1, lambda self, x: self.tw.canvas.setgray(x)], 'seth':[1, lambda self, x: self.tw.canvas.seth(x)], @@ -1171,6 +1172,12 @@ class LogoCode: self.tw.canvas.draw_text(text, int(x), int(y), self.body_height, int(w)) + def see(self): + """ Read r, g, b from the canvas and return a corresponding palette + color """ + r, g, b, a = self.tw.canvas.get_pixel() + return self.tw.canvas.get_color_index(r, g, b) + def read_pixel(self): """ Read r, g, b, a from the canvas and push b, g, r to the stack """ r, g, b, a = self.tw.canvas.get_pixel() -- cgit v0.9.1