• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python utils.fp_str函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: __repr__

 def __repr__(self):
     return "CMYKColor(%s%s%s%s)" % (
         string.replace(fp_str(self.cyan, self.magenta, self.yellow, self.black), " ", ","),
         (self.spotName and (",spotName=" + repr(self.spotName)) or ""),
         (self.density != 1 and (",density=" + fp_str(self.density)) or ""),
         (self.knockout is not None and (",knockout=%d" % self.knockout) or ""),
     )
开发者ID:tschalch,项目名称:pyTray,代码行数:7,代码来源:colors.py


示例2: _issueT1String

    def _issueT1String(self,fontObj,x,y,s):
        fc = fontObj
        code_append = self.code_append
        fontSize = self._fontSize
        fontsUsed = self._fontsUsed
        escape = self._escape
        if not isinstance(s,str):
            try:
                s = s.decode('utf8')
            except UnicodeDecodeError as e:
                i,j = e.args[2:4]
                raise UnicodeDecodeError(*(e.args[:4]+('%s\n%s-->%s<--%s' % (e.args[4],s[i-10:i],s[i:j],s[j:j+10]),)))

        for f, t in unicode2T1(s,[fontObj]+fontObj.substitutionFonts):
            if f!=fc:
                psName = f.face.name
                code_append('(%s) findfont %s scalefont setfont' % (psName,fp_str(fontSize)))
                if psName not in fontsUsed:
                    fontsUsed.append(psName)
                fc = f
            code_append('%s m (%s) show ' % (fp_str(x,y),escape(t)))
            x += f.stringWidth(t.decode(f.encName),fontSize)
        if fontObj!=fc:
            self._font = None
            self.setFont(fontObj.face.name,fontSize)
开发者ID:wolf29,项目名称:EG-notifications,代码行数:25,代码来源:renderPS.py


示例3: __repr__

 def __repr__(self):
     return "CMYKColor(%s%s%s%s)" % (
         string.replace(fp_str(self.cyan, self.magenta, self.yellow, self.black),' ',','),
         (self.spotName and (',spotName='+repr(self.spotName)) or ''),
         (self.density!=1 and (',density='+fp_str(self.density)) or ''),
         (self.knockout is not None and (',knockout=%d' % self.knockout) or ''),
         )
开发者ID:AceZOfZSpades,项目名称:RankPanda,代码行数:7,代码来源:colors.py


示例4: setStrokeColor

 def setStrokeColor(self, aColor, alpha=None):
     """Takes a color object, allowing colors to be referred to by name"""
     if isinstance(aColor, CMYKColor):
         d = aColor.density
         c,m,y,k = (d*aColor.cyan, d*aColor.magenta, d*aColor.yellow, d*aColor.black)
         self._strokeColorObj = aColor
         name = self._checkSeparation(aColor)
         if name:
             self._code.append('/%s CS %s SCN' % (name,fp_str(d)))
         else:
             self._code.append('%s K' % fp_str(c, m, y, k))
     elif isinstance(aColor, Color):
         rgb = (aColor.red, aColor.green, aColor.blue)
         self._strokeColorObj = aColor
         self._code.append('%s RG' % fp_str(rgb) )
     elif isinstance(aColor,(tuple,list)):
         l = len(aColor)
         if l==3:
             self._strokeColorObj = aColor
             self._code.append('%s RG' % fp_str(aColor) )
         elif l==4:
             self.setStrokeColorCMYK(aColor[0], aColor[1], aColor[2], aColor[3])
         else:
             raise ValueError('Unknown color %r' % aColor)
     elif isinstance(aColor,basestring):
         self.setStrokeColor(toColor(aColor))
     else:
         raise ValueError('Unknown color %r' % aColor)
     if alpha is not None:
         self.setStrokeAlpha(alpha)
     elif getattr(aColor, 'alpha', None) is not None:
         self.setStrokeAlpha(aColor.alpha)
