Mercurial > boomslang
comparison pyntnclick/tools/rect_drawer.py @ 690:4a933444c99b pyntnclick
The return of the rects to the rect drawer
author | Neil Muller <neil@dip.sun.ac.za> |
---|---|
date | Tue, 14 Feb 2012 12:24:33 +0200 |
parents | 929b63589c96 |
children | 60bf20849231 |
comparison
equal
deleted
inserted
replaced
689:929b63589c96 | 690:4a933444c99b |
---|---|
1 # Quickly hacked together helper for working out | 1 # Quickly hacked together helper for working out |
2 # interactive regions in Suspended Sentence | 2 # interactive regions in Suspended Sentence |
3 | |
4 def frame_rect(*args): | |
5 pass | |
6 | 3 |
7 Image = object | 4 Image = object |
8 request_old_filename = None | 5 request_old_filename = None |
9 | 6 |
10 from pygame.locals import (K_LEFT, K_RIGHT, K_UP, K_DOWN, | 7 from pygame.locals import (K_LEFT, K_RIGHT, K_UP, K_DOWN, |
15 import pygame | 12 import pygame |
16 | 13 |
17 import pyntnclick.constants | 14 import pyntnclick.constants |
18 from pyntnclick.widgets.text import LabelWidget, TextButton | 15 from pyntnclick.widgets.text import LabelWidget, TextButton |
19 from pyntnclick.widgets.base import Container | 16 from pyntnclick.widgets.base import Container |
17 from pyntnclick.tools.utils import draw_rect_image | |
20 | 18 |
21 | 19 |
22 class RectDrawerConstants(pyntnclick.constants.GameConstants): | 20 class RectDrawerConstants(pyntnclick.constants.GameConstants): |
23 debug = True | 21 debug = True |
24 menu_width = 200 | 22 menu_width = 200 |
101 else: | 99 else: |
102 self.offset = (-self.state.current_scene.OFFSET[0], | 100 self.offset = (-self.state.current_scene.OFFSET[0], |
103 -self.state.current_scene.OFFSET[1]) | 101 -self.state.current_scene.OFFSET[1]) |
104 self.find_existing_intersects() | 102 self.find_existing_intersects() |
105 self.add_callback(MOUSEBUTTONDOWN, self.mouse_down) | 103 self.add_callback(MOUSEBUTTONDOWN, self.mouse_down) |
106 self.add_callback(MOUSEBUTTONUP, self.mouse_down) | 104 self.add_callback(MOUSEBUTTONUP, self.mouse_up) |
107 self.add_callback(MOUSEMOTION, self.mouse_move) | 105 self.add_callback(MOUSEMOTION, self.mouse_move) |
108 | 106 |
109 def _get_scene(self): | 107 def _get_scene(self): |
110 if self.state.current_detail: | 108 if self.state.current_detail: |
111 return self.state.current_detail | 109 return self.state.current_detail |
275 if self.mode == 'draw' and self.start_pos and self.draw_rects: | 273 if self.mode == 'draw' and self.start_pos and self.draw_rects: |
276 rect = pygame.rect.Rect(self.start_pos[0], self.start_pos[1], | 274 rect = pygame.rect.Rect(self.start_pos[0], self.start_pos[1], |
277 self.end_pos[0] - self.start_pos[0], | 275 self.end_pos[0] - self.start_pos[0], |
278 self.end_pos[1] - self.start_pos[1]) | 276 self.end_pos[1] - self.start_pos[1]) |
279 rect.normalize() | 277 rect.normalize() |
280 frame_rect(surface, self.rect_color, rect, self.draw_thick) | 278 draw_rect_image(surface, self.rect_color, rect, self.draw_thick) |
281 if self.draw_rects: | 279 if self.draw_rects: |
282 for (col, rect) in self.rects: | 280 for (col, rect) in self.rects: |
283 frame_rect(surface, col, rect, self.rect_thick) | 281 draw_rect_image(surface, col, rect, self.rect_thick) |
284 if self.draw_images: | 282 if self.draw_images: |
285 for image in self.images: | 283 for image in self.images: |
286 if image.rect.colliderect(surface.get_rect()): | 284 if image.rect.colliderect(surface.get_rect()): |
287 cropped_rect = image.rect.clip(surface.get_rect()) | 285 cropped_rect = image.rect.clip(surface.get_rect()) |
288 self.draw_sub_image(image, surface, cropped_rect) | 286 self.draw_sub_image(image, surface, cropped_rect) |