コード例 #1
0
    def getBounds(self):
        xPos = self.xPos
        xDest = self.xDest
        yPos = self.yPos
        yDest = self.yDest
        width = self.tool.getWidth()
        height = self.tool.getHeight()
        r = CityRect()

        r.x = xPos
        if width >= 3:
            r.x -= 1
        if xDest >= xPos:
            r.width = ((xDest - xPos) / width + 1) * width
        else:
            r.width = ((xPos - xDest) / width + 1) * height
            r.x += width - r.width

        r.y = yPos
        if height >= 3:
            r.y -= 1
        if yDest > yPos:
            r.height = ((yDest - yPos) / height + 1) * height
        else:
            # tool dragged upwards
            r.height = (((yPos - yDest) / height) + 1) * height
            r.y -= r.height - height

        return r
コード例 #2
0
    def getBounds(self):
        ''' constrain bounds to be rectangle with
            either width of height equal to one '''

        assert self.tool.getWidth() == 1
        assert self.tool.getHeight() == 1

        xDest = self.xDest
        xPos = self.xPos
        yDest = self.yDest
        yPos = self.yPos

        if abs(xDest - xPos) >= abs(yDest - yPos):
            # horizontal line
            r = CityRect()
            r.x = min(xPos, xDest)
            r.width = abs(xDest - xPos) + 1
            r.y = yPos
            r.height = 1
            return r
        else:
            # vertical line
            r = CityRect()
            r.x = xPos
            r.width = 1
            r.y = min(yPos, yDest)
            r.height = abs(yDest - yPos) + 1
            return r
コード例 #3
0
ファイル: toolStroke.py プロジェクト: chrisbiggar/micropylis
    def getBounds(self):
        xPos = self.xPos
        xDest = self.xDest
        yPos = self.yPos
        yDest = self.yDest
        width = self.tool.getWidth()
        height = self.tool.getHeight()
        r = CityRect()

        r.x = xPos
        if width >= 3:
            r.x -= 1
        if xDest >= xPos:
            r.width = ((xDest - xPos) / width + 1) * width
        else:
            r.width = ((xPos - xDest) / width + 1) * height
            r.x += width - r.width

        r.y = yPos
        if height >= 3:
            r.y -= 1
        if yDest > yPos:
            r.height = ((yDest - yPos) / height + 1) * height
        else:
            # tool dragged upwards
            r.height = (((yPos - yDest) / height) + 1) * height
            r.y -= r.height - height

        return r