Removed: tuple-unpacking args.
parent
8f9c4dedff
commit
0387a6c260
|
@ -81,14 +81,15 @@ class LTComponent(LTItem):
|
||||||
return ('<%s %s>' %
|
return ('<%s %s>' %
|
||||||
(self.__class__.__name__, bbox2str(self.bbox)))
|
(self.__class__.__name__, bbox2str(self.bbox)))
|
||||||
|
|
||||||
def set_bbox(self, (x0, y0, x1, y1)):
|
def set_bbox(self, bbox):
|
||||||
|
(x0, y0, x1, y1) = bbox
|
||||||
self.x0 = x0
|
self.x0 = x0
|
||||||
self.y0 = y0
|
self.y0 = y0
|
||||||
self.x1 = x1
|
self.x1 = x1
|
||||||
self.y1 = y1
|
self.y1 = y1
|
||||||
self.width = x1-x0
|
self.width = x1-x0
|
||||||
self.height = y1-y0
|
self.height = y1-y0
|
||||||
self.bbox = (x0, y0, x1, y1)
|
self.bbox = bbox
|
||||||
return
|
return
|
||||||
|
|
||||||
def is_empty(self):
|
def is_empty(self):
|
||||||
|
@ -158,7 +159,8 @@ class LTLine(LTCurve):
|
||||||
##
|
##
|
||||||
class LTRect(LTCurve):
|
class LTRect(LTCurve):
|
||||||
|
|
||||||
def __init__(self, linewidth, (x0, y0, x1, y1)):
|
def __init__(self, linewidth, bbox):
|
||||||
|
(x0, y0, x1, y1) = bbox
|
||||||
LTCurve.__init__(self, linewidth, [(x0, y0), (x1, y0), (x1, y1), (x0, y1)])
|
LTCurve.__init__(self, linewidth, [(x0, y0), (x1, y0), (x1, y1), (x0, y1)])
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
|
@ -79,8 +79,9 @@ class PDFTextDevice(PDFDevice):
|
||||||
scaling, charspace, wordspace, rise, dxscale)
|
scaling, charspace, wordspace, rise, dxscale)
|
||||||
return
|
return
|
||||||
|
|
||||||
def render_string_horizontal(self, seq, matrix, (x, y),
|
def render_string_horizontal(self, seq, matrix, pos,
|
||||||
font, fontsize, scaling, charspace, wordspace, rise, dxscale):
|
font, fontsize, scaling, charspace, wordspace, rise, dxscale):
|
||||||
|
(x, y) = pos
|
||||||
needcharspace = False
|
needcharspace = False
|
||||||
for obj in seq:
|
for obj in seq:
|
||||||
if isnumber(obj):
|
if isnumber(obj):
|
||||||
|
@ -97,8 +98,9 @@ class PDFTextDevice(PDFDevice):
|
||||||
needcharspace = True
|
needcharspace = True
|
||||||
return (x, y)
|
return (x, y)
|
||||||
|
|
||||||
def render_string_vertical(self, seq, matrix, (x, y),
|
def render_string_vertical(self, seq, matrix, pos,
|
||||||
font, fontsize, scaling, charspace, wordspace, rise, dxscale):
|
font, fontsize, scaling, charspace, wordspace, rise, dxscale):
|
||||||
|
(x, y) = pos
|
||||||
needcharspace = False
|
needcharspace = False
|
||||||
for obj in seq:
|
for obj in seq:
|
||||||
if isnumber(obj):
|
if isnumber(obj):
|
||||||
|
|
|
@ -54,25 +54,33 @@ def apply_png_predictor(pred, colors, columns, bitspercomponent, data):
|
||||||
MATRIX_IDENTITY = (1, 0, 0, 1, 0, 0)
|
MATRIX_IDENTITY = (1, 0, 0, 1, 0, 0)
|
||||||
|
|
||||||
|
|
||||||
def mult_matrix((a1, b1, c1, d1, e1, f1), (a0, b0, c0, d0, e0, f0)):
|
def mult_matrix(m1, m0):
|
||||||
|
(a1, b1, c1, d1, e1, f1) = m1
|
||||||
|
(a0, b0, c0, d0, e0, f0) = m0
|
||||||
"""Returns the multiplication of two matrices."""
|
"""Returns the multiplication of two matrices."""
|
||||||
return (a0*a1+c0*b1, b0*a1+d0*b1,
|
return (a0*a1+c0*b1, b0*a1+d0*b1,
|
||||||
a0*c1+c0*d1, b0*c1+d0*d1,
|
a0*c1+c0*d1, b0*c1+d0*d1,
|
||||||
a0*e1+c0*f1+e0, b0*e1+d0*f1+f0)
|
a0*e1+c0*f1+e0, b0*e1+d0*f1+f0)
|
||||||
|
|
||||||
|
|
||||||
def translate_matrix((a, b, c, d, e, f), (x, y)):
|
def translate_matrix(m, v):
|
||||||
"""Translates a matrix by (x, y)."""
|
"""Translates a matrix by (x, y)."""
|
||||||
|
(a, b, c, d, e, f) = m
|
||||||
|
(x, y) = v
|
||||||
return (a, b, c, d, x*a+y*c+e, x*b+y*d+f)
|
return (a, b, c, d, x*a+y*c+e, x*b+y*d+f)
|
||||||
|
|
||||||
|
|
||||||
def apply_matrix_pt((a, b, c, d, e, f), (x, y)):
|
def apply_matrix_pt(m, v):
|
||||||
|
(a, b, c, d, e, f) = m
|
||||||
|
(x, y) = v
|
||||||
"""Applies a matrix to a point."""
|
"""Applies a matrix to a point."""
|
||||||
return (a*x+c*y+e, b*x+d*y+f)
|
return (a*x+c*y+e, b*x+d*y+f)
|
||||||
|
|
||||||
|
|
||||||
def apply_matrix_norm((a, b, c, d, e, f), (p, q)):
|
def apply_matrix_norm(m, v):
|
||||||
"""Equivalent to apply_matrix_pt(M, (p,q)) - apply_matrix_pt(M, (0,0))"""
|
"""Equivalent to apply_matrix_pt(M, (p,q)) - apply_matrix_pt(M, (0,0))"""
|
||||||
|
(a, b, c, d, e, f) = m
|
||||||
|
(p, q) = v
|
||||||
return (a*p+c*q, b*p+d*q)
|
return (a*p+c*q, b*p+d*q)
|
||||||
|
|
||||||
|
|
||||||
|
@ -227,11 +235,13 @@ def enc(x, codec='ascii'):
|
||||||
return x.encode(codec, 'xmlcharrefreplace')
|
return x.encode(codec, 'xmlcharrefreplace')
|
||||||
|
|
||||||
|
|
||||||
def bbox2str((x0, y0, x1, y1)):
|
def bbox2str(bbox):
|
||||||
|
(x0, y0, x1, y1) = bbox
|
||||||
return '%.3f,%.3f,%.3f,%.3f' % (x0, y0, x1, y1)
|
return '%.3f,%.3f,%.3f,%.3f' % (x0, y0, x1, y1)
|
||||||
|
|
||||||
|
|
||||||
def matrix2str((a, b, c, d, e, f)):
|
def matrix2str(m):
|
||||||
|
(a, b, c, d, e, f) = m
|
||||||
return '[%.2f,%.2f,%.2f,%.2f, (%.2f,%.2f)]' % (a, b, c, d, e, f)
|
return '[%.2f,%.2f,%.2f,%.2f, (%.2f,%.2f)]' % (a, b, c, d, e, f)
|
||||||
|
|
||||||
|
|
||||||
|
@ -264,7 +274,8 @@ class Plane(object):
|
||||||
def __contains__(self, obj):
|
def __contains__(self, obj):
|
||||||
return obj in self._objs
|
return obj in self._objs
|
||||||
|
|
||||||
def _getrange(self, (x0, y0, x1, y1)):
|
def _getrange(self, bbox):
|
||||||
|
(x0, y0, x1, y1) = bbox
|
||||||
if (x1 <= self.x0 or self.x1 <= x0 or
|
if (x1 <= self.x0 or self.x1 <= x0 or
|
||||||
y1 <= self.y0 or self.y1 <= y0): return
|
y1 <= self.y0 or self.y1 <= y0): return
|
||||||
x0 = max(self.x0, x0)
|
x0 = max(self.x0, x0)
|
||||||
|
@ -306,9 +317,10 @@ class Plane(object):
|
||||||
return
|
return
|
||||||
|
|
||||||
# find(): finds objects that are in a certain area.
|
# find(): finds objects that are in a certain area.
|
||||||
def find(self, (x0, y0, x1, y1)):
|
def find(self, bbox):
|
||||||
|
(x0, y0, x1, y1) = bbox
|
||||||
done = set()
|
done = set()
|
||||||
for k in self._getrange((x0, y0, x1, y1)):
|
for k in self._getrange(bbox):
|
||||||
if k not in self._grid:
|
if k not in self._grid:
|
||||||
continue
|
continue
|
||||||
for obj in self._grid[k]:
|
for obj in self._grid[k]:
|
||||||
|
|
Loading…
Reference in New Issue