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


Python SVGdraw类代码示例

本文整理汇总了Python中SVGdraw的典型用法代码示例。如果您正苦于以下问题:Python SVGdraw类的具体用法?Python SVGdraw怎么用?Python SVGdraw使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: fill

 def fill(self,elt):
     pattern=SVGdraw.SVGelement('pattern',attributes=
                                {"height":"20", "width":"20",
                                 "patternUnits": "userSpaceOnUse",
                                 "patternContentUnits": "userSpaceOnUse",
                                 "id": "semy%04d"%blazon.Ordinary.id})
     blazon.Ordinary.id+=1
     # Just in case we try to countercharge it.  It doesn't work anyway.
     self.colors=(self.background,self.charge.tincture)
     charge2=copy.deepcopy(self.charge)
     self.charge.moveto((5,15))
     self.charge.scale(.1)
     charge2.moveto((15,5))
     charge2.scale(.1)
     #pattern.addElement(SVGdraw.rect(0,0,30,30,stroke="black",
     #                                stroke_width=".3",fill="none"))
     pattern.addElement(self.charge.finalizeSVG())
     pattern.addElement(charge2.finalizeSVG())
     blazon.Ordinary.defs.append(pattern)
     newelt=SVGdraw.group()
     elt=self.background.fill(elt)
     newelt.addElement(elt)
     newbase=SVGdraw.rect(x=-blazon.Ordinary.FESSPTX,
                          y=-blazon.Ordinary.FESSPTY,
                          width=blazon.Ordinary.WIDTH,
                          height=blazon.Ordinary.HEIGHT,
                          fill="url(#%s)"%pattern.attributes["id"])
     newelt.addElement(newbase)
     return newelt
开发者ID:ipatrol,项目名称:pyblazon,代码行数:29,代码来源:treatment.py

示例2: writeToFile

    def writeToFile(self, outfile):
        """write svg image to file.
        """
        self.finalizePlot()

        self.mRoot = SVGdraw.drawing()
        self.mDraw = SVGdraw.svg( (0, 0, self.mPageWidth, self.mPageHeight ) , "100%", "100%" )

        kk = self.mElements.keys()
        kk.sort()
        kk.reverse()
        for k in kk:
            for e in self.mElements[k]:
                self.mDraw.addElement( e )
            
        self.mRoot.setSVG(self.mDraw)

        tfile = tempfile.mktemp()
        
        self.mRoot.toXml( tfile )

        lines = open(tfile,"r").readlines()
        
        outfile.write(string.join(lines,""))
        outfile.write("\n")
        
        os.remove(tfile)
开发者ID:BioinformaticsArchive,项目名称:cgat,代码行数:27,代码来源:SVGDuplicationsWheel.py

示例3: errorsvg

def errorsvg(msg):
    s=SVGdraw.svg(width='5cm', height='1cm')
    s.addElement(SVGdraw.text(0,0,msg))
    d=SVGdraw.drawing()
    d.svg=s
    print d.toXml()
    return s
开发者ID:clsn,项目名称:THexplorer,代码行数:7,代码来源:knots.py

示例4: writeToFile

    def writeToFile(self, outfile):
        """write svg image to file.
        """
        self.finalizePlot()

        kk = self.mElements.keys()
        kk.sort()
        kk.reverse()

        ## make sure the image size is ok
        min_x, min_y, max_x, max_y = 0, 0, 0, 0
        
        for k in kk:
            for e in self.mElements[k]:
                for x in ('x', 'x2', 'x1'):
                    if x in e.attributes:
                        v = e.attributes[x] 
                        min_x = min(min_x, v )
                        max_x = max(max_x, v )
                for y in ('y', 'y2', 'y1'):
                    if y in e.attributes:
                        v = e.attributes[y]
                        min_y = min(min_y, v )
                        max_y = max(max_y, v )

        min_x, min_y = int(math.floor(min_x)), int(math.floor(min_y))
        max_x, max_y = int(math.floor(max_x)), int(math.floor(max_y))        

        for k in kk:
            for e in self.mElements[k]:
                for x in ('x', 'x2', 'x1'):
                    if x in e.attributes:
                        e.attributes[x] -= min_x
                for x in ('y', 'y2', 'y1'):
                    if y in e.attributes:
                        e.attributes[y] -= min_y

        ## now add all the elements
        self.mRoot = SVGdraw.drawing()
        self.mDraw = SVGdraw.svg( (0, 0, self.mPageWidth - min_x, self.mPageHeight - min_y ) , "100%", "100%" )
                        
        for k in kk:
            for e in self.mElements[k]:
                self.mDraw.addElement( e )
            
        self.mRoot.setSVG(self.mDraw)

        tfile = tempfile.mktemp()
        
        self.mRoot.toXml( tfile )

        lines = open(tfile,"r").readlines()
        
        outfile.write(string.join(lines,""))
        outfile.write("\n")
        
        os.remove(tfile)
