コード例 #1
0
ファイル: frame.py プロジェクト: wachin/inkscape
    def add_frame(self, name, box, style, radius=0):
        """
            name -- The name of the new frame object.
            box -- The boundary box of the node.
            style -- The style used to draw the path.
            radius -- The corner radius of the frame.
            returns a new frame node.
        """
        r = min(
            [radius, (abs(box[1] - box[0]) / 2), (abs(box[3] - box[2]) / 2)])
        if radius > 0:
            d = ' '.join(
                str(x) for x in [
                    'M', box[0], (box[2] + r), 'A', r, r, '0 0 1', (
                        box[0] + r), box[2], 'L', (box[1] - r), box[2], 'A', r,
                    r, '0 0 1', box[1], (box[2] + r), 'L', box[1], (
                        box[3] - r), 'A', r, r, '0 0 1', (box[1] -
                                                          r), box[3], 'L',
                    (box[0] +
                     r), box[3], 'A', r, r, '0 0 1', box[0], (box[3] - r), 'Z'
                ])
        else:
            d = ' '.join(
                str(x) for x in [
                    'M', box[0], box[2], 'L', box[1], box[2], 'L', box[1],
                    box[3], 'L', box[0], box[3], 'Z'
                ])

        elem = PathElement()
        elem.style = style
        elem.label = name
        elem.path = d
        return elem
コード例 #2
0
ファイル: parchis_extension.py プロジェクト: afijog/plugins
 def generateLine(self, x1, y1, x2, y2, strokeWidth, stroke, name):
     line = PathElement()
     line.path = 'M {} {} L {} {}'.format(x1, y1, x2, y2)
     line.style = {
         'stroke': stroke,
         'stroke-width': strokeWidth,
         'fill': 'none'
     }
     line.label = name
     return line
コード例 #3
0
ファイル: parchis_extension.py プロジェクト: afijog/plugins
        def generateSectorColoredPart():
            nSectorPlusOne = nSector + 1
            pathPattern = 'm{} {} v {} h {} v {} h {} v {} h {} v {} Z'
            coloredPart = PathElement()
            coloredPart.style = {
                'stroke': stroke,
                'stroke-width': strokeWidth,
                'fill': self.sectorColors[nSector]
            }
            coloredPart.label = 'colored-part-{}'.format(nSectorPlusOne)

            coloredPart.path = pathPattern.format(
                (nColumns / 2 - 2) * xBoxSize,
                initialY - yBoxSize, -initialY + yBoxSize, xBoxSize,
                yBoxSize * (nBoxesPerColumn - 5), xBoxSize, yBoxSize,
                -xBoxSize, yBoxSize * 3)
            return coloredPart
コード例 #4
0
ファイル: parchis_extension.py プロジェクト: afijog/plugins
        def generateOutline():
            pathPattern = 'm{} {} v {} l {} {} h {} l {} {} v {} Z'
            outline = PathElement()
            outline.style = {
                'stroke': stroke,
                'stroke-width': strokeWidth,
                'fill': fillSecure
            }
            outline.label = 'outline-{}'.format(nSector + 1)

            outline.path = pathPattern.format(initialX, initialY,
                                              -initialY + yBoxSize,
                                              obliqueDistance, -yBoxSize,
                                              topDistance, obliqueDistance,
                                              yBoxSize,
                                              yBoxSize * (nBoxesPerColumn - 1))
            return outline
コード例 #5
0
ファイル: parchis_extension.py プロジェクト: afijog/plugins
        def generateSectorCenterPart():
            nSectorPlusOne = nSector + 1
            pathPattern = 'm{} {} L {} {} L {} {}'
            centerColoredPart = PathElement()
            fill = ('none',
                    self.sectorColors[nSector])[not self.useLaser
                                                and self.generateCenter]
            centerColoredPart.style = {
                'stroke': stroke,
                'stroke-width': strokeWidth,
                'fill': fill
            }
            centerColoredPart.label = 'colored-part-{}'.format(nSectorPlusOne)

            cornerSize = initialX + obliqueDistance

            centerColoredPart.path = pathPattern.format(
                cornerSize, 0, 0, -distanceFromBoardCenter, -cornerSize, 0)
            return centerColoredPart