开发者ID:DDRBoxman,项目名称:Spherebot-Host-GUI,代码行数:32,代码来源:textobject.py


示例5: arcTo

 def arcTo(self, x1, y1, x2, y2, startAng=0, extent=90):
     """Like arc, but draws a line from the current point to
     the start if the start is not the current point."""
     pointList = pdfgeom.bezierArc(x1, y1, x2, y2, startAng, extent)
     self._code.append("%s l" % fp_str(pointList[0][:2]))
     for curve in pointList:
         self._code.append("%s c" % fp_str(curve[2:]))
开发者ID:BackupTheBerlios,项目名称:pixies-svn,代码行数:7,代码来源:pathobject.py


示例6: setFillColor

 def setFillColor(self, aColor, alpha=None):
     """Takes a color object, allowing colors to be referred to by name"""
     if self._enforceColorSpace:
         aColor = self._enforceColorSpace(aColor)
     if isinstance(aColor, CMYKColor):
         d = aColor.density
         c, m, y, k = (d * aColor.cyan, d * aColor.magenta, d * aColor.yellow, d * aColor.black)
         self._fillColorObj = aColor
         name = self._checkSeparation(aColor)
         if name:
             self._code.append("/%s cs %s scn" % (name, fp_str(d)))
         else:
             self._code.append("%s k" % fp_str(c, m, y, k))
     elif isinstance(aColor, Color):
         rgb = (aColor.red, aColor.green, aColor.blue)
         self._fillColorObj = aColor
         self._code.append("%s rg" % fp_str(rgb))
     elif isinstance(aColor, (tuple, list)):
         l = len(aColor)
         if l == 3:
             self._fillColorObj = aColor
             self._code.append("%s rg" % fp_str(aColor))
         elif l == 4:
             self._fillColorObj = aColor
             self._code.append("%s k" % fp_str(aColor))
         else:
             raise ValueError("Unknown color %r" % aColor)
     elif isinstance(aColor, basestring):
         self.setFillColor(toColor(aColor))
     else:
         raise ValueError("Unknown color %r" % aColor)
     if alpha is not None:
         self.setFillAlpha(alpha)
     elif getattr(aColor, "alpha", None) is not None:
         self.setFillAlpha(aColor.alpha)
开发者ID:HiTechnologia,项目名称:basri-openerp-rtl,代码行数:35,代码来源:textobject.py


示例7: setColor

 def setColor(self, color):
     if self._color!=color:
         self._color = color
         if color:
             if hasattr(color, "cyan"):
                 self.code_append('%s setcmykcolor' % fp_str(color.cyan, color.magenta, color.yellow, color.black))
             else:
                 self.code_append('%s setrgbcolor' % fp_str(color.red, color.green, color.blue))
开发者ID:ingob,项目名称:mwlib.ext,代码行数:8,代码来源:renderPS.py


示例8: setTextOrigin

 def setTextOrigin(self, x, y):
     if self._canvas.bottomup:
         self._code.append('1 0 0 1 %s Tm' % fp_str(x, y)) #bottom up
     else:
         self._code.append('1 0 0 -1 %s Tm' % fp_str(x, y))  #top down
     self._x = x
     self._y = y
     self._x0 = x #the margin
开发者ID:broodjeaap,项目名称:project-78-hr-2011-groep1,代码行数:8,代码来源:textobject.py


示例9: __repr__

 def __repr__(self):
     return "%s(%s%s%s%s%s)" % (self.__class__.__name__,
         fp_str(self.cyan*100, self.magenta*100, self.yellow*100, self.black*100).replace(' ',','),
         (self.spotName and (',spotName='+repr(self.spotName)) or ''),
         (self.density!=1 and (',density='+fp_str(self.density*100)) or ''),
         (self.knockout is not None and (',knockout=%d' % self.knockout) or ''),
         (self.alpha is not None and (',alpha=%d' % (self.alpha*100)) or ''),
         )
开发者ID:commtrack,项目名称:commcare-hq,代码行数:8,代码来源:colors.py


