当前位置: 首页>>代码示例>>Python>>正文


Python simplestyle.formatStyle方法代码示例

本文整理汇总了Python中simplestyle.formatStyle方法的典型用法代码示例。如果您正苦于以下问题:Python simplestyle.formatStyle方法的具体用法?Python simplestyle.formatStyle怎么用?Python simplestyle.formatStyle使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在simplestyle的用法示例。


在下文中一共展示了simplestyle.formatStyle方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: setMarker

# 需要导入模块: import simplestyle [as 别名]
# 或者: from simplestyle import formatStyle [as 别名]
def setMarker(self, option):
        if option=='inside':
            # inside
            self.arrowlen = 6.0
            self.dimline_style['marker-start'] = 'url(#ArrowDIN-start)'
            self.dimline_style['marker-end'] = 'url(#ArrowDIN-end)'
            self.makeMarkerstyle('ArrowDIN-start', False)
            self.makeMarkerstyle('ArrowDIN-end', True)
        else:
            # outside
            self.arrowlen = 0
            self.dimline_style['marker-start'] = 'url(#ArrowDINout-start)'
            self.dimline_style['marker-end'] = 'url(#ArrowDINout-end)'
            self.makeMarkerstyle('ArrowDINout-start', False)
            self.makeMarkerstyle('ArrowDINout-end', True)
        self.dimline_attribs['style'] = simplestyle.formatStyle(self.dimline_style) 
开发者ID:Rutzmoser,项目名称:inkscape_dimensioning,代码行数:18,代码来源:dimensioning.py

示例2: effect

# 需要导入模块: import simplestyle [as 别名]
# 或者: from simplestyle import formatStyle [as 别名]
def effect(self):
        self._calculateDimensions()
        style = simplestyle.formatStyle({'stroke': '#000000', 'stroke-width': str(self.linewidth), 'fill': '#808080'})
        if self.options.mergeSides:
            self._addMergedSideShape(style, 0, 0);
        else:
            self._addSideShape('front', style, 0, 0, True)
            self._addSideShape('back', style, self.outsideWidth, 0, True)
            self._addSideShape('right', style, 2 * self.outsideWidth, 0, False)
            self._addSideShape('left', style, 2 * self.outsideWidth + self.outsideDepth, 0, False)

        self._addTopShape('bottom', style, self.thickness, self.outsideHeight + self.thickness)
        if self.options.includeLid:
            self._addTopShape('top', style, self.thickness + self.outsideWidth, self.outsideHeight + self.thickness)


# Create effect instance and apply it. 
开发者ID:AmiableAnteater,项目名称:inkscape-extensions,代码行数:19,代码来源:LaserBox.py

示例3: effect

# 需要导入模块: import simplestyle [as 别名]
# 或者: from simplestyle import formatStyle [as 别名]
def effect(self):
        self._epsilon = self.unittouu("0.001mm")
        self._lineWidth = self.unittouu("0.01mm")

        self._hingeHeight = self._conv(self.options.hinge_height)
        dimensions0 = self._getInkscapeMeasures(self.options.voffset0, self.options.length0, self.options.width0,
                                                self.options.vspacing0)
        # TODO Add some sanity checks, e.g. cutWidth < cutLength, cutLength <= hinge height
        oddCuts = self._createCutString(dimensions0)

        dimensions1 = self._getInkscapeMeasures(self.options.voffset1, self.options.length1, self.options.width1,
                                                self.options.vspacing1)
        evenCuts = self._createCutString(dimensions1)

        self._hSpacing0 = self._conv(self.options.hspacing0)
        self._hSpacing1 = self._conv(self.options.hspacing1)
        if not self.options.useHairlines:
            self._hSpacing0 += self._conv(self.options.width0)
            self._hSpacing1 += self._conv(self.options.width1)
        style = simplestyle.formatStyle(
            {'stroke': '#000000', 'stroke-width': str(self._lineWidth), 'fill': 'none', 'stroke-linecap': 'round'})
        currentX = 0
        for x in xrange(0, self.options.count_cuts):
            self._addPathToDocumentTree(style, 'M ' + str(currentX) + ',0' + oddCuts)
            currentX += self._hSpacing0
            self._addPathToDocumentTree(style, 'M ' + str(currentX) + ',0' + evenCuts)
            currentX += self._hSpacing1
        if self.options.drawBorders:
            self._addPathToDocumentTree(style, 'M 0,0 ' + SvgBasics.lineRel(currentX, 0) +
                                        SvgBasics.moveRel(0, self._hingeHeight) + SvgBasics.lineRel(-currentX, 0))


