# HG changeset patch # User Neil Muller # Date 1329215073 -7200 # Node ID 4a933444c99b8437e6bf3aa5b22295cee3923ac9 # Parent 929b63589c9620c910d6cdca13894f9afa2e2aa0 The return of the rects to the rect drawer diff -r 929b63589c96 -r 4a933444c99b pyntnclick/tools/rect_drawer.py --- a/pyntnclick/tools/rect_drawer.py Mon Feb 13 18:24:08 2012 +0200 +++ b/pyntnclick/tools/rect_drawer.py Tue Feb 14 12:24:33 2012 +0200 @@ -1,9 +1,6 @@ # Quickly hacked together helper for working out # interactive regions in Suspended Sentence -def frame_rect(*args): - pass - Image = object request_old_filename = None @@ -17,6 +14,7 @@ import pyntnclick.constants from pyntnclick.widgets.text import LabelWidget, TextButton from pyntnclick.widgets.base import Container +from pyntnclick.tools.utils import draw_rect_image class RectDrawerConstants(pyntnclick.constants.GameConstants): @@ -103,7 +101,7 @@ -self.state.current_scene.OFFSET[1]) self.find_existing_intersects() self.add_callback(MOUSEBUTTONDOWN, self.mouse_down) - self.add_callback(MOUSEBUTTONUP, self.mouse_down) + self.add_callback(MOUSEBUTTONUP, self.mouse_up) self.add_callback(MOUSEMOTION, self.mouse_move) def _get_scene(self): @@ -277,10 +275,10 @@ self.end_pos[0] - self.start_pos[0], self.end_pos[1] - self.start_pos[1]) rect.normalize() - frame_rect(surface, self.rect_color, rect, self.draw_thick) + draw_rect_image(surface, self.rect_color, rect, self.draw_thick) if self.draw_rects: for (col, rect) in self.rects: - frame_rect(surface, col, rect, self.rect_thick) + draw_rect_image(surface, col, rect, self.rect_thick) if self.draw_images: for image in self.images: if image.rect.colliderect(surface.get_rect()): diff -r 929b63589c96 -r 4a933444c99b pyntnclick/tools/utils.py --- a/pyntnclick/tools/utils.py Mon Feb 13 18:24:08 2012 +0200 +++ b/pyntnclick/tools/utils.py Tue Feb 14 12:24:33 2012 +0200 @@ -10,3 +10,17 @@ print 'Available details are : ' for detail in state.detail_views: print ' ', detail + +def draw_rect_image(surface, color, rect, thickness): + """Draw a rectangle with lines thickness wide""" + # top + surface.fill(color, (rect.left, rect.top, rect.width, thickness)) + # bottom + surface.fill(color, (rect.left, rect.bottom - thickness, rect.width, + thickness)) + # left + surface.fill(color, (rect.left, rect.top, thickness, rect.height)) + # right + surface.fill(color, (rect.right - thickness, rect.top, thickness, + rect.height)) +