コード例 #1
0
ファイル: tileImage2.py プロジェクト: rpwagner/tiled-display
 def __init__(self,
              imageFilename,
              screenRect,
              fullRect,
              absRect,
              initialOffset=(0, 0),
              zoom=(4, 4),
              imagePos=(0, 0),
              imageSize=None):
     self.hasDrawFunc = True
     self.hasEraseDrawFunc = True
     self.visible = True
     self.texture = Texture(imageFilename)
     #self.easyTexture = EasyTexture(imageFilename, screenGeomRect=screenRect, blend=False)
     #self.easyTexture.width = renderer.width * 0.8
     #self.easyTexture.height = renderer.height * 0.8
     #self.easyTexture.width = renderer.width
     #self.easyTexture.height = renderer.height
     self.useDrawPixel = False  # For comparison debugging
     self.xvel = 0.1
     self.yvel = 0.1
     self.zoom = zoom
     #self.easyTexture.zoom(zoom[0], zoom[1])
     #self.easyTexture.setOffset(initialOffset[0], initialOffset[1])
     self.autoPan = True
     self.imagePos = Vec2(imagePos[0], imagePos[1])
     if imageSize == None:
         self.imageSize = self.texture.getWidth(
         ), self.texture.getHeight()
     else:
         self.imageSize = imageSize
     self.fullRect = fullRect
     self.absRect = absRect
     self.screenRect = screenRect
コード例 #2
0
ファイル: glUtils.py プロジェクト: rpwagner/tiled-display
class glTxtrBox(BaseTileDisplayObject):
    # The bounds of this object are based on:
    #    pos, imageSize, and scale
    # Use getPos() and getSize() to get bounding rect
    def __init__(self, imageFilename, screenRect, fullRect, absRect, zoom=(4,4), imagePos=None, imageSize=None, blend=False, cropRect=None, scale=None):
        pos = imagePos # FIXME, replace imagePos arg above and its mention in other files with "pos"

        BaseTileDisplayObject.__init__(self, screenRect=screenRect, fullRect=fullRect, absRect=absRect, zoom=zoom, pos=pos, size=imageSize, blend=blend, cropRect=cropRect)

        self.hasDrawFunc=True
        self.hasEraseDrawFunc=True
        self.visible = True
        self.texture = Texture( imageFilename, cropRect=cropRect)
        #self.easyTexture = EasyTexture(imageFilename, screenGeomRect=screenRect, blend=False)
        #self.easyTexture.width = renderer.width * 0.8
        #self.easyTexture.height = renderer.height * 0.8
        #self.easyTexture.width = renderer.width
        #self.easyTexture.height = renderer.height
        self.useDrawPixel = False # For comparison debugging
        self.xvel = 0.1
        self.yvel = 0.1
        self.vflipTexture = False

        # Now in base class
        #self.blend=blend
        #self.zoom = zoom

        #self.easyTexture.zoom(zoom[0], zoom[1])
        #self.easyTexture.setOffset(initialOffset[0], initialOffset[1])
        self.autoPan = False

        if pos:
            self.pos = Vec2(pos[0], pos[1])
        else:
            self.pos = Vec2(0.0, 0.0)

        self.srcImageSize = self.texture.getWidth(), self.texture.getHeight()

        if imageSize == None:
            self.imageSize = self.texture.getWidth(), self.texture.getHeight()
        else:
            self.imageSize = imageSize

        self.scale = scale
        if self.scale != None:
            self.imageSize = self.imageSize[0] * self.scale[0], self.imageSize[1] * self.scale[1]

        self.fullRect = fullRect
        self.absRect = absRect
        self.screenRect = screenRect

    def getScale(self):
        return self.scale

    def setScale(self, (x,y)):
        self.scale = (x,y)
        self.imageSize = self.texture.getWidth() * self.scale[0], self.texture.getHeight() * self.scale[1]