# Create effect instance and apply it. 
开发者ID:AmiableAnteater,项目名称:inkscape-extensions,代码行数:35,代码来源:LatticeLivingHinges.py

示例4: effect

# 需要导入模块: import simplestyle [as 别名]
# 或者: from simplestyle import formatStyle [as 别名]
def effect(self):
        thickness = self._conv(self.options.thickness)
        leadingOffset = self._conv(self.options.leadingOffset)
        lengthOfTabs = self._conv(self.options.lengthOfTabs)
        lengthOfGaps = self._conv(self.options.lengthOfGaps)
        trailingOffset = self._conv(self.options.trailingOffset)
        linewidth = self._conv(self.options.linewidth)

        offsetForClosedBox = 1 if self.options.createClosedShape else 0
        line = SvgBasics.moveAbs((1 + offsetForClosedBox) * thickness, thickness)
        cutouts = SvgBasics.moveAbs((3 + offsetForClosedBox) * thickness, thickness)

        line += SvgBasics.lineRel(0, leadingOffset)
        cutouts += SvgBasics.moveRel(0, leadingOffset)

        for i in xrange(1, self.options.countTabs + 1):
            line += SvgBasics.createTab(thickness, lengthOfTabs)
            cutouts += SvgBasics.createRect(thickness, lengthOfTabs)
            if i < self.options.countTabs:
                line += SvgBasics.lineRel(0, lengthOfGaps)
                cutouts += SvgBasics.moveRel(0, lengthOfTabs + lengthOfGaps)
            elif trailingOffset > 0:
                line += SvgBasics.lineRel(0, trailingOffset)

        style = simplestyle.formatStyle(
            {'stroke': '#000000', 'stroke-width': str(linewidth), 'fill': 'none'})

        if self.options.createClosedShape:
            line += SvgBasics.lineRel(-thickness,0)
            line += SvgBasics.lineRel(0, -trailingOffset - self.options.countTabs * lengthOfTabs - (self.options.countTabs - 1) * lengthOfGaps - leadingOffset)
            line += SvgBasics.lineRel(thickness,0)
            line += ' z'

        self._addPathToDocumentTree(style, line)
        self._addPathToDocumentTree(style, cutouts)

# Create effect instance and apply it. 
开发者ID:AmiableAnteater,项目名称:inkscape-extensions,代码行数:39,代码来源:TabLines.py

示例5: effect

# 需要导入模块: import simplestyle [as 别名]
# 或者: from simplestyle import formatStyle [as 别名]
def effect(self):
        self.radius = self._conv(self.options.radius)
        self.linewidth = self._conv(self.options.linewidth)

        # Create wheel of triangles around the origin
        triangles = []
        A = Point(self.radius, self.radius)
        for i in xrange(10):
            phi = (2 * i - 1) * math.pi / 10
            B = Point(self.radius * math.cos(phi), self.radius * math.sin(phi)) + A
            phi = (2 * i + 1) * math.pi / 10
            C = Point(self.radius * math.cos(phi), self.radius * math.sin(phi)) + A
            triangle = PenroseTriangle(True, A, C, B) if i % 2 == 0 else PenroseTriangle(True, A, B, C)
            triangles.append(triangle)

        # Perform subdivisions
        for i in xrange(self.options.recursions):
            triangles = self.subdivide(triangles)

        self.drawnLines = set()
        style = simplestyle.formatStyle(
            {'stroke': '#000000', 'stroke-width': str(self.linewidth), 'fill': 'none', 'stroke-linecap': 'round'})
        lineArr = [] if self.options.combineLines else None
        for triangle in triangles:
            self._drawLine(triangle.pointA, triangle.pointB, style, lineArr)
            self._drawLine(triangle.pointC, triangle.pointA, style, lineArr)
        if self.options.combineLines:
            self._addPathToDocumentTree(style, ' '.join(lineArr))


