scripts: maps: Fixed divide-by-zero when packing blocks into small maps
This can be hit when dealing with very small maps, which is common since we're rendering to the terminal. Not crashing here at least allows the header/usage string to be shown.
This commit is contained in:
+3
-3
@@ -4598,11 +4598,11 @@ def main_(ring, disk, mroots=None, *,
|
|||||||
# well for things that are often powers-of-two
|
# well for things that are often powers-of-two
|
||||||
block_cols_ = 1
|
block_cols_ = 1
|
||||||
block_rows_ = len(bmap)
|
block_rows_ = len(bmap)
|
||||||
while (abs(((canvas.width/(block_cols_ * 2))
|
while (abs(((canvas.width/(block_cols_*2))
|
||||||
/ (canvas.height/mt.ceil(block_rows_ / 2)))
|
/ max(canvas.height/mt.ceil(block_rows_/2), 1))
|
||||||
- block_ratio)
|
- block_ratio)
|
||||||
< abs(((canvas.width/block_cols_)
|
< abs(((canvas.width/block_cols_)
|
||||||
/ (canvas.height/block_rows_)))
|
/ max(canvas.height/block_rows_, 1)))
|
||||||
- block_ratio):
|
- block_ratio):
|
||||||
block_cols_ *= 2
|
block_cols_ *= 2
|
||||||
block_rows_ = mt.ceil(block_rows_ / 2)
|
block_rows_ = mt.ceil(block_rows_ / 2)
|
||||||
|
|||||||
@@ -4918,11 +4918,11 @@ def main(disk, output, mroots=None, *,
|
|||||||
# well for things that are often powers-of-two
|
# well for things that are often powers-of-two
|
||||||
block_cols_ = 1
|
block_cols_ = 1
|
||||||
block_rows_ = len(bmap)
|
block_rows_ = len(bmap)
|
||||||
while (abs(((width__/(block_cols_ * 2))
|
while (abs(((width__/(block_cols_*2))
|
||||||
/ (height__/mt.ceil(block_rows_ / 2)))
|
/ max(height__/mt.ceil(block_rows_/2), 1))
|
||||||
- block_ratio)
|
- block_ratio)
|
||||||
< abs(((width__/block_cols_)
|
< abs(((width__/block_cols_)
|
||||||
/ (height__/block_rows_)))
|
/ max(height__/block_rows_, 1)))
|
||||||
- block_ratio):
|
- block_ratio):
|
||||||
block_cols_ *= 2
|
block_cols_ *= 2
|
||||||
block_rows_ = mt.ceil(block_rows_ / 2)
|
block_rows_ = mt.ceil(block_rows_ / 2)
|
||||||
|
|||||||
+3
-3
@@ -1794,11 +1794,11 @@ def main(path='-', *,
|
|||||||
# well for things that are often powers-of-two
|
# well for things that are often powers-of-two
|
||||||
block_cols_ = 1
|
block_cols_ = 1
|
||||||
block_rows_ = len(bmap)
|
block_rows_ = len(bmap)
|
||||||
while (abs(((canvas.width/(block_cols_ * 2))
|
while (abs(((canvas.width/(block_cols_*2))
|
||||||
/ (canvas.height/mt.ceil(block_rows_ / 2)))
|
/ max(canvas.height/mt.ceil(block_rows_/2), 1))
|
||||||
- block_ratio)
|
- block_ratio)
|
||||||
< abs(((canvas.width/block_cols_)
|
< abs(((canvas.width/block_cols_)
|
||||||
/ (canvas.height/block_rows_)))
|
/ max(canvas.height/block_rows_, 1)))
|
||||||
- block_ratio):
|
- block_ratio):
|
||||||
block_cols_ *= 2
|
block_cols_ *= 2
|
||||||
block_rows_ = mt.ceil(block_rows_ / 2)
|
block_rows_ = mt.ceil(block_rows_ / 2)
|
||||||
|
|||||||
Reference in New Issue
Block a user