コード例 #3
0
ファイル: tileImage2.py プロジェクト: rpwagner/tiled-display
 def __init__(self, imageFilename, screenRect, fullRect, absRect, initialOffset=(0,0), zoom=(4,4), imagePos=(0,0), imageSize=None ):
     self.hasDrawFunc=True
     self.hasEraseDrawFunc=True
     self.visible = True
     self.texture = Texture( imageFilename)
     #self.easyTexture = EasyTexture(imageFilename, screenGeomRect=screenRect, blend=False)
     #self.easyTexture.width = renderer.width * 0.8
     #self.easyTexture.height = renderer.height * 0.8
     #self.easyTexture.width = renderer.width
     #self.easyTexture.height = renderer.height
     self.useDrawPixel = False # For comparison debugging
     self.xvel = 0.1
     self.yvel = 0.1
     self.zoom = zoom
     #self.easyTexture.zoom(zoom[0], zoom[1])
     #self.easyTexture.setOffset(initialOffset[0], initialOffset[1])
     self.autoPan = True
     self.imagePos = Vec2(imagePos[0], imagePos[1])
     if imageSize == None:
         self.imageSize = self.texture.getWidth(), self.texture.getHeight()
     else:
         self.imageSize = imageSize
     self.fullRect = fullRect
     self.absRect = absRect
     self.screenRect = screenRect
コード例 #4
0
    def __init__(self,
                 imageFilename,
                 screenRect,
                 fullRect,
                 absRect,
                 zoom=(4, 4),
                 imagePos=None,
                 imageSize=None,
                 blend=False,
                 cropRect=None,
                 scale=None):
        pos = imagePos  # FIXME, replace imagePos arg above and its mention in other files with "pos"

        BaseTileDisplayObject.__init__(self,
                                       screenRect=screenRect,
                                       fullRect=fullRect,
                                       absRect=absRect,
                                       zoom=zoom,
                                       pos=pos,
                                       size=imageSize,
                                       blend=blend,
                                       cropRect=cropRect)

        self.hasDrawFunc = True
        self.hasEraseDrawFunc = True
        self.visible = True
        self.texture = Texture(imageFilename, cropRect=cropRect)
        #self.easyTexture = EasyTexture(imageFilename, screenGeomRect=screenRect, blend=False)
        #self.easyTexture.width = renderer.width * 0.8
        #self.easyTexture.height = renderer.height * 0.8
        #self.easyTexture.width = renderer.width
        #self.easyTexture.height = renderer.height
        self.useDrawPixel = False  # For comparison debugging
        self.xvel = 0.1
        self.yvel = 0.1
        self.vflipTexture = False

        # Now in base class
        #self.blend=blend
        #self.zoom = zoom

        #self.easyTexture.zoom(zoom[0], zoom[1])
        #self.easyTexture.setOffset(initialOffset[0], initialOffset[1])
        self.autoPan = False

        if pos:
            self.pos = Vec2(pos[0], pos[1])
        else:
            self.pos = Vec2(0.0, 0.0)

        self.srcImageSize = self.texture.getWidth(), self.texture.getHeight()

        if imageSize == None:
            self.imageSize = self.texture.getWidth(), self.texture.getHeight()
        else:
            self.imageSize = imageSize

        self.scale = scale
        if self.scale != None:
            self.imageSize = self.imageSize[0] * self.scale[0], self.imageSize[
                1] * self.scale[1]

        self.fullRect = fullRect
        self.absRect = absRect
        self.screenRect = screenRect