# Create effect instance and apply it. 
开发者ID:AmiableAnteater,项目名称:inkscape-extensions,代码行数:33,代码来源:PenroseTiling.py

示例6: draw_SVG_circle

# 需要导入模块: import simplestyle [as 别名]
# 或者: from simplestyle import formatStyle [as 别名]
def draw_SVG_circle(parent, r, cx, cy, name, style):
    " structre an SVG circle entity under parent "
    circ_attribs = {'style': simplestyle.formatStyle(style),
                    'cx': str(cx), 'cy': str(cy), 
                    'r': str(r),
                    inkex.addNS('label','inkscape'): name,
                    'id':name,
                    'clip-path':"url(#uArm_CutOffBottom)" }
    circle = inkex.etree.SubElement(parent, inkex.addNS('circle','svg'), circ_attribs ) 
开发者ID:fdraeger,项目名称:uArmSwiftPro_InkscapePlugin,代码行数:11,代码来源:uarm.py

示例7: drawS

# 需要导入模块: import simplestyle [as 别名]
# 或者: from simplestyle import formatStyle [as 别名]
def drawS(parent, XYstring):         # Draw lines from a list
  name='part'
  style = { 'stroke': '#000000', 'fill': 'none', 'stroke-width': self.unittouu("0.1 mm") }
  drw = {'style':simplestyle.formatStyle(style),inkex.addNS('label','inkscape'):name,'d':XYstring}
  inkex.etree.SubElement(parent, inkex.addNS('path','svg'), drw )
  return 
开发者ID:paulusjacobus,项目名称:Gerbil,代码行数:8,代码来源:living_hinge.py

示例8: draw_slots

# 需要导入模块: import simplestyle [as 别名]
# 或者: from simplestyle import formatStyle [as 别名]
def draw_slots(self, path):
        #Female slot creation
        
        start = self.to_complex(path[0][1])
        end = self.to_complex(path[1][1])
        
        if self.edgefeatures == False:
            segCount = (self.numslots * 2) 
        else:
            segCount = (self.numslots * 2) - 1

        distance = end - start
        debugMsg(distance)
        debugMsg("segCount - " + str(segCount))
        
        try:
            if self.edgefeatures:
                segLength = self.get_length(distance) / segCount
            else:
                segLength = self.get_length(distance) / (segCount + 1)
        except:
            segLength = self.get_length(distance)
        
        debugMsg("segLength - " + str(segLength))
        newLines = []
        
        line_style = simplestyle.formatStyle({ 'stroke': '#000000', 'fill': 'none', 'stroke-width': str(self.unittouu('1px')) })
                
        for i in range(segCount):
            if (self.edgefeatures and (i % 2) == 0) or (not self.edgefeatures and (i % 2)):
                newLines = self.draw_box(start, distance, segLength, self.thickness, self.kerf)
                debugMsg(newLines)
                
                slot_id = self.uniqueId('slot')
                g = inkex.etree.SubElement(self.current_layer, 'g', {'id':slot_id})
                
                line_atts = { 'style':line_style, 'id':slot_id+'-inner-close-tab', 'd':simplepath.formatPath(newLines) }
                inkex.etree.SubElement(g, inkex.addNS('path','svg'), line_atts )
                
            #Find next point
            polR, polPhi = cmath.polar(distance)
            polR = segLength
            start = cmath.rect(polR, polPhi) + start 
