Changeset 1084

Show
Ignore:
Timestamp:
10/31/08 10:09:46 (2 months ago)
Author:
bhimebau
Message:

changed the visualizer's color scheme where there is a transiton from blue (low voltage) to red (high voltage)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • analog/pyeac/branches/pyeac_pygame/visualizer.py

    r1082 r1084  
    1111    def __init__(self, fill_color=(100,0,0)): 
    1212        self.fill_color = fill_color 
     13        self.palette = self.createpalette() 
    1314        self.surface = pygame.Surface((300,300)) 
    1415        fill_window = Rect((0,0),(60,60)) 
     
    3132            for x in range(5): 
    3233                if self.fill_color[2]==0: 
    33                     cdata = (int((vdata[y][x]/5.0)*255),0,0) 
     34                    cdata = self.palette[int((vdata[y][x]/5.0)*255)] 
    3435                else: 
    35                     cdata = (0,0,int((vdata[y][x]/5.0)*255))         
     36                    cdata = self.palette[int((vdata[y][x]/5.0)*255)] 
    3637                self.set_block((x,y),cdata) 
    3738         
     39    def createpalette(self): 
     40        r,g,b = -1,0,256 
     41        palette = [] 
     42        for i in xrange(0,256): 
     43            r += 1 
     44            b -= 1 
     45            palette.append( (r,g,b) ) 
     46        return palette     
     47 
     48 
    3849__version__ = "0.0.1" 
    3950__copyright__ = "Copyright (c) 2008 Bryce Himebaugh and The Trustees of Indiana University. All rights reserved. Additional copyrights may follow."