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…
No comments yet. Log in to reply on the Fediverse. Comments will appear here.