prerender glow effect into logo background
This commit is contained in:
parent
e85d8ee74f
commit
d95b31a19b
50
NS.py
50
NS.py
|
@ -883,12 +883,12 @@ class Video(Sprite):
|
|||
gifs.append(Image.open(path))
|
||||
print(gifs[-1].info)
|
||||
self.gif_index = 0
|
||||
self.mask = Surface([diameter] * 2, SRCALPHA)
|
||||
rect = self.mask.get_rect()
|
||||
mask = Surface([diameter] * 2, SRCALPHA)
|
||||
rect = mask.get_rect()
|
||||
alpha = int(self.get_configuration("display", "attract-gif-alpha") * 255)
|
||||
filled_circle(self.mask, rect.centerx, rect.centery, rect.centerx, (0, 0, 0, alpha))
|
||||
filled_circle(self.mask, rect.centerx, rect.centery, rect.centerx - 2, (255, 255, 255, alpha))
|
||||
self.add_frame(self.mask)
|
||||
filled_circle(mask, rect.centerx, rect.centery, rect.centerx, (0, 0, 0, alpha))
|
||||
filled_circle(mask, rect.centerx, rect.centery, rect.centerx - 2, (255, 255, 255, alpha))
|
||||
self.add_frame(mask)
|
||||
if not self.get_configuration("system", "minimize-load-time"):
|
||||
self.play()
|
||||
# preload GIF frames scaled instead of loading each frame like before
|
||||
|
@ -899,8 +899,8 @@ class Video(Sprite):
|
|||
gif.seek(ii)
|
||||
frame_scaled = smoothscale(
|
||||
fromstring(gif.convert("RGBA").tobytes(), gif.size, "RGBA"),
|
||||
(self.mask.get_width(), int(gif.width * gif.height / self.mask.get_width())))
|
||||
copy = self.mask.copy()
|
||||
(mask.get_width(), int(gif.width * gif.height / mask.get_width())))
|
||||
copy = mask.copy()
|
||||
rect = frame_scaled.get_rect()
|
||||
rect.bottom = copy.get_rect().bottom
|
||||
copy.blit(frame_scaled, rect, None, BLEND_RGBA_MIN)
|
||||
|
@ -930,32 +930,26 @@ class Logo(Sprite):
|
|||
|
||||
def __init__(self, parent):
|
||||
"""
|
||||
Load the logo and add locations at regular offsets until the screen is covered to create a tile fill effect. Create a second
|
||||
Sprite that will display a glow effect that can be blended into the main layer.
|
||||
Load the logo and create a glowing version by creating multiple frames, each with a glow effect blended onto it.
|
||||
"""
|
||||
Sprite.__init__(self, parent)
|
||||
Sprite.__init__(self, parent, 60)
|
||||
dsr = self.get_display_surface().get_rect()
|
||||
self.load_from_path(self.get_resource("Title_tile.png"), True)
|
||||
mask = pygame.image.load(self.get_resource("Title_tile.png")).convert()
|
||||
palette = (255, 255, 255), (255, 255, 128), (255, 255, 0)
|
||||
thickness = 8
|
||||
for offset in range(len(palette)):
|
||||
tile = mask.copy()
|
||||
for x in range(0, dsr.w, thickness):
|
||||
tile.fill(palette[(offset + x) % len(palette)], (x, 0, thickness, dsr.h), pygame.BLEND_RGB_MIN)
|
||||
self.add_frame(tile)
|
||||
for y in range(0, dsr.h + self.location.h, self.location.h):
|
||||
for x in range(0, dsr.w + self.location.w, self.location.w):
|
||||
if x != 0 or y != 0:
|
||||
self.add_location((x, y))
|
||||
|
||||
# Create a screen sized Sprite to create a glowing animation drawn onto blank frames
|
||||
if self.get_configuration("display", "effects"):
|
||||
self.effect = Sprite(self, 100)
|
||||
palette = (255, 255, 255), (255, 255, 128), (255, 255, 0)
|
||||
thickness = 8
|
||||
for offset in range(len(palette)):
|
||||
frame = Surface(dsr.size)
|
||||
for x in range(0, dsr.w, thickness):
|
||||
frame.fill(palette[(offset + x) % len(palette)], (x, 0, thickness, dsr.h))
|
||||
self.effect.add_frame(frame)
|
||||
|
||||
def update(self):
|
||||
"""
|
||||
Scroll the tiles, wrapping at the edges of the screen. Draw the effect layer beneath the logo tile and blend with the logo
|
||||
if effects are on.
|
||||
Scroll the tiles, wrapping at the edges of the screen.
|
||||
"""
|
||||
# Wrap around motion effect
|
||||
self.move(-2, 2)
|
||||
|
@ -963,13 +957,7 @@ class Logo(Sprite):
|
|||
self.move(self.location.w)
|
||||
if self.location.top > 0:
|
||||
self.move(dy=-self.location.h)
|
||||
|
||||
# Blend with the effect layer if effects are on
|
||||
if self.get_configuration("display", "effects"):
|
||||
self.effect.update()
|
||||
Sprite.update(self, flags=BLEND_RGBA_MIN)
|
||||
else:
|
||||
Sprite.update(self)
|
||||
Sprite.update(self)
|
||||
|
||||
|
||||
class Title(Animation):
|
||||
|
|
Loading…
Reference in New Issue