开发者ID:BioinformaticsArchive,项目名称:cgat,代码行数:57,代码来源:SVGTree.py

示例5: save

	def save(self, filename=None):
		document = SVGdraw.drawing()
		width = str(self.width) + self.units
		height = str(self.height) + self.units
		canvas = SVGdraw.svg(None, width, height)

		self.makeGrid(canvas)

		document.setSVG(canvas)

		if filename:
			document.toXml(filename)
		else:
			return document.toXml()
开发者ID:vincent,项目名称:irlig,代码行数:14,代码来源:gridmaps.py

示例6: writeScale

    def writeScale( self ):
        """write scales."""

        current_x = self.mScaleX
        current_y = self.mScaleY + self.mScaleHeight

        nboxes = len(self.mColourThresholds)
        # box size for legend in x-direction
        # subtract size of right-most axis label so that it takes the
        # same width as self.mDataWidth.
        box_size_x = math.ceil( (self.mDataWidth -
                                (self.mScaleFontSize * len(self.mFormatNumberLegend % self.mColourThresholds[-1])))
                                / nboxes )

        # change font size such that it labels will fit between tick-marks
        self.mScaleFontSize = min( self.mScaleFontSize,
                                   (box_size_x * self.mScaleNumTicks * 1.5) / len(self.mFormatNumberLegend % self.mColourThresholds[-1]) )
        
        for x in range(nboxes):

            e = SVGdraw.rect( current_x,
                              current_y,
                              box_size_x,
                              self.mScaleBoxSizeY,                                   
                              fill = "rgb(%i,%i,%i)" % self.mColours[x],
                              stroke = "rgb(%i,%i,%i)" % self.mColours[x])                                   
            
            self.addElement(e)
            
            if x % self.mScaleNumTicks == 0:

                e = SVGdraw.line( current_x,
                                  current_y,
                                  current_x,
                                  current_y + self.mScaleBoxSizeY,
                                  stroke = "rgb(%i,%i,%i)" % BLACK,
                                  stroke_width = 5)
                self.addElement(e)
                
                e = SVGdraw.text( current_x,
                                  current_y - self.mScaleBoxSizeY,
                                  self.mFormatNumberLegend % self.mColourThresholds[x],
                                  self.mScaleFontSize,
                                  self.mScaleFont,
                                  stroke = "rgb(%i,%i,%i)" % BLACK,
                                  text_anchor = "start")
                self.addElement(e)
            
            
            current_x += box_size_x
开发者ID:BioinformaticsArchive,项目名称:cgat,代码行数:50,代码来源:SVGDuplicationsWheel.py

示例7: assemble

 def assemble(self):
     # Yes, everything with HEIGHT, so I'm working in a square.
     # May have the colors backwards.
     p=partLine(linetype=self.lineType)
     if self.pieces == 8:
         # No reason to do this as a special case, but it was working
         # first, so why mess with it.
         p.move(0,-blazon.Ordinary.HEIGHT)
         p.makeline(0,blazon.Ordinary.HEIGHT)
         p.hline(-blazon.Ordinary.HEIGHT)
         p.makeline(blazon.Ordinary.HEIGHT,-blazon.Ordinary.HEIGHT)
         p.closepath()
         p.move(-blazon.Ordinary.HEIGHT,0)
         p.makeline(blazon.Ordinary.HEIGHT,0)
         p.vline(blazon.Ordinary.HEIGHT)
         p.makeline(-blazon.Ordinary.HEIGHT,-blazon.Ordinary.HEIGHT)
         p.closepath()
     else:
         angle=2*math.pi/self.pieces
         pi_2=math.pi/2
         for i in range(0,self.pieces,2):
             p.move(blazon.Ordinary.HEIGHT*math.cos(pi_2+i*angle),
                    blazon.Ordinary.HEIGHT*math.sin(pi_2+i*angle))
             p.makeline(0,0)
             p.makeline(blazon.Ordinary.HEIGHT*math.cos(pi_2+(i+1)*angle),
                        blazon.Ordinary.HEIGHT*math.sin(pi_2+(i+1)*angle))
             p.closepath()
     self.path=SVGdraw.path(p)
     self.path.attributes["fill-rule"]="evenodd"
