From 5763de58f064b05c69d2a83494ad33be21cdc6e7 Mon Sep 17 00:00:00 2001 From: Tim Redfern Date: Sat, 5 May 2012 12:30:51 +0100 Subject: fixed serial bug --- layers.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'layers.py') diff --git a/layers.py b/layers.py index ceaef1e..603b60d 100644 --- a/layers.py +++ b/layers.py @@ -52,8 +52,8 @@ class indexlayer(layer): colour=-1 def setcoord(self,pos): result=None - #210 35 5 185 - c=self.image.getpixel(pos) + p=(min(max(int(pos[0]),0),self.image.size[0]-2),min(max(int(pos[1]),0),self.image.size[1]-2)) + c=self.image.getpixel(p) if c!=self.colour: self.colour=c print "indexlayer: new colour",c @@ -71,8 +71,8 @@ class scalelayer(layer): def setcommand(self,command): self.command=command def setcoord(self,pos): - px=int(pos[0]) - py=int(pos[1]) + px=min(max(int(pos[0]),0),self.image.size[0]-2) + py=min(max(int(pos[1]),0),self.image.size[1]-2) c=float(self.image.getpixel((px,py)))/255.0 c1=float(self.image.getpixel((px+1,py)))/255.0 c2=float(self.image.getpixel((px,py+1)))/255.0 -- cgit v1.2.3