コード例 #1
0
ファイル: text.py プロジェクト: ilathid/ilathidEngine
 def update(self, fileref = None, rect = None, visible = None, string = None, color = None, just = None, size = None, userlineheight = None):
     dirtyrect = None
     
     # Invalidate render
     self._texture = None
     
     #Update attributes
     if fileref != None:
         self._file = fileref
     if rect != None:
         if len(rect) == 4:
             self._rect = pygame.Rect(rect)
         else:
             self._rect = pygame.Rect(rect,(0,0))
     if visible != None:
         self._visible = visible
     if string  != None:
         self._string = string
     if color != None:
         self._color = color
     if just != None:
         self._just = just
     if size != None:
         self._size = size
     if userlineheight != None:
         self._userlineheight = userlineheight
     if self._file == None or self._rect == None:
         self._visible = 0
     #If the object is visible, redraw it
     if globals.isslidevisible(self._slide):
         if self._visible:
             #If any of these changed we need to reload the font
             if fileref or size:
                 self._font = globals.loadfont(self._file, self._size, self._datfile, self._encryption)
                 #If default line spacing is not overridden, get the default
                 if self._userlineheight != None:
                     self._lineheight = self._userlineheight
                 else:
                     self._lineheight = self._font.get_linesize()
                 #Clear the character table
                 self._chartable = None
                 #Clear the objects surface
                 self._objectsurface = None
             #If any of these changed we need to rerender the text, so clear the objects surface
             if string or rect or just or userlineheight or color:
                 self._objectsurface = None
             return
         else:
             #Image is not visible, so clear the buffers to save memory
             self._clearbuffers()
     else:
         #Image is not visible, so clear the buffers to save memory
         self._clearbuffers()
コード例 #2
0
ファイル: AoIimage.py プロジェクト: ilathid/ilathidEngine
    def render(self):
        if globals.isslidevisible(self._slide):
            #Load image if needed
            if self._objectsurface == None:
                self._objectsurface = globals.loadimage(self._file, isSlide = False)
            #Build destination rect
            self._rect.size = [self._objectsurface.getWidth(), self._objectsurface.getHeight()]
                       
            #If alpha, set color key
            # TODO: OpenGL vs alpha
            #if self._alpha != None:
            #    self._objectsurface.set_colorkey(self._objectsurface.get_at(self._alpha))

            if self._visible:
                #Draw image
                if self._ratio != None:
                    self._objectsurface.scaleDraw(self._rect.left, self._rect.top,self._ratio[0],self._ratio[1])
                else:
                    self._objectsurface.draw(self._rect.left, self._rect.top)
                return self._rect
コード例 #3
0
ファイル: AoIimage.py プロジェクト: ilathid/ilathidEngine
   def update(self, fileref = None, rect = None, visible = None, alpha = None, angle = None, ratio = None):
       dirtyrect = None
       
       # I know usually in Python you don't verify types but this will help detect problems during the current refactor.
       if fileref is not None and not isinstance(fileref, FilePath):
           raise Exception("fileref must be a FilePath object")
 
       #Update attributes
       if fileref != None:
           self._file = fileref
       if rect != None:
           if len(rect) == 4:
               self._rect = pygame.Rect(rect)
           else:
               self._rect = pygame.Rect(rect,(0,0))
       if visible != None:
           self._visible = visible
       if alpha != None:
           self._alpha = alpha
       if angle != None:
           self._angle = angle
       if ratio != None:
           self._ratio = ratio
       
       if self._file == None or self._rect == None:
           self._visible = 0
       #If Updated image is visible, clear everything above it's new area and redraw
       if globals.isslidevisible(self._slide):
           if self._visible:
               #load with new options if needed
               if fileref:
                   self._texture = globals.loadimage(self._file, isSlide = False)
                   self._rect.size = [self._objectsurface.getWidth(), self._objectsurface.getHeight()]
               return
           else:
               #Image is not visible, so clear it's buffers to save mem
               self._clearbuffers()
       else:
           #Image is not visible, so clear it's buffers to save mem
           self._clearbuffers()