Clarify Image._iter_children() a little.
This commit is contained in:
parent
3d6c3de316
commit
2012da7957
1 changed files with 8 additions and 3 deletions
|
|
@ -85,12 +85,17 @@ class Image(object):
|
||||||
|
|
||||||
line_start = None
|
line_start = None
|
||||||
prev_line_end = 0
|
prev_line_end = 0
|
||||||
|
|
||||||
|
def is_nonblank(row):
|
||||||
|
return row.any()
|
||||||
|
|
||||||
for i, row in enumerate(self.bitmap):
|
for i, row in enumerate(self.bitmap):
|
||||||
if row.any(): # non-blank row
|
if is_nonblank(row):
|
||||||
if line_start is None:
|
if line_start is None:
|
||||||
line_start = i
|
line_start = i
|
||||||
if line_start - prev_line_end >= min_space:
|
height = line_start - prev_line_end
|
||||||
yield self.child_cls.space(line_start - prev_line_end, self.width)
|
if height >= min_space:
|
||||||
|
yield self.child_cls.space(height, self.width)
|
||||||
else:
|
else:
|
||||||
if line_start is not None:
|
if line_start is not None:
|
||||||
yield self.child_cls(self._data[line_start:i, :])
|
yield self.child_cls(self._data[line_start:i, :])
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue