This commit is contained in:
Frank 2015-04-30 14:39:50 -04:00
parent 29c07c34e4
commit cc1127f45f
1 changed files with 15 additions and 2 deletions

View File

@ -3,7 +3,7 @@ from os.path import isfile, join
from sys import exc_info, stdout
from glob import glob
from pygame import Color, Rect, Surface
from pygame import Color, Rect, Surface, PixelArray
from pygame.image import load
from pygame.transform import flip
from pygame.locals import *
@ -305,7 +305,20 @@ class Fader(Surface):
self.blit(frame, (0, 0))
frame.set_alpha(sprite.alpha)
if not self.location.is_hidden():
self.blit_to_display(self, areas)
if frame.get_flags() & SRCALPHA:
ratio = self.get_alpha() / 255.0
pixels = PixelArray(frame.copy())
color = Color(0, 0, 0)
for x in xrange(len(pixels)):
for y in xrange(len(pixels[0])):
h, s, l, a = Color(*frame.unmap_rgb(pixels[x][y])).hsla
if a:
color.hsla = h, s, l, int(a * ratio)
pixels[x][y] = color
self.blit_to_display(pixels.make_surface(), areas)
del pixels
else:
self.blit_to_display(self, areas)
elif self.fade_remaining is None or self.get_alpha() >= sprite.alpha:
if self.fade_remaining >= 0:
self.update_alpha()