示例10: drawCurve

 def drawCurve(self, x1, y1, x2, y2, x3, y3, x4, y4, closed=0):
     codeline = "%s m %s curveto"
     data = (fp_str(x1, y1), fp_str(x2, y2, x3, y3, x4, y4))
     if self._fillColor != None:
         self.setColor(self._fillColor)
         self.code_append((codeline % data) + " eofill")
     if self._strokeColor != None:
         self.setColor(self._strokeColor)
         self.code_append((codeline % data) + ((closed and " closepath") or "") + " stroke")
开发者ID:olivierdalang,项目名称:stdm,代码行数:9,代码来源:renderPS.py


示例11: setTextOrigin

    def setTextOrigin(self, x, y):
        if self._canvas.bottomup:
            self._code.append('1 0 0 1 %s Tm' % fp_str(x, y)) #bottom up
        else:
            self._code.append('1 0 0 -1 %s Tm' % fp_str(x, y))  #top down

        # The current cursor position is at the text origin
        self._x0 = self._x = x
        self._y0 = self._y = y
开发者ID:alexissmirnov,项目名称:donomo,代码行数:9,代码来源:textobject.py


示例12: lines

    def lines(self, lineList, color=None, width=None):
        # print "### lineList", lineList
        return

        if self._strokeColor != None:
            self._setColor(self._strokeColor)
            codeline = "%s m %s l stroke"
            for line in lineList:
                self.code.append(codeline % (fp_str(line[0]), fp_str(line[1])))
开发者ID:jwheare,项目名称:digest,代码行数:9,代码来源:renderSVG.py


示例13: __repr__

 def __repr__(self):
     return "%s(%s%s%s%s%s)" % (
         self.__class__.__name__,
         fp_str(self.cyan * 100, self.magenta * 100, self.yellow * 100, self.black * 100).replace(" ", ","),
         (self.spotName and (",spotName=" + repr(self.spotName)) or ""),
         (self.density != 1 and (",density=" + fp_str(self.density * 100)) or ""),
         (self.knockout is not None and (",knockout=%d" % self.knockout) or ""),
         (self.alpha is not None and (",alpha=%s" % (fp_str(self.alpha * 100))) or ""),
     )
开发者ID:pythonoob,项目名称:Rstext.me,代码行数:9,代码来源:colors.py


示例14: drawCurve

 def drawCurve(self, x1, y1, x2, y2, x3, y3, x4, y4, closed=0):
     codeline = '%s m %s curveto'
     data = (fp_str(x1, y1), fp_str(x2, y2, x3, y3, x4, y4))
     if self._fillColor != None:
         self.setColor(self._fillColor)
         self.code_append((codeline % data) + ' eofill')
     if self._strokeColor != None:
         self.setColor(self._strokeColor)
         self.code_append((codeline % data)
                         + ((closed and ' closepath') or '')
                         + ' stroke')
开发者ID:ingob,项目名称:mwlib.ext,代码行数:11,代码来源:renderPS.py


示例15: drawInlineImage

 def drawInlineImage(self, canvas): #, image, x,y, width=None,height=None):
     """Draw an Image into the specified rectangle.  If width and
     height are omitted, they are calculated from the image size.
     Also allow file names as well as images.  This allows a
     caching mechanism"""
     (x,y) = self.point
     # this says where and how big to draw it
     if not canvas.bottomup: y = y+self.height
     canvas._code.append('q %s 0 0 %s cm' % (fp_str(self.width), fp_str(self.height, x, y)))
     # self._code.extend(imagedata) if >=python-1.5.2
     for line in self.imageData:
         canvas._code.append(line)
     canvas._code.append('Q')
开发者ID:tschalch,项目名称:pyTray,代码行数:13,代码来源:pdfimages.py


