comparison tools/rect_drawer.py @ 181:f98bc17f5e67

Add attributes for drawing rects
author Neil Muller <neil@dip.sun.ac.za>
date Wed, 25 Aug 2010 15:34:52 +0200
parents 39f75faf16cb
children b63ecd5b9a45
comparison
equal deleted inserted replaced
180:6b3ccee6f3f9 181:f98bc17f5e67
57 57
58 58
59 59
60 class AppImage(Widget): 60 class AppImage(Widget):
61 61
62 rect_thick = 3
63 draw_thick = 1
64
62 def __init__(self, state): 65 def __init__(self, state):
63 self.state = state 66 self.state = state
64 super(AppImage, self).__init__(pygame.rect.Rect(0, 0, 800, 600)) 67 super(AppImage, self).__init__(pygame.rect.Rect(0, 0, 800, 600))
65 self.mode = 'draw' 68 self.mode = 'draw'
66 self.rects = [] 69 self.rects = []
81 self.state.draw(surface) 84 self.state.draw(surface)
82 if self.mode == 'draw' and self.start_pos: 85 if self.mode == 'draw' and self.start_pos:
83 rect = pygame.rect.Rect(self.start_pos[0], self.start_pos[1], 86 rect = pygame.rect.Rect(self.start_pos[0], self.start_pos[1],
84 self.end_pos[0] - self.start_pos[0], 87 self.end_pos[0] - self.start_pos[0],
85 self.end_pos[1] - self.start_pos[1]) 88 self.end_pos[1] - self.start_pos[1])
86 frame_rect(surface, self.draw_color, rect, 2) 89 frame_rect(surface, self.draw_color, rect, self.draw_thick)
87 for (col, rect) in self.rects: 90 for (col, rect) in self.rects:
88 frame_rect(surface, col, rect, 1) 91 frame_rect(surface, col, rect, self.rect_thick)
89 92
90 def _make_dict(self): 93 def _make_dict(self):
91 d = {} 94 d = {}
92 for col, rect in self.rects: 95 for col, rect in self.rects:
93 d.setdefault(col, []) 96 d.setdefault(col, [])