Fix bug in rect.intersect(): empty rects beyond the first were

ignored instead of making the outcome empty...
This commit is contained in:
Guido van Rossum 1990-10-26 13:44:32 +00:00
parent e1f069ec98
commit 124eb94270
2 changed files with 18 additions and 16 deletions

View File

@ -29,14 +29,15 @@ def intersect(list):
if is_empty(list[0]): return empty if is_empty(list[0]): return empty
(left, top), (right, bottom) = list[0] (left, top), (right, bottom) = list[0]
for rect in list[1:]: for rect in list[1:]:
if not is_empty(rect): if is_empty(rect):
(l, t), (r, b) = rect return empty
if left < l: left = l (l, t), (r, b) = rect
if top < t: top = t if left < l: left = l
if right > r: right = r if top < t: top = t
if bottom > b: bottom = b if right > r: right = r
if is_empty((left, top), (right, bottom)): if bottom > b: bottom = b
return empty if is_empty((left, top), (right, bottom)):
return empty
return (left, top), (right, bottom) return (left, top), (right, bottom)

View File

@ -29,14 +29,15 @@ def intersect(list):
if is_empty(list[0]): return empty if is_empty(list[0]): return empty
(left, top), (right, bottom) = list[0] (left, top), (right, bottom) = list[0]
for rect in list[1:]: for rect in list[1:]:
if not is_empty(rect): if is_empty(rect):
(l, t), (r, b) = rect return empty
if left < l: left = l (l, t), (r, b) = rect
if top < t: top = t if left < l: left = l
if right > r: right = r if top < t: top = t
if bottom > b: bottom = b if right > r: right = r
if is_empty((left, top), (right, bottom)): if bottom > b: bottom = b
return empty if is_empty((left, top), (right, bottom)):
return empty
return (left, top), (right, bottom) return (left, top), (right, bottom)