コード例 #5
0
ファイル: tileImage2.py プロジェクト: rpwagner/tiled-display
    class glTxtrBox:
        def __init__(self,
                     imageFilename,
                     screenRect,
                     fullRect,
                     absRect,
                     initialOffset=(0, 0),
                     zoom=(4, 4),
                     imagePos=(0, 0),
                     imageSize=None):
            self.hasDrawFunc = True
            self.hasEraseDrawFunc = True
            self.visible = True
            self.texture = Texture(imageFilename)
            #self.easyTexture = EasyTexture(imageFilename, screenGeomRect=screenRect, blend=False)
            #self.easyTexture.width = renderer.width * 0.8
            #self.easyTexture.height = renderer.height * 0.8
            #self.easyTexture.width = renderer.width
            #self.easyTexture.height = renderer.height
            self.useDrawPixel = False  # For comparison debugging
            self.xvel = 0.1
            self.yvel = 0.1
            self.zoom = zoom
            #self.easyTexture.zoom(zoom[0], zoom[1])
            #self.easyTexture.setOffset(initialOffset[0], initialOffset[1])
            self.autoPan = True
            self.imagePos = Vec2(imagePos[0], imagePos[1])
            if imageSize == None:
                self.imageSize = self.texture.getWidth(
                ), self.texture.getHeight()
            else:
                self.imageSize = imageSize
            self.fullRect = fullRect
            self.absRect = absRect
            self.screenRect = screenRect

        def getPos(self):
            return (self.imagePos.x, self.imagePos.y)

        def setPos(self, x, y):
            self.imagePos = Vec2(x, y)

        def update(self, secs, app):
            pass
            #if self.autoPan:
            #    self.easyTexture.pan(self.xvel * secs, self.yvel* secs)

        def pan(self, xchange, ychange):
            if mpi.rank == 1:
                print "Panning:", xchange, ychange
            #self.easyTexture.pan(xchange * 300, ychange * 300)

        def draw(self, renderer):
            #glClearColor(.8, .8, .8, 1.0)
            #glClear(GL_COLOR_BUFFER_BIT)
            # glPixelStoref(GL_UNPACK_ALIGNMENT, 1)

            # self.texture.blit( Vec2(10,10), Rect(10,10, 30,30), (app.width, app.height) )
            # self.texture.blit( Vec2(50,50), Rect(0,0, 64,64), (app.width, app.height) )
            # self.texture.blit( Vec2(150,50), Rect(40,40, 64,64), (app.width, app.height) , blend=True)
            #self.texture.blit( Vec2(0.1 * renderer.width,0.1 * renderer.height), Rect(0,0, 30,30), (app.width, app.height) )

            # convert to local coords
            localBtmLeft = Vec2(self.imagePos.x - self.absRect.x,
                                self.imagePos.y - self.absRect.y)
            localTopRight = Vec2(localBtmLeft.x + self.imageSize[0],
                                 localBtmLeft.y + self.imageSize[1])
            localBtmLeft = Vec2(max(localBtmLeft.x, 0), max(localBtmLeft.y, 0))
            localTopRight = Vec2(min(localTopRight.x, self.screenRect.width),
                                 min(localTopRight.y, self.screenRect.height))
            blitSize = Vec2(localTopRight.x - localBtmLeft.x,
                            localTopRight.y - localBtmLeft.y)

            # convert clipped local coords back to global coords find the source rect
            globalBtmLeft = Vec2(localBtmLeft.x + self.absRect.x,
                                 localBtmLeft.y + self.absRect.y)
            globalTopRight = Vec2(localTopRight.x + self.absRect.x,
                                  localTopRight.y + self.absRect.y)

            # convert global coords to txtr coords
            offset = Vec2(globalBtmLeft.x - self.imagePos.x,
                          globalBtmLeft.y - self.imagePos.y)
            size = (globalTopRight.x - globalBtmLeft.x,
                    globalTopRight.y - globalBtmLeft.y)
            if size[0] > 0 and size[1] > 0:
                self.texture.blit(localBtmLeft,
                                  Rect(offset.x, offset.y, size[0], size[1]),
                                  (renderer.width, renderer.height))