开发者ID:JarrettR,项目名称:QuickJoint,代码行数:45,代码来源:quickjoint.py

示例9: _addMergedSideShape

# 需要导入模块: import simplestyle [as 别名]
# 或者: from simplestyle import formatStyle [as 别名]
def _addMergedSideShape(self, style, upperLeftOffsetX, upperLeftOffsetY):
        # using a variable here enables usage as parameter (not tested!)
        leftSideStartIndented = False
        joinedLine, isLineToSouthIndentedAtEnd, initialOffset, lastOffset = self._createIndentedVerticalLine(
            upperLeftOffsetX, upperLeftOffsetY, leftSideStartIndented)

        # draw eastwards - two times for the width, two times for the depth
        joinedLine += self._generateIndentedEdge(self.countIndentsTopWidth, self.lengthOfTopWidthIndents, EAST, True,
                                                 initialOffset, lastOffset)
        joinedLine += self._generateIndentedEdge(self.countIndentsTopWidth, self.lengthOfTopWidthIndents, EAST, True,
                                                 initialOffset, lastOffset)
        joinedLine += self._generateIndentedEdge(self.countIndentsTopDepth, self.lengthOfTopDepthIndents, EAST, True,
                                                 initialOffset, lastOffset)
        joinedLine += self._generateIndentedEdge(self.countIndentsTopDepth, self.lengthOfTopDepthIndents, EAST, True,
                                                 initialOffset, lastOffset)

        # draw northwards
        joinedLine += self._generateIndentedEdge(self.options.countIndentsSides, self.lengthOfSideIndents, NORTH,
                                                 isLineToSouthIndentedAtEnd)

        # determine whether the second vertical line drawn is indented at the end
        isLineToNorthIndentedAtEnd, initialOffset, lastOffset = self._calculateFinalIndentationAndOffsetForHorizontalLine(
            isLineToSouthIndentedAtEnd)

        # draw westwards and close the shape
        if self.options.includeLid:
            # repeat the same spiel backwards
            joinedLine += self._generateIndentedEdge(self.countIndentsTopDepth, self.lengthOfTopDepthIndents, WEST,
                                                     False, lastOffset, initialOffset)
            joinedLine += self._generateIndentedEdge(self.countIndentsTopDepth, self.lengthOfTopDepthIndents, WEST,
                                                     False, lastOffset, initialOffset)
            joinedLine += self._generateIndentedEdge(self.countIndentsTopWidth, self.lengthOfTopWidthIndents, WEST,
                                                     False, lastOffset, initialOffset)
            joinedLine += self._generateIndentedEdge(self.countIndentsTopWidth, self.lengthOfTopWidthIndents, WEST,
                                                     False, lastOffset, initialOffset)

        joinedLine += 'z'
        self._addPathToDocumentTree(style, joinedLine, "sides")

        noFillStyle = simplestyle.formatStyle(
            {'stroke': '#000000', 'stroke-width': str(self.linewidth), 'fill': 'none'})
        joinedLine = \
            self._createIndentedVerticalLine(upperLeftOffsetX + self.insideWidth + self.thickness, upperLeftOffsetY,
                                             leftSideStartIndented)[0]
        self._addPathToDocumentTree(noFillStyle, joinedLine, "cut0")
        joinedLine = \
            self._createIndentedVerticalLine(upperLeftOffsetX + 2 * (self.insideWidth + self.thickness),
                                             upperLeftOffsetY,
                                             leftSideStartIndented)[0]
        self._addPathToDocumentTree(noFillStyle, joinedLine, "cut1")
        joinedLine = self._createIndentedVerticalLine(
            upperLeftOffsetX + 2 * (self.insideWidth + self.thickness) + self.insideDepth + self.thickness,
            upperLeftOffsetY, leftSideStartIndented)[0]
        self._addPathToDocumentTree(noFillStyle, joinedLine, "cut2") 
开发者ID:AmiableAnteater,项目名称:inkscape-extensions,代码行数:56,代码来源:LaserBox.py

