本文整理匯總了Python中reportlab.graphics.shapes.Line類的典型用法代碼示例。如果您正苦於以下問題:Python Line類的具體用法?Python Line怎麽用?Python Line使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了Line類的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: makeSwatchSample
def makeSwatchSample(self,rowNo, x, y, width, height):
baseStyle = self.lines
styleIdx = rowNo % len(baseStyle)
style = baseStyle[styleIdx]
color = style.strokeColor
y = y+height/2.
if self.joinedLines:
dash = getattr(style, 'strokeDashArray', getattr(baseStyle,'strokeDashArray',None))
strokeWidth= getattr(style, 'strokeWidth', getattr(style, 'strokeWidth',None))
L = Line(x,y,x+width,y,strokeColor=color,strokeLineCap=0)
if strokeWidth: L.strokeWidth = strokeWidth
if dash: L.strokeDashArray = dash
else:
L = None
if hasattr(style, 'symbol'):
S = style.symbol
elif hasattr(baseStyle, 'symbol'):
S = baseStyle.symbol
else:
S = None
if S: S = uSymbol2Symbol(S,x+width/2.,y,color)
if S and L:
g = Group()
g.add(L)
g.add(S)
return g
return S or L
示例2: makeSwatchSample
def makeSwatchSample(self,rowNo, x, y, width, height):
styleCount = len(self.lines)
styleIdx = rowNo % styleCount
rowColor = self.lines[styleIdx].strokeColor
if self.joinedLines:
dash = getattr(self.lines[styleIdx], 'strokeDashArray', getattr(self.lines,'strokeDashArray',None))
strokeWidth= getattr(self.lines[styleIdx], 'strokeWidth', getattr(self.lines[styleIdx], 'strokeWidth',None))
L = Line(x,y,x+width,y+height,strokeColor=rowColor,strokeLineCap=0)
if strokeWidth: L.strokeWidth = strokeWidth
if dash: L.strokeDashArray = dash
else:
L = None
if hasattr(self.lines[styleIdx], 'symbol'):
S = self.lines[styleIdx].symbol
elif hasattr(self.lines, 'symbol'):
S = self.lines.symbol
else:
S = None
if S: S = uSymbol2Symbol(S,x+width/2.,y+height/2.,rowColor)
if S and L:
g = Group()
g.add(S)
g.add(L)
return g
return S or L
示例3: _draw_segment
def _draw_segment(self, cur_drawing):
"""Draw a half circle representing the end of a linear chromosome.
"""
# set the coordinates of the segment -- it'll take up the left part
# of the space we have.
width = (self.end_x_position - self.start_x_position) \
* self.chr_percent
height = self.start_y_position - self.end_y_position
center_x = self.start_x_position + width / 2
if self._inverted:
center_y = self.start_y_position
start_angle = 180
end_angle = 360
else:
center_y = self.end_y_position
start_angle = 0
end_angle = 180
cap_wedge = Wedge(center_x, center_y, width / 2,
start_angle, end_angle, height / 2)
cap_wedge.fillColor = self.fill_color
cur_drawing.add(cap_wedge)
# draw a line to cover up the the bottom part of the wedge
if self._inverted:
cover_line = Line(self.start_x_position, self.start_y_position,
self.start_x_position + width,
self.start_y_position)
else:
cover_line = Line(self.start_x_position, self.end_y_position,
self.start_x_position + width,
self.end_y_position)
if self.fill_color is not None:
cover_color = self.fill_color
else:
cover_color = colors.white
cover_line.strokeColor = cover_color
cur_drawing.add(cover_line)
示例4: makeInnerLines
def makeInnerLines(self):
# inner grid lines
group = Group()
w, h = self.width, self.height
if self.useLines == 1:
if self.orientation == 'vertical':
r = self.makeLinePosList(self.x, isX=1)
for x in r:
line = Line(x, self.y, x, self.y + h)
line.strokeColor = self.strokeColor
line.strokeWidth = self.strokeWidth
group.add(line)
elif self.orientation == 'horizontal':
r = self.makeLinePosList(self.y, isX=0)
for y in r:
line = Line(self.x, y, self.x + w, y)
line.strokeColor = self.strokeColor
line.strokeWidth = self.strokeWidth
group.add(line)
return group
示例5: draw
def draw(self):
l = Line(self.x,self.y,self.x+self.width,self.y)
l.strokeColor = self.strokeColor
l.strokeDashArray = self.strokeDashArray
l.strokeWidth = self.height
return l
示例6: render
#.........這裏部分代碼省略.........
target = element
break
if target is None:
msg = "Could not find use node '%s'" % link_id
raise SVGError(msg)
self.render(target, group)
parent.add(group)
# apply transform
transforms = node.get('transform')
if transforms:
for op in parseTransform.iterparse(transforms):
self.applyTransformOnGroup(group, op)
# apply 'x' and 'y' attribute as translation of defs object
if node.get('x') or node.get('y'):
dx = parseLength(node.get('x','0'))
dy = parseLength(node.get('y','0'))
self.applyTransformOnGroup(group, ('translate', (dx,dy)))
self.level -= 1
elif node.tag == self.SVG_LINE:
# get coordinates
x1 = parseLength(node.get('x1', '0'))
y1 = parseLength(node.get('y1', '0'))
x2 = parseLength(node.get('x2', '0'))
y2 = parseLength(node.get('y2', '0'))
shape = Line(x1, y1, x2, y2)
self.addShape(parent, node, shape)
elif node.tag == self.SVG_RECT:
# get coordinates
x = parseLength(node.get('x', '0'))
y = parseLength(node.get('y', '0'))
width = parseLength(node.get('width'))
height = parseLength(node.get('height'))
rx = parseLength(node.get('rx', '0'))
ry = parseLength(node.get('ry', '0'))
shape = Rect(x, y, width, height, rx=rx, ry=ry)
self.addShape(parent, node, shape)
elif node.tag == self.SVG_CIRCLE:
cx = parseLength(node.get('cx', '0'))
cy = parseLength(node.get('cy', '0'))
r = parseLength(node.get('r'))
if r > 0.:
shape = Circle(cx, cy, r)
self.addShape(parent, node, shape)
elif node.tag == self.SVG_ELLIPSE:
cx = parseLength(node.get('cx', '0'))
cy = parseLength(node.get('cy', '0'))
rx = parseLength(node.get('rx'))
ry = parseLength(node.get('ry'))
if rx > 0. and ry > 0.:
shape = Ellipse(cx, cy, rx, ry)