mirror of
https://github.com/Febbweiss/mopidy-touchscreen.git
synced 2026-03-04 22:25:39 +00:00
Background image
This commit is contained in:
@@ -1,10 +1,13 @@
|
||||
import random
|
||||
|
||||
import pygame
|
||||
|
||||
class DynamicBackground():
|
||||
def __init__(self):
|
||||
def __init__(self, size):
|
||||
self.size = size
|
||||
self.current = get_valid_color()
|
||||
self.target = get_valid_color()
|
||||
self.surface = None
|
||||
|
||||
def draw_background(self, surface):
|
||||
same = True
|
||||
@@ -18,9 +21,18 @@ class DynamicBackground():
|
||||
#if same:
|
||||
# self.target = get_valid_color()
|
||||
surface.fill(self.current)
|
||||
if self.surface is not None:
|
||||
surface.blit(self.surface,(0,0))
|
||||
|
||||
def set_target_color(self, color):
|
||||
def set_target_color(self, color, surface):
|
||||
self.target = [color[0], color[1], color[2]]
|
||||
#irudi = pygame.Surface(surface.get_size())
|
||||
#pygame.transform.laplacian(surface, irudi)
|
||||
irudi = surface
|
||||
target = pygame.Surface(self.size)
|
||||
pygame.transform.smoothscale(irudi, self.size, target)
|
||||
target.set_alpha(80)
|
||||
self.surface = target
|
||||
|
||||
|
||||
# Returns an array with 3 integers in range of 0-255
|
||||
|
||||
@@ -278,7 +278,7 @@ class MainScreen(BaseScreen):
|
||||
self.get_cover_folder() +
|
||||
self.get_image_file_name()).convert(),
|
||||
(size, size))
|
||||
self.background.set_target_color(pygame.transform.average_color(image))
|
||||
self.background.set_target_color(pygame.transform.average_color(image), image)
|
||||
self.image = image
|
||||
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ class ScreenManager():
|
||||
self.size = size
|
||||
self.core = core
|
||||
self.fonts = {}
|
||||
self.background = DynamicBackground()
|
||||
self.background = DynamicBackground(self.size)
|
||||
self.current_screen = 0
|
||||
self.base_size = self.size[1] / 8
|
||||
font = resource_filename(
|
||||
|
||||
Reference in New Issue
Block a user