开发者ID:ipatrol,项目名称:pyblazon,代码行数:29,代码来源:treatment.py

示例8: doGrid

	def doGrid(self, canvas, rows, verticalOffset, partHeight, columns, horizontalOffset, partWidth, gridsize, lineColor, fillColor, penWidth):
		polySize = str(gridsize) + self.units
		for polyRow in range(0, rows):
			polyTop = verticalOffset + polyRow*partHeight
			polyTopStr = str(polyTop) + self.units

			#do stuff for hexagons
			rowcolumns = columns
			rowoffset = 0
			if self.type == 'hex':
				if polyRow % 2 == 0:
					if (self.width-(horizontalOffset+self.rightMargin-.01)) >= (columns*partWidth + gridsize):
						rowcolumns = columns + 1
				else:
					rowoffset = gridsize/2 + gridsize/4

			for polyColumn in range(0, rowcolumns):
				polyLeft = horizontalOffset + polyColumn*partWidth
				polyLeft += rowoffset
				polyLeftStr = str(polyLeft) + self.units
				
				if self.type == 'hex':
					gridshape = hexagon(gridsize, polyLeft, polyTop, self.units, stroke=lineColor, fill=fillColor, stroke_width=penWidth)
				else:
					gridshape = SVGdraw.rect(polyLeftStr, polyTopStr, polySize, polySize, stroke=lineColor, fill=fillColor, stroke_width=penWidth)
				
				canvas.addElement(gridshape)
		return canvas
开发者ID:xytis,项目名称:GURPS,代码行数:28,代码来源:gridmaps.py

示例9: getElements

    def getElements( self, node_id, x, y1, y2 ):

        e = []
        e.append(SVGdraw.line( x, y1, x, y2,
                                stroke = "rgb(%i,%i,%i)" % BLACK,
                                stroke_width = 1 ))
        return e
开发者ID:BioinformaticsArchive,项目名称:cgat,代码行数:7,代码来源:SVGTree.py

示例10: addSeparator

 def addSeparator( self ):
     """add separator on circles."""
     if self.mRadius not in self.mSeparators:
         e = SVGdraw.circle( self.mDataMiddleX, self.mDataMiddleY, self.mRadius, fill="none",
                             stroke = "rgb(%i,%i,%i)" % self.mGridColour,
                             stroke_width = self.mGridStrokeWidth )
         self.addWheelElement( e, self.mPlaneGrid )
     self.mSeparators[self.mRadius] = 1
开发者ID:BioinformaticsArchive,项目名称:cgat,代码行数:8,代码来源:SVGDuplicationsWheel.py

示例11: plot

    def plot(self, 
             filename,
             segments,
             workspace,
             samples ):
        nlines = 2 + len(samples)
        
        height = nlines * self.linewidth * self.linespace

        width = workspace.max()
        
        print height, width
    
        root = SVGdraw.drawing()
        canvas = SVGdraw.svg( (0, 0, width, heigh), "100%", "100%")

        root.setSVG( canvas )

        root.toXml( filename )
开发者ID:abudulemusa,项目名称:gat,代码行数:19,代码来源:validate_randomization.py