コード例 #6
0
ファイル: tileImage2.py プロジェクト: rpwagner/tiled-display
    class glTxtrBox:
        def __init__(self, imageFilename, screenRect, fullRect, absRect, initialOffset=(0,0), zoom=(4,4), imagePos=(0,0), imageSize=None ):
            self.hasDrawFunc=True
            self.hasEraseDrawFunc=True
            self.visible = True
            self.texture = Texture( imageFilename)
            #self.easyTexture = EasyTexture(imageFilename, screenGeomRect=screenRect, blend=False)
            #self.easyTexture.width = renderer.width * 0.8
            #self.easyTexture.height = renderer.height * 0.8
            #self.easyTexture.width = renderer.width
            #self.easyTexture.height = renderer.height
            self.useDrawPixel = False # For comparison debugging
            self.xvel = 0.1
            self.yvel = 0.1
            self.zoom = zoom
            #self.easyTexture.zoom(zoom[0], zoom[1])
            #self.easyTexture.setOffset(initialOffset[0], initialOffset[1])
            self.autoPan = True
            self.imagePos = Vec2(imagePos[0], imagePos[1])
            if imageSize == None:
                self.imageSize = self.texture.getWidth(), self.texture.getHeight()
            else:
                self.imageSize = imageSize
            self.fullRect = fullRect
            self.absRect = absRect
            self.screenRect = screenRect

        def getPos(self):
            return (self.imagePos.x, self.imagePos.y)

        def setPos(self, x, y):
            self.imagePos = Vec2(x,y)

        def update(self, secs, app):
            pass
            #if self.autoPan:
            #    self.easyTexture.pan(self.xvel * secs, self.yvel* secs) 

        def pan(self, xchange, ychange):
            if mpi.rank == 1:
                print "Panning:", xchange, ychange
            #self.easyTexture.pan(xchange * 300, ychange * 300)

        def draw(self, renderer):
            #glClearColor(.8, .8, .8, 1.0)
            #glClear(GL_COLOR_BUFFER_BIT)
            # glPixelStoref(GL_UNPACK_ALIGNMENT, 1)

            # self.texture.blit( Vec2(10,10), Rect(10,10, 30,30), (app.width, app.height) )
            # self.texture.blit( Vec2(50,50), Rect(0,0, 64,64), (app.width, app.height) )
            # self.texture.blit( Vec2(150,50), Rect(40,40, 64,64), (app.width, app.height) , blend=True)
            #self.texture.blit( Vec2(0.1 * renderer.width,0.1 * renderer.height), Rect(0,0, 30,30), (app.width, app.height) )

            # convert to local coords
            localBtmLeft = Vec2(self.imagePos.x - self.absRect.x, self.imagePos.y - self.absRect.y)
            localTopRight = Vec2(localBtmLeft.x + self.imageSize[0], localBtmLeft.y + self.imageSize[1])
            localBtmLeft = Vec2(max(localBtmLeft.x, 0), max(localBtmLeft.y, 0))
            localTopRight = Vec2(min(localTopRight.x, self.screenRect.width), min(localTopRight.y, self.screenRect.height))
            blitSize = Vec2(localTopRight.x - localBtmLeft.x, localTopRight.y - localBtmLeft.y)

            # convert clipped local coords back to global coords find the source rect
            globalBtmLeft = Vec2(localBtmLeft.x + self.absRect.x, localBtmLeft.y + self.absRect.y)
            globalTopRight = Vec2(localTopRight.x + self.absRect.x, localTopRight.y + self.absRect.y)

            # convert global coords to txtr coords
            offset = Vec2(globalBtmLeft.x - self.imagePos.x , globalBtmLeft.y - self.imagePos.y)
            size = (globalTopRight.x - globalBtmLeft.x, globalTopRight.y - globalBtmLeft.y)
            if size[0] > 0 and size[1] > 0:
                self.texture.blit( localBtmLeft, Rect(offset.x,offset.y, size[0], size[1]), (renderer.width, renderer.height) )