示例10: absCoords

# 需要导入模块: import simplestyle [as 别名]
# 或者: from simplestyle import formatStyle [as 别名]
def absCoords(parent, coordsList, offset=[0, 0], label='none', lineStyle=lineStyle.setSimpleBlack()):
        """Draws a (poly)line based on a list of absolute coordinates

        .. warning:: Keep in mind  that Inkscape's y axis is upside down!

        :param parent: parent object
        :param coordsList: list with coords x and y.  ex  [[x1,y1], ..., [xN,yN]]
        :param offset: offset coords. Default [0,0]
        :param label: label of the line. Default 'none'
        :param lineStyle: line style to be used. See class ``lineStyle``. Default: lineStyle=lineStyle.setSimpleBlack()

        :type parent: inkscapeMadeEasy object (see example below)
        :type coordsList: list of list
        :type offset: list
        :type label: string
        :type lineStyle: lineStyle object

        :returns: the new line object
        :rtype: line Object

        **Example**

        .. image:: ../imagesDocs/lineExample.png
          :width: 250px

        >>> import inkex
        >>> import inkscapeMadeEasy_Base as inkBase
        >>> import inkscapeMadeEasy_Draw as inkDraw
        >>> 
        >>> class myExtension(inkBase.inkscapeMadeEasy):
        >>>   def __init__(self):
        >>>     ...
        >>>     ...
        >>> 
        >>>   def effect(self):
        >>>     root_layer = self.document.getroot()     # retrieves the root layer of the document
        >>>     myLineStyle = set(lineWidth=1.0, lineColor=color.defined('red'))
        >>>     
        >>> 
        >>>     # creates a polyline passing by points (0,0) (0,1) (1,1) (1,2) (2,2) using absolute coordinates
        >>>     coords=[ [0,0], [0,1], [1,1], [1,2], [2,2] ]
        >>>     inkDraw.line.absCoords(root_layer, coordsList=coords, offset=[0, 0], label='fooBarLine', lineStyle=myLineStyle)
        >>>
        >>>     # creates the same polyline translated to point (5,6). Note we just have to change the offset
        >>>     inkDraw.line.absCoords(root_layer, coordsList=coords, offset=[5, 6], label='fooBarLine', lineStyle=myLineStyle)
        """

        # string with coordinates
        string_coords = ''

        for point in coordsList:
            string_coords = string_coords + ' ' + str(point[0] + offset[0]) + ' ' + str(point[1] + offset[1])

        Attribs = {inkex.addNS('label', 'inkscape'): label,
                   'style': simplestyle.formatStyle(lineStyle),
                   # M = move, L = line, H = horizontal line, V = vertical line, C = curve, S = smooth curve, Q = quadratic Bezier curve, T = smooth quadratic Bezier curve, A = elliptical Arc,Z = closepath
                   'd': 'M ' + string_coords}

        return inkex.etree.SubElement(parent, inkex.addNS('path', 'svg'), Attribs)

    #--------------------------------------------- 
开发者ID:fsmMLK,项目名称:inkscapeMadeEasy,代码行数:63,代码来源:inkscapeMadeEasy_Draw.py

示例11: relCoords

