Added conversion from rectangles to ranges

This commit is contained in:
Rob McMullen 2016-02-11 13:27:52 -08:00
parent 20c5b35d9c
commit c02b983d06

View File

@ -353,6 +353,15 @@ class DefaultSegment(object):
indexes = np.tile(np.arange(c), r) + np.repeat(np.arange(r) * self.map_width, c) + start indexes = np.tile(np.arange(c), r) + np.repeat(np.arange(r) * self.map_width, c) + start
s[indexes] |= style_bits s[indexes] |= style_bits
def rects_to_ranges(self, rects):
ranges = []
bpr = self.map_width
for (r1, c1), (r2, c2) in rects:
start = r1 * bpr + c1
end = (r2 - 1) * bpr + c2
ranges.append((start, end))
return ranges
def clear_style_bits(self, **kwargs): def clear_style_bits(self, **kwargs):
style_mask = self.get_style_mask(**kwargs) style_mask = self.get_style_mask(**kwargs)
self.style &= style_mask self.style &= style_mask