本文整理汇总了Python中reportlab.graphics.shapes.Group.shift方法的典型用法代码示例。如果您正苦于以下问题:Python Group.shift方法的具体用法?Python Group.shift怎么用?Python Group.shift使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类reportlab.graphics.shapes.Group
的用法示例。
在下文中一共展示了Group.shift方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: draw
# 需要导入模块: from reportlab.graphics.shapes import Group [as 别名]
# 或者: from reportlab.graphics.shapes.Group import shift [as 别名]
def draw(self):
s = float(self.size) #abbreviate as we will use this a lot
g = Group()
# new algorithm from markers.StarFive
R = float(self.size)/2
r = R*sin(18*(pi/180.0))/cos(36*(pi/180.0))
P = []
angle = 90
for i in xrange(5):
for radius in R, r:
theta = angle*(pi/180.0)
P.append(radius*cos(theta))
P.append(radius*sin(theta))
angle = angle + 36
# star specific bits
star = Polygon(P,
fillColor = self.fillColor,
strokeColor = self.strokeColor,
strokeWidth=s/50)
g.rotate(self.angle)
g.shift(self.x+self.dx,self.y+self.dy)
g.add(star)
return g
示例2: _borderDraw
# 需要导入模块: from reportlab.graphics.shapes import Group [as 别名]
# 或者: from reportlab.graphics.shapes.Group import shift [as 别名]
def _borderDraw(self,f):
s = self.size # abbreviate as we will use this a lot
g = Group()
g.add(f)
x, y, sW = self.x+self.dx, self.y+self.dy, self.strokeWidth/2.
g.insert(0,Rect(-sW, -sW, width=getattr(self,'_width',2*s)+3*sW, height=getattr(self,'_height',s)+2*sW,
fillColor = None, strokeColor = self.strokeColor, strokeWidth=sW*2))
g.shift(x,y)
g.scale(s/_size, s/_size)
return g
示例3: draw
# 需要导入模块: from reportlab.graphics.shapes import Group [as 别名]
# 或者: from reportlab.graphics.shapes.Group import shift [as 别名]
def draw(self):
fillColor = self.fillColor
strokeColor = self.strokeColor
g = Group()
bg = self.background
bd = self.border
bdw = self.borderWidth
shadow = self.shadow
x, y = self.x, self.y
if bg:
if shadow is not None and 0<=shadow<1:
shadow = Color(bg.red*shadow,bg.green*shadow,bg.blue*shadow)
self._paintLogo(g,dy=-2.5, dx=2,fillColor=shadow)
self._paintLogo(g,fillColor=fillColor,strokeColor=strokeColor)
g.skew(kx=self.skewX, ky=self.skewY)
g.shift(self._dx,self._dy)
G = Group()
G.add(g)
_w, _h = 130, 86
w, h = self.width, self.height
if bg or (bd and bdw):
G.insert(0,Rect(0,0,_w,_h,fillColor=bg,strokeColor=bd,strokeWidth=bdw))
if w!=_w or h!=_h: G.scale(w/float(_w),h/float(_h))
angle = self.angle
if self.angle:
w, h = w/2., h/2.
G.shift(-w,-h)
G.rotate(angle)
G.shift(w,h)
G.shift(x,y)
return G
示例4: draw
# 需要导入模块: from reportlab.graphics.shapes import Group [as 别名]
# 或者: from reportlab.graphics.shapes.Group import shift [as 别名]
def draw(self):
fillColor = self.fillColor
strokeColor = self.strokeColor
g = Group()
bg = self.background
bd = self.border
bdw = self.borderWidth
shadow = self.shadow
x, y = self.x, self.y
if bg:
if shadow is not None and 0 <= shadow < 1:
shadow = Color(bg.red * shadow, bg.green * shadow, bg.blue * shadow)
self._paintLogo(g, dy=-2.5, dx=2, fillColor=shadow)
self._paintLogo(
g,
fillColor=fillColor,
strokeColor=strokeColor,
_ocolors=getattr(self, "_ocolors", None),
_pagecolors=getattr(self, "_pagecolors", None),
)
g.skew(kx=self.skewX, ky=self.skewY)
g.shift(self._dx, self._dy)
G = Group()
G.add(g)
_w, _h = 130, 86
w, h = self.width, self.height
if bg or (bd and bdw):
G.insert(0, Rect(0, 0, _w, _h, fillColor=bg, strokeColor=bd, strokeWidth=bdw))
if w != _w or h != _h:
G.scale(w / float(_w), h / float(_h))
angle = self.angle
if self.angle:
w, h = w / 2.0, h / 2.0
G.shift(-w, -h)
G.rotate(angle)
G.shift(w, h)
xFlip = getattr(self, "xFlip", 0) and -1 or 0
yFlip = getattr(self, "yFlip", 0) and -1 or 0
if xFlip or yFlip:
sx = xFlip or 1
sy = yFlip or 1
G.shift(sx * x + w * xFlip, sy * y + yFlip * h)
G = Group(G, transform=(sx, 0, 0, sy, 0, 0))
else:
G.shift(x, y)
return G
示例5: draw
# 需要导入模块: from reportlab.graphics.shapes import Group [as 别名]
# 或者: from reportlab.graphics.shapes.Group import shift [as 别名]
def draw(self):
g = Group()
ys = self.bottomPadding+(self.triangleHeight/2)+self.sourceLabelOffset+self.sourceLabelFontSize
if self.background:
x,y = self._getDrawingDimensions()
g.add(Rect(-self.leftPadding,-ys,x,y,
strokeColor=None,
strokeWidth=0,
fillColor=self.background))
ascent=getFont(self.labelFontName).face.ascent/1000.
if ascent==0: ascent=0.718 # default (from helvetica)
ascent=ascent*self.labelFontSize # normalize
colorsList = self._getColors()
# Draw the boxes - now uses ShadedRect from grids
x=0
for f in range (0,self.numberOfBoxes):
sr=ShadedRect()
sr.x=x
sr.y=0
sr.width=self.boxWidth
sr.height=self.boxHeight
sr.orientation = 'vertical'
sr.numShades = 30
sr.fillColorStart = colorsList[f]
sr.fillColorEnd = colorsList[f+1]
sr.strokeColor = None
sr.strokeWidth = 0
g.add(sr)
g.add(Rect(x,0,self.boxWidth,self.boxHeight,
strokeColor=self.boxOutlineColor,
strokeWidth=self.boxOutlineWidth,
fillColor=None))
g.add(String(x+self.boxWidth/2.,(self.boxHeight-ascent)/2.,
text = str(f+1),
fillColor = self.labelFillColor,
strokeColor=self.labelStrokeColor,
textAnchor = 'middle',
fontName = self.labelFontName,
fontSize = self.labelFontSize))
x=x+self.boxWidth+self.boxSpacing
#do triangles
xt = (self.trianglePosition*self.boxWidth)
if self.trianglePosition>1:
xt = xt+(self.trianglePosition-1)*self.boxSpacing
xt = xt-(self.boxWidth/2)
g.add(Polygon(
strokeColor = self.triangleStrokeColor,
strokeWidth = self.triangleStrokeWidth,
fillColor = self.triangleFillColor,
points=[xt,self.boxHeight-(self.triangleHeight/2),
xt-(self.triangleWidth/2),self.boxHeight+(self.triangleHeight/2),
xt+(self.triangleWidth/2),self.boxHeight+(self.triangleHeight/2),
xt,self.boxHeight-(self.triangleHeight/2)]))
g.add(Polygon(
strokeColor = self.triangleStrokeColor,
strokeWidth = self.triangleStrokeWidth,
fillColor = self.triangleFillColor,
points=[xt,0+(self.triangleHeight/2),
xt-(self.triangleWidth/2),0-(self.triangleHeight/2),
xt+(self.triangleWidth/2),0-(self.triangleHeight/2),
xt,0+(self.triangleHeight/2)]))
#source label
if self.sourceLabelText != None:
g.add(String(x-self.boxSpacing,0-(self.triangleHeight/2)-self.sourceLabelOffset-(self.sourceLabelFontSize),
text = self.sourceLabelText,
fillColor = self.sourceLabelFillColor,
textAnchor = 'end',
fontName = self.sourceLabelFontName,
fontSize = self.sourceLabelFontSize))
g.shift(self.leftPadding, ys)
return g