示例12: writeGrid

    def writeGrid( self ):
        """add grid lines."""

        middlex = self.mDataMiddleX
        middley = self.mDataMiddleY

        ## print separators
        for c in range(len(self.contigs)):

            contig = self.contigs[c]
            
            pos = self.getPosition( contig, "+", 0)
            angle = self.getAngle( pos )

            x,y = self.getPosOnArc( angle, self.mRadius )
            
            e = SVGdraw.line( middlex,
                              middley,
                              x, 
                              y,
                              stroke = "rgb(%i,%i,%i)" % BLACK,
                              stroke_width = self.mGridStrokeWidth )

            self.addElement(e, self.mPlaneGrid )

            if c < len(self.contigs) - 1:
                next_angle = self.getAngle(self.getPosition( self.contigs[c+1], "+", 0 ) )
            else:
                next_angle = 360
            
            x,y = self.getPosOnArc( angle + float(next_angle - angle) / 2, self.mRadiusStart / 2)
            
            e = SVGdraw.text( x,
                              y,
                              contig,
                              self.mGridFontSize,
                              self.mGridFont,
                              stroke = "rgb(%i,%i,%i)" % BLACK,
                              text_anchor = "start" )
            # do not rotate text:
            # transform="rotate(%i,%i,%i)" % ( angle, x, y ))

            self.addElement(e)
开发者ID:BioinformaticsArchive,项目名称:cgat,代码行数:43,代码来源:SVGDuplicationsWheel.py

示例13: build

 def build(self):
     (sx, sy) = self._srcchgset.position()
     h_offset = self._srcchgset.tag_offset(self._h)
     self._position = (sx + (self._srcchgset.extent()[0])/2,
                       sy - (3*self._h)/2 + h_offset)
     x = self._position[0]+(self._w-self._tw)/2
     y = self._position[1]
     r = UNIT/2
     rect = SVG.rect(x,y,self._tw,self._h,
                     self._srcchgset.strokecolor(),
                     self._srcchgset.fillcolor(), 
                     self._srcchgset.strokewidth())
     rect.attributes['rx'] = r
     rect.attributes['ry'] = r        
     rect.attributes['opacity'] = str(self._opacity/100.0) 
     text = SVG.text(self._position[0]+self._w/2, 
                     self._position[1]+self._h/2+UNIT/4,
                     "%s" % self._title.encode('utf-8'), 
                     self._srcchgset.fontsize(), 
                     self._srcchgset.fontname())
     txc = SvgColor('white')
     text.attributes['style'] = 'fill:%s; text-anchor: middle' % txc.rgb()
     name = self._title.encode('utf-8').replace('/','')
     g = SVG.group('grp%d' % self._revision, elements=[rect, text])
     link = "%s/changeset/%d" % (self._parent.urlbase(), self._revision)
     self._link = SVG.link(link, elements=[g])
     self._link.attributes['id'] = 'rev%d' % self._revision
     self._link.attributes['style'] = \
         'color: %s; background-color: %s' % \
             (self._srcchgset.fillcolor(), self._srcchgset.strokecolor())
开发者ID:nyuhuhuu,项目名称:trachacks,代码行数:30,代码来源:svgview.py

示例14: create

 def create(self, color, head):
     name = self._get_name(color, head)
     if not self._markers.has_key(name):
         if head:
             marker = SVG.marker(name, (0,0,10,8), 0, 4, UNIT/4, UNIT/4,
                                 fill=SvgColor(color), orient='auto')
             marker.addElement(SVG.polyline(((0,4),(10,0),(10,8),(0,4))))
         else:
             marker = SVG.marker(name, (0,0,10,8), 10, 4, UNIT/4, UNIT/4,
                                 fill=SvgColor(color), orient='auto')
             marker.addElement(SVG.polyline(((0,0),(0,8),(10,4),(0,0))))
         self._markers[name] = marker
     return name
开发者ID:nyuhuhuu,项目名称:trachacks,代码行数:13,代码来源:svgview.py

示例15: render

 def render(self, scale=1, width=None, height=None, linkparent=False):
     """Render the revision tree"""
     self._svg = SVG.svg((0,0,self._extent[0],self._extent[1]),
                         scale*self._extent[0], scale*self._extent[1])
     self._arrows.render()
     # FIXME: only two levels for enhancers (background, foreground)
     map(lambda e: e.render(self._addons[e], 1), self.enhancers)
     map(lambda b: b.render(), self._svgbranches.values())
     map(lambda e: e.render(self._addons[e], 2), self.enhancers)
开发者ID:nyuhuhuu,项目名称:trachacks,代码行数:9,代码来源:svgview.py


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