示例16: polygon

    def polygon(self, p, closed=0, stroke=1, fill=1):
        assert len(p) >= 2, 'Polygon must have 2 or more points'

        start = p[0]
        p = p[1:]

        polyCode = []
        polyCode.append("%s m" % fp_str(start))
        for point in p:
            polyCode.append("%s l" % fp_str(point))
        if closed:
            polyCode.append("closepath")

        self._fillAndStroke(polyCode,stroke=stroke,fill=fill)
开发者ID:roytest001,项目名称:PythonCode,代码行数:14,代码来源:renderPS.py


示例17: polygon

    def polygon(self, p, closed=0, stroke=1, fill=1):
        assert len(p) >= 2, "Polygon must have 2 or more points"

        start = p[0]
        p = p[1:]

        poly = []
        a = poly.append
        a("%s m" % fp_str(start))
        for point in p:
            a("%s l" % fp_str(point))
        if closed:
            a("closepath")

        self._fillAndStroke(poly, stroke=stroke, fill=fill)
开发者ID:olivierdalang,项目名称:stdm,代码行数:15,代码来源:renderPS.py


示例18: arc

    def arc(self, x1, y1, x2, y2, startAng=0, extent=90):
        """Contributed to piddlePDF by Robert Kern, 28/7/99.
        Draw a partial ellipse inscribed within the rectangle x1,y1,x2,y2,
        starting at startAng degrees and covering extent degrees.   Angles
        start with 0 to the right (+x) and increase counter-clockwise.
        These should have x1<x2 and y1<y2.

        The algorithm is an elliptical generalization of the formulae in
        Jim Fitzsimmon's TeX tutorial <URL: http://www.tinaja.com/bezarc1.pdf>."""

        pointList = pdfgeom.bezierArc(x1, y1, x2, y2, startAng, extent)
        # move to first point
        self._code.append("%s m" % fp_str(pointList[0][:2]))
        for curve in pointList:
            self._code.append("%s c" % fp_str(curve[2:]))
开发者ID:BackupTheBerlios,项目名称:pixies-svn,代码行数:15,代码来源:pathobject.py


示例19: _formatText

 def _formatText(self, text):
     "Generates PDF text output operator(s)"
     if self._dynamicFont:
         #it's a truetype font and should be utf8.  If an error is raised,
         
         results = []
         font = pdfmetrics.getFont(self._fontname)
         try: #assume UTF8
             stuff = font.splitString(text, self._canvas._doc)
         except UnicodeDecodeError:
             #assume latin1 as fallback
             from reportlab.pdfbase.ttfonts import latin1_to_utf8
             from reportlab.lib.logger import warnOnce
             warnOnce('non-utf8 data fed to truetype font, assuming latin-1 data')
             text = latin1_to_utf8(text)
             stuff = font.splitString(text, self._canvas._doc)
         for subset, chunk in stuff:
             if subset != self._curSubset:
                 pdffontname = font.getSubsetInternalName(subset, self._canvas._doc)
                 results.append("%s %s Tf %s TL" % (pdffontname, fp_str(self._fontsize), fp_str(self._leading)))
                 self._curSubset = subset
             chunk = self._canvas._escape(chunk)
             results.append("(%s) Tj" % chunk)
         return string.join(results, ' ')
     else:
         text = self._canvas._escape(text)
         return "(%s) Tj" % text
开发者ID:tschalch,项目名称:pyTray,代码行数:27,代码来源:textobject.py


示例20: setStrokeColorRGB

 def setStrokeColorRGB(self, r, g, b, alpha=None):
     """Set the stroke color using positive color description
        (Red,Green,Blue).  Takes 3 arguments between 0.0 and 1.0"""
     self._strokeColorObj = (r, g, b)
     self._code.append('%s RG' % fp_str(r,g,b))
     if alpha is not None:
         self.setStrokeAlpha(alpha)
开发者ID:DDRBoxman,项目名称:Spherebot-Host-GUI,代码行数:7,代码来源:textobject.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python utils.getBytesIO函数代码示例发布时间:2022-05-26
下一篇:
Python utils.flatten函数代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap