예제 #1
0
def createButton(self):
    but = self.links[0]
    
    #generate colors
    color = but.color
    colorBot = util.multColor(color,0.5)
    colorRig = util.multColor(color,0.8)
    #make surface
    surf = None
    if but.backColor:
        surf = pygame.Surface( but.size )
        surf.fill( but.backColor )
    else:
        surf = pygame.Surface( but.size , SRCALPHA )
    #add polygons
    pygame.draw.polygon( surf, color   , but.middle )
    pygame.draw.polygon( surf, colorBot, but.bottom )
    pygame.draw.polygon( surf, colorRig, but.right  )
    #add text
    difX = but.inW - g.tManager.get(but.textSurf).surf.get_width()
    difY = but.inH - g.tManager.get(but.textSurf).surf.get_height()
    g.tManager.blit( surf , but.textSurf , (difX / 2 , difY / 2) )
    self.surf = surf
예제 #2
0
 def makeSurf(self,iterVoid = 1.0):
     outSize = self.size * 1.25
     size = self.size
     
     self.offset = -self.size*3/4
     
     self.middle = [ (0,0)    , (size,0)    , (size,size)       , (0,size)]
     self.bottom = [ (0,size) , (size,size) , (outSize,outSize) , (outSize-size,outSize)]
     self.right  = [ (size,0) , (size,size) , (outSize,outSize) , (outSize,outSize-size)]
     
     self.surf = pygame.Surface( (outSize,outSize) , SRCALPHA )
     pygame.draw.polygon( self.surf ,                self.color      , self.middle )
     pygame.draw.polygon( self.surf , util.multColor(self.color,0.5) , self.bottom )
     pygame.draw.polygon( self.surf , util.multColor(self.color,0.8) , self.right )
     
     if iterVoid != 1.0 and iterVoid != 0.0 :
         #make the box disapear in darkness
         self.surf.lock()
         for x in range(int(outSize)):
             for y in range(int(outSize)):
                 r,g,b,a = self.surf.get_at( (x,y) )
                 self.surf.set_at( (x,y) , (r,g,b,a*iterVoid) )
         self.surf.unlock()