From f2b9ca14218c032b18c6483b5d73a96c5b4fe28c Mon Sep 17 00:00:00 2001 From: Neil Date: Wed, 7 Sep 2016 16:29:55 +0200 Subject: [PATCH] Avoid surface.copy for the cases where we blow away the contents --- tabakrolletjie/lights.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tabakrolletjie/lights.py b/tabakrolletjie/lights.py index 2c691fe..e47fa14 100644 --- a/tabakrolletjie/lights.py +++ b/tabakrolletjie/lights.py @@ -5,6 +5,7 @@ import pymunk import pymunk.pygame_util import pygame.display import pygame.draw +import pygame.locals as pgl from .constants import ( SCREEN_SIZE, LIGHT_CATEGORY, FITTINGS_CATEGORY) @@ -173,7 +174,7 @@ class BaseLight(object): if not self.on: return - raypoly_mask = surface.copy() + raypoly_mask = pygame.surface.Surface(surface.get_size(), pgl.SWSURFACE) white, black = (255, 255, 255, 255), (0, 0, 0, 0) raypoly_mask.fill(black) for shape in self.body.shapes: @@ -185,7 +186,7 @@ class BaseLight(object): pygame.draw.polygon(raypoly_mask, white, pygame_poly, 0) pygame.draw.aalines(raypoly_mask, white, True, pygame_poly, 1) - limits_mask = surface.copy() + limits_mask = pygame.surface.Surface(surface.get_size(), pgl.SWSURFACE) limits_mask.fill(black) centre = pymunk.pygame_util.to_pygame(self.position, surface) max_radius = self.radius_limits[1] or 50.0 @@ -204,12 +205,11 @@ class BaseLight(object): pygame.draw.arc( limits_mask, white, box3, start_angle, end_angle, int(width)) - import pygame.locals as pgl raypoly_mask.blit(limits_mask, (0, 0), None, pgl.BLEND_RGBA_MIN) raypoly_mask.set_colorkey(black) light_colour = self.COLOURS[self.colour] - overlay = surface.copy() + overlay = pygame.surface.Surface(surface.get_size(), pgl.SWSURFACE) overlay.fill(light_colour) raypoly_mask.blit(overlay, (0, 0), None, pgl.BLEND_RGBA_MULT) -- 2.34.1