diff --git a/albow/utils.py b/albow/utils.py index 477f7e8..54ab366 100644 --- a/albow/utils.py +++ b/albow/utils.py @@ -1,6 +1,7 @@ from pygame import draw, Surface from pygame.locals import SRCALPHA + def frame_rect(surface, color, rect, thick = 1): o = 1 surface.fill(color, (rect.left+o, rect.top, rect.width-o-o, thick)) @@ -8,6 +9,7 @@ def frame_rect(surface, color, rect, thick = 1): surface.fill(color, (rect.left, rect.top+o, thick, rect.height-o-o)) surface.fill(color, (rect.right - thick, rect.top+o, thick, rect.height-o-o)) + def blit_tinted(surface, image, pos, tint, src_rect = None): from Numeric import array, add, minimum from pygame.surfarray import array3d, pixels3d @@ -21,11 +23,13 @@ def blit_tinted(surface, image, pos, tint, src_rect = None): buf_rgb = None surface.blit(buf, pos) + def blit_in_rect(dst, src, frame, align = 'tl', margin = 0): r = src.get_rect() align_rect(r, frame, align, margin) dst.blit(src, r) + def align_rect(r, frame, align = 'tl', margin = 0): if 'l' in align: r.left = frame.left + margin @@ -40,5 +44,6 @@ def align_rect(r, frame, align = 'tl', margin = 0): else: r.centery = frame.centery + def brighten(rgb, factor): return [min(255, int(round(factor * c))) for c in rgb]