From f347b44f44bccc674b0af02ce17feeaffe6f83c3 Mon Sep 17 00:00:00 2001 From: Adam Schreiber Date: Sat, 09 May 2009 13:08:47 +0000 Subject: Fix drawing of shapes out of window rect.x and rect.y when getting the allocation are given in window coordinates not in relation to the current drawing area. --- diff --git a/deka.py b/deka.py index 1d4daf5..3321514 100644 --- a/deka.py +++ b/deka.py @@ -46,20 +46,20 @@ class DrawShapesArea(gtk.DrawingArea): def draw (self, context): rect = self.get_allocation() context.set_source_rgba(0.0, 0.0, 0.0, 1.0) - context.move_to (rect.x+rect.width/6, rect.y) - context.line_to (rect.x+rect.width/6, rect.y + rect.height) + context.move_to (rect.width/6, 0) + context.line_to (rect.width/6, rect.height) - context.move_to (rect.x+2*rect.width/6, rect.y) - context.line_to (rect.x+2*rect.width/6, rect.y + rect.height) + context.move_to (2*rect.width/6, 0) + context.line_to (2*rect.width/6, rect.height) - context.move_to (rect.x+3*rect.width/6, rect.y) - context.line_to (rect.x+3*rect.width/6, rect.y + rect.height) + context.move_to (3*rect.width/6, 0) + context.line_to (3*rect.width/6, rect.height) - context.move_to (rect.x+4*rect.width/6, rect.y) - context.line_to (rect.x+4*rect.width/6, rect.y + rect.height) + context.move_to (4*rect.width/6, 0) + context.line_to (4*rect.width/6, rect.height) - context.move_to (rect.x+5*rect.width/6, rect.y) - context.line_to (rect.x+5*rect.width/6, rect.y + rect.height) + context.move_to (5*rect.width/6, 0) + context.line_to (5*rect.width/6, rect.height) context.stroke() @@ -70,8 +70,9 @@ class DrawShapesArea(gtk.DrawingArea): else: opacity = 0.25 - self.drawBar (context, rect.x + 5*rect.width/6 + n*rect.width/12, - rect.y + m*rect.height/6, rect.width/12, rect.height/6, opacity) + self.drawBar (context, 5*rect.width/6 + n*rect.width/12, + m*rect.height/6 + (rect.height - 5*rect.height/6)/2, + rect.width/12, rect.height/6, opacity) for m in range (0,5): for n in range (0,2): @@ -80,8 +81,9 @@ class DrawShapesArea(gtk.DrawingArea): else: opacity = 0.25 - self.drawCircle (context, rect.x + 4*rect.width/6 + n*rect.width/12, - rect.y + m*rect.height/6, rect.width/12, rect.height/6, opacity) + self.drawCircle (context, 4*rect.width/6 + n*rect.width/12, + m*rect.height/6 + (rect.height - 5*rect.height/6)/2, + rect.width/12, rect.height/6, opacity) for m in range (0,5): for n in range (0,2): @@ -89,10 +91,11 @@ class DrawShapesArea(gtk.DrawingArea): opacity = 1 else: opacity = 0.25 - - self.drawTriangle (context, rect.x + 3*rect.width/6 + n*rect.width/12, - rect.y + m*rect.height/6, rect.width/12, rect.height/6, opacity) - + + self.drawTriangle (context, 3*rect.width/6 + n*rect.width/12, + m*rect.height/6 + (rect.height - 5*rect.height/6)/2, + rect.width/12, rect.height/6, opacity) + for m in range (0,5): for n in range (0,2): if (((5-m) + ((n+1)%2)*5) <= self.thousands): @@ -100,8 +103,9 @@ class DrawShapesArea(gtk.DrawingArea): else: opacity = 0.25 - self.drawSquare (context, rect.x + 2*rect.width/6 + n*rect.width/12, - rect.y + m*rect.height/6, rect.width/12, rect.height/6, opacity) + self.drawSquare (context, + 2*rect.width/6 + n*rect.width/12, + m*rect.height/6 + (rect.height - 5*rect.height/6)/2, + rect.width/12, rect.height/6, opacity) for m in range (0,5): for n in range (0,2): @@ -110,8 +114,9 @@ class DrawShapesArea(gtk.DrawingArea): else: opacity = 0.25 - self.drawPentagon (context, rect.x + 1*rect.width/6 + n*rect.width/12, - rect.y + m*rect.height/6, rect.width/12, rect.height/6, opacity) + self.drawPentagon (context, + 1*rect.width/6 + n*rect.width/12, + m*rect.height/6 + (rect.height - 5*rect.height/6)/2, + rect.width/12, rect.height/6, opacity) for m in range (0,5): for n in range (0,2): if (((5-m) + ((n+1)%2)*5) <= self.hundredthousands): @@ -119,8 +124,9 @@ class DrawShapesArea(gtk.DrawingArea): else: opacity = 0.25 - self.drawHexagon (context, rect.x + 0*rect.width/6 + n*rect.width/12, - rect.y + m*rect.height/6, rect.width/12, rect.height/6, opacity) + self.drawHexagon (context, + 0*rect.width/6 + n*rect.width/12, + m*rect.height/6 + (rect.height - 5*rect.height/6)/2, + rect.width/12, rect.height/6, opacity) def set_count (self, count): val = int(count) -- cgit v0.9.1