本文整理汇总了Python中reportlab.lib.utils.fp_str函数的典型用法代码示例。如果您正苦于以下问题:Python fp_str函数的具体用法?Python fp_str怎么用?Python fp_str使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了fp_str函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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 ""),
)
示例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)
示例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 ''),
)
示例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)
示例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:]))
示例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)
示例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))
示例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
示例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 ''),
)
示例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")
示例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
示例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])))
示例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 ""),
)
示例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')
示例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')