# 需要导入模块: import simplestyle [as 别名]
# 或者: from simplestyle import formatStyle [as 别名]
def relCoords(parent, coordsList, offset=[0, 0], label='none', lineStyle=lineStyle.setSimpleBlack()):
        """Draws a (poly)line based on a list of relative coordinates

        .. warning:: Keep in mind  that Inkscape's y axis is upside down!

        :param parent: parent object
        :param coordsList: list with distances dx and dy for all points.  ex  [[dx1,dy1], ..., [dxN,dyN]]
        :param offset: offset coords. Default [0,0]
        :param label: label of the line. Default 'none'
        :param lineStyle: line style to be used. See class ``lineStyle``. Default: lineStyle=lineStyle.setSimpleBlack()

        :type parent: inkscapeMadeEasy object (see example below)
        :type coordsList: list of list
        :type offset: list
        :type label: string
        :type lineStyle: lineStyle object

        :returns: the new line object
        :rtype: line Object

        **Example**

        .. image:: ../imagesDocs/lineExample.png
          :width: 250px

        >>> import inkex
        >>> import inkscapeMadeEasy_Base as inkBase
        >>> import inkscapeMadeEasy_Draw as inkDraw
        >>> 
        >>> class myExtension(inkBase.inkscapeMadeEasy):
        >>>   def __init__(self):
        >>>     ...
        >>>     ...
        >>> 
        >>>   def effect(self):
        >>>     root_layer = self.document.getroot()     # retrieves the root layer of the document
        >>>     myLineStyle = setSimpleBlack(lineWidth=1.0)
        >>>     
        >>> 
        >>>     # creates a polyline passing by points (0,0) (0,1) (1,1) (1,2) (2,2) using relative coordinates
        >>>     coords=[ [0,1], [1,0], [0,1], [1,0] ]
        >>>     inkDraw.line.relCoords(root_layer, coordsList=coords, offset=[0, 0], label='fooBarLine', lineStyle=myLineStyle)
        >>>
        >>>     # creates the same polyline translated to point (5,6)
        >>>     inkDraw.line.relCoords(root_layer, coordsList=coords, offset=[5, 6], label='fooBarLine', lineStyle=myLineStyle)
        """

        # string with coordinates
        string_coords = ''
        for dist in coordsList:
            string_coords = string_coords + ' ' + str(dist[0]) + ' ' + str(dist[1])

        Attribs = {inkex.addNS('label', 'inkscape'): label,
                   'style': simplestyle.formatStyle(lineStyle),
                   # M = move, L = line, H = horizontal line, V = vertical line, C = curve, S = smooth curve, Q = quadratic Bezier curve, T = smooth quadratic Bezier curve, A = elliptical Arc,Z = closepath
                   'd': 'm ' + str(offset[0]) + ' ' + str(offset[1]) + string_coords}

        return inkex.etree.SubElement(parent, inkex.addNS('path', 'svg'), Attribs) 
开发者ID:fsmMLK,项目名称:inkscapeMadeEasy,代码行数:60,代码来源:inkscapeMadeEasy_Draw.py

示例12: centerRadius

# 需要导入模块: import simplestyle [as 别名]
# 或者: from simplestyle import formatStyle [as 别名]
def centerRadius(parent, centerPoint, radius, offset=[0, 0], label='circle', lineStyle=lineStyle.setSimpleBlack()):
        """draws a circle given its center point and radius

        .. warning:: Keep in mind  that Inkscape's y axis is upside down!

        :param parent: parent object
        :param centerPoint: center coordinate [x,y]
        :param radius: circle's radius
        :param offset: extra offset coords [x,y]
        :param label: label of the line. Default 'circle'
        :param lineStyle: line style to be used. See class ``lineStyle``. Default: lineStyle=lineStyle.setSimpleBlack()

        :type parent: inkscapeMadeEasy object (see example below)
        :type centerPoint: list
        :type radius: float
        :type offset: list
        :type label: string
        :type lineStyle: lineStyle object

        :returns: the new circle object
        :rtype: line Object

        **Example**

        >>> import inkex
        >>> import inkscapeMadeEasy_Base as inkBase
        >>> import inkscapeMadeEasy_Draw as inkDraw
        >>> 
        >>> class myExtension(inkBase.inkscapeMadeEasy):
        >>>   def __init__(self):
        >>>     ...
        >>>     ...
        >>> 
        >>>   def effect(self):
        >>>     root_layer = self.document.getroot()     # retrieves the root layer of the document
        >>>     myLineStyle=inkDraw.lineStyle.setSimpleBlack()
        >>>     
        >>>     #draws the shortest arc
        >>>     inkDraw.circle.centerRadius(parent=root_layer, centerPoint=[0,0], radius=15.0, offset=[5,1], label='circle1',  lineStyle=myLineStyle)
        """

        # arc instructions
        arcStringA = ' a %f,%f 0 1 1 %f,%f' % (radius, radius, -2 * radius, 0)
        arcStringB = ' a %f,%f 0 1 1 %f,%f' % (radius, radius, 2 * radius, 0)

        Attribs = {inkex.addNS('label', 'inkscape'): label,
                   'style': simplestyle.formatStyle(lineStyle),
                   inkex.addNS('type', 'sodipodi'): 'arc',
                   inkex.addNS('rx', 'sodipodi'): str(radius),
                   inkex.addNS('ry', 'sodipodi'): str(radius),
                   inkex.addNS('cx', 'sodipodi'): str(centerPoint[0] + offset[0]),
                   inkex.addNS('cy', 'sodipodi'): str(centerPoint[1] + offset[1]),
                   inkex.addNS('start', 'sodipodi'): '0',
                   inkex.addNS('end', 'sodipodi'): str(2 * math.pi),
                   # M = moveto,L = lineto,H = horizontal lineto,V = vertical lineto,C = curveto,S = smooth curveto,Q = quadratic Bezier curve,T = smooth quadratic Bezier curveto,A = elliptical Arc,Z = closepath
                   'd': 'M ' + str(centerPoint[0] + offset[0] + radius) + ' ' + str(centerPoint[1] + offset[1]) + arcStringA + ' ' + arcStringB + ' z'}

        return inkex.etree.SubElement(parent, inkex.addNS('path', 'svg'), Attribs) 
开发者ID:fsmMLK,项目名称:inkscapeMadeEasy,代码行数:60,代码来源:inkscapeMadeEasy_Draw.py

示例13: export_HATCH

# 需要导入模块: import simplestyle [as 别名]
# 或者: from simplestyle import formatStyle [as 别名]
def export_HATCH():
    # mandatory group codes : (10, 20, 70, 72, 92, 93) (x, y, fill, Edge Type, Path Type, Number of edges)
    if vals[groups['10']] and vals[groups['20']] and vals[groups['70']] and vals[groups['72']] and vals[groups['92']] and vals[groups['93']]:
        if vals[groups['70']][0] and len(vals[groups['10']]) > 1 and len(vals[groups['20']]) == len(vals[groups['10']]):
            # optional group codes : (11, 21, 40, 50, 51, 73) (x, y, r, angle1, angle2, CCW)
            i10 = 1    # count start points
            i11 = 0    # count line end points
            i40 = 0    # count circles
            i72 = 0    # count edge type flags
            path = ''
            for i in range (0, len(vals[groups['93']])):
                xc = vals[groups['10']][i10]
                yc = vals[groups['20']][i10]
                if vals[groups['72']][i72] == 2:            # arc
                    rm = scale*vals[groups['40']][i40]
                    a1 = vals[groups['50']][i40]
                    path += 'M %f,%f ' % (xc + rm*math.cos(a1*math.pi/180.0), yc + rm*math.sin(a1*math.pi/180.0))
                else:
                    a1 = 0
                    path += 'M %f,%f ' % (xc, yc)
                for j in range(0, vals[groups['93']][i]):
                    if vals[groups['92']][i] & 2:           # polyline
                        if j > 0:
                            path += 'L %f,%f ' % (vals[groups['10']][i10], vals[groups['20']][i10])
                        if j == vals[groups['93']][i] - 1:
                            i72 += 1
                    elif vals[groups['72']][i72] == 2:      # arc
                        xc = vals[groups['10']][i10]
                        yc = vals[groups['20']][i10]
                        rm = scale*vals[groups['40']][i40]
                        a2 = vals[groups['51']][i40]
                        diff = (a2 - a1 + 360) % (360)
                        sweep = 1 - vals[groups['73']][i40] # sweep CCW
                        large = 0                           # large-arc-flag
                        if diff:
                            path += 'A %f,%f 0.0 %d %d %f,%f ' % (rm, rm, large, sweep, xc + rm*math.cos(a2*math.pi/180.0), yc + rm*math.sin(a2*math.pi/180.0))
                        else:
                            path += 'A %f,%f 0.0 %d %d %f,%f ' % (rm, rm, large, sweep, xc + rm*math.cos((a1+180.0)*math.pi/180.0), yc + rm*math.sin((a1+180.0)*math.pi/180.0))
                            path += 'A %f,%f 0.0 %d %d %f,%f ' % (rm, rm, large, sweep, xc + rm*math.cos(a1*math.pi/180.0), yc + rm*math.sin(a1*math.pi/180.0))
                        i40 += 1
                        i72 += 1
                    elif vals[groups['72']][i72] == 1:      # line
                        path += 'L %f,%f ' % (scale*(vals[groups['11']][i11] - xmin), -scale*(vals[groups['21']][i11] - ymax))
                        i11 += 1
                        i72 += 1
                    i10 += 1
                path += "z "
            style = simplestyle.formatStyle({'fill': '%s' % color})
            attribs = {'d': path, 'style': style}
            inkex.etree.SubElement(layer, 'path', attribs) 
开发者ID:paulusjacobus,项目名称:Gerbil,代码行数:52,代码来源:dxf_input.py

示例14: effect

# 需要导入模块: import simplestyle [as 别名]
# 或者: from simplestyle import formatStyle [as 别名]
def effect(self):
    
    unit=self.options.unit
    # starting cut length. Will be adjusted for get an integer number of cuts in the y-direction.
    l = self.unittouu(str(self.options.cut_length) + unit)
    # cut separation in the y-direction
    d = self.unittouu(str(self.options.gap_length) + unit)
    # starting separation between lines of cuts in the x-direction. Will be adjusted to get an integer
    # number of cut lines in the x-direction.
    dd = self.unittouu(str(self.options.sep_distance) + unit)
    
    # get selected nodes
    if self.selected:
      # put lines on the current layer        
      parent = self.current_layer
      for id, node in self.selected.iteritems():
      #        inkex.debug("id:" + id)
      #         for key in node.attrib.keys():
      #           inkex.debug(key + ": " + node.get(key))
        x = float(node.get("x"))
        dx = float(node.get("width"))
        y = float(node.get("y"))
        dy = float(node.get("height"))
        
        # calculate the cut lines for the hinge
        lines, l_actual, d_actual, dd_actual = self.calcCutLines(x, y, dx, dy, l, d, dd)

        # all the lines are one path. Prepare the string that describes the path.
        s = ''
        for line in lines:
          s = s + "M %s, %s L %s, %s " % (line['x1'], line['y1'], line['x2'], line['y2'])
        # add the path to the document
        style = { 'stroke': '#000000', 'fill': 'none', 'stroke-width': self.unittouu("0.1 mm")}
        drw = {'style':simplestyle.formatStyle(style), 'd': s}
        hinge = inkex.etree.SubElement(parent, inkex.addNS('path', 'svg'), drw)
        # add a description element to hold the parameters used to create the cut lines
        desc = inkex.etree.SubElement(hinge, inkex.addNS('desc', 'svg'))
        desc.text = "Hinge cut parameters: actual(requested)\n" \
          "cut length: %.2f %s (%.2f %s)\n" \
          "gap length: %.2f %s (%.2f %s)\n" \
          "separation distance: %.2f %s (%.2f %s)" % (self.uutounit(l_actual, unit), unit, self.uutounit(l, unit), unit, 
                                 self.uutounit(d_actual, unit), unit, self.uutounit(d, unit), unit,
                                 self.uutounit(dd_actual, unit), unit, self.uutounit(dd, unit), unit)
    else:
      inkex.debug("No rectangle(s) have been selected.") 
开发者ID:paulusjacobus,项目名称:Gerbil,代码行数:47,代码来源:living_hinge.py


注:本文中的simplestyle.formatStyle方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。