From: pin Date: Thu, 18 Feb 2010 14:23:42 +0000 (+0000) Subject: Implémentation de Column (en cours). X-Git-Url: https://scm.cri.mines-paristech.fr/git/minwii.git/commitdiff_plain/ab079c6f8baf25c115b6b2fb2ef2bfe4a1c4a6fc?ds=inline;hp=2b9d34e4fd258c988ccb7796d918fdf40f4d9937 Implémentation de Column (en cours). git-svn-id: https://svn.cri.ensmp.fr/svn/minwii/trunk@40 fe552daf-6dbe-4428-90eb-1537e0879342 --- diff --git a/src/app/widgets/playingscreen.py b/src/app/widgets/playingscreen.py index f65d8e5..0e78285 100755 --- a/src/app/widgets/playingscreen.py +++ b/src/app/widgets/playingscreen.py @@ -7,8 +7,17 @@ $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=[]) : @@ -17,6 +26,7 @@ class _PlayingScreenBase(object) : triées du plus grave au plus aigu. """ self.distinctNotes = distinctNotes + self.keyboardLength = 0 self.keyboardRects = [] self._initRects() self.drawColumns() @@ -28,9 +38,9 @@ class _PlayingScreenBase(object) : """ ambitus = self.distinctNotes[-1].midi - self.distinctNotes[0].midi if ambitus <= 12 : - keyboardLength = 8 + self.keyboardLength = 8 else : - keyboardLength = 11 + self.keyboardLength = 11 screen = pygame.display.get_surface() @@ -47,6 +57,13 @@ class _PlayingScreenBase(object) : 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) : @@ -66,5 +83,15 @@ class SongPlayingScreen(_PlayingScreenBase) : class Column(pygame.sprite.Sprite) : - def __init__(self, color) : - pass \ No newline at end of file + 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