X-Git-Url: https://scm.cri.ensmp.fr/git/minwii.git/blobdiff_plain/ab079c6f8baf25c115b6b2fb2ef2bfe4a1c4a6fc..46f3ffd7fdde386f41020171b5733e55a8e64a85:/src/app/widgets/playingscreen.py diff --git a/src/app/widgets/playingscreen.py b/src/app/widgets/playingscreen.py deleted file mode 100755 index 0e78285..0000000 --- a/src/app/widgets/playingscreen.py +++ /dev/null @@ -1,97 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Écran de jeu MinWii : -bandes arc-en-ciel représentant un clavier. - -$Id$ -$URL$ -""" -import pygame -from colorsys import hls_to_rgb -from gradients import gradients -# TODO : positionner cette constance en fonction de la résolution d'affichage -# externaliser la conf. -BORDER = 5 # 5px -FIRST_HUE = 0.6 -OFF_LUMINANCE = 0.1 -OFF_SATURATION = 1 -ON_TOP_LUMINANCE = 0.9 -ON_BOTTOM_LUMINANCE = 0.6 -ON_SATURATION = 1 - -class _PlayingScreenBase(object) : - def __init__(self, distinctNotes=[]) : - """ - distinctNotes : notes disctinctes présentes dans la chanson - triées du plus grave au plus aigu. - """ - self.distinctNotes = distinctNotes - self.keyboardLength = 0 - self.keyboardRects = [] - self._initRects() - self.drawColumns() - - - def _initRects(self) : - """ création des espaces réservés pour - afficher les colonnes. - """ - ambitus = self.distinctNotes[-1].midi - self.distinctNotes[0].midi - if ambitus <= 12 : - self.keyboardLength = 8 - else : - self.keyboardLength = 11 - - screen = pygame.display.get_surface() - - # taille de la zone d'affichage utile (bordure autour) - dispWidth = screen.get_width() - 2 * BORDER - dispHeight = screen.get_height() - 2 * BORDER - - columnWidth = int(round(float(dispWidth) / keyboardLength)) - - rects = [] - for i in range(keyboardLength) : - upperLeftCorner = (i*columnWidth + BORDER, BORDER) - rect = pygame.Rect(upperLeftCorner, (columnWidth, dispHeight)) - rects.append(rect) - - self.keyboardRects = rects - - def _initColumns(self) : - - hueStep = FIRST_HUE / (self.keyboardLength - 1) - for i, rect in enumerate(self.keyboardRects) : - hue = FIRST_HUE - hueStep * i - c = Column(hue) - - - def drawColumns(self) : - pass - - def highLightColumn(self) : - pass - - -class SongPlayingScreen(_PlayingScreenBase) : - - def __init__(self, song) : - super(SongPlayingScreen, self).__init__(song.) - self.song = song - - - -class Column(pygame.sprite.Sprite) : - - def __init__(self, hue, rect) : - pygame.sprite.Sprite.__init__(self) - sur = Surface(rect.size) - rgba = hls_to_rgb(hue, OFF_LUMINANCE, OFF_SATURATION) + (255,) - sur.fill(rgba) - self.stateOff = sur - - topRgba = hls_to_rgb(hue, ON_TOP_LUMINANCE, ON_SATURATION) + (255,) - bottomRgba = hls_to_rgb(hue, ON_BOTTOM_LUMINANCE, ON_SATURATION) + (255,) - size = rect.inflate(2*rect.width,0).size - self.stateOn = gradients.vertical(size, topRgba, bottomRgba) - \ No newline at end of file