Report, then Anti-Duplication 0 ▲ ronjeffries.com 177 days ago · 11 min read2180 words · Tech · hide · Fediverse post TI made some changes to the scaling of images. I’ll report on that, but what I really want to do is to eliminate some duplication. I surprise myself. I found an incantation in Arcade/Pillow that returns the bounding box of a texture that includes transparent pixels. Applied that, didn’t entirely like the result, added a scaling factor to the scale_texture function. Here’s what we’ve got now: params.py # dungeon parameters cell_size = 16 def scale_texture(texture, adjust=1): pil = texture.image x0, y1, x1, y0 = pil.getbbox() x = x1 - x0 y = y1 - y0 size = x if x > y else y return cell_size / size * adjust Get the bounding box in left upper right bottom order because that’’s what you get; get the width and height. (Should rename those, will do in a moment.) Get the max as size, scale to that size times the adjustment factor. Same basic scaling as before,, cell_size/size, except that we use the visible size of the texture, and we can adjust it by a factor. The factor is there because… Commenting on Bubbles has been removed. Why? If you want to talk about this post, write to the author, use the comments on their blog if it has them, or reply with a "RE:" post on your own blog. Suggestions? feedback@bubbles.town