Clarify Image._iter_children() a little.

This commit is contained in:
Andrey Golovizin 2014-08-08 17:00:14 +02:00
parent 3d6c3de316
commit 2012da7957

View file

@ -85,12 +85,17 @@ class Image(object):
line_start = None
prev_line_end = 0
def is_nonblank(row):
return row.any()
for i, row in enumerate(self.bitmap):
if row.any(): # non-blank row
if is_nonblank(row):
if line_start is None:
line_start = i
if line_start - prev_line_end >= min_space:
yield self.child_cls.space(line_start - prev_line_end, self.width)
height = line_start - prev_line_end
if height >= min_space:
yield self.child_cls.space(height, self.width)
else:
if line_start is not None:
yield self.child_cls(self._data[line_start:i, :])