Undocumented and inconsistent behavior when setting a Sprite's Texture to one smaller than it. (+ bonus feature request)
It seems if you change the Texture of a Sprite to be a different size than the Sprites width/height, it anchors the new Texture to the center of the Sprite.
This can be seen here: https://cdn.discordapp.com/attachments/941428558184726549/943987817787306085/Charm-tests_2022.02.17_-_16.47.26.02.mp4
Notice how the red square isn't staying on the red line, but instead being pinned to the center of the Sprite. This is because I'm switching to a Texture that is smaller than the Sprite itself.
This is made more clear in this video: https://cdn.discordapp.com/attachments/412692184182161414/944126350871101490/Charm-tests_2022.02.18_-_01.56.40.04.mp4
The red box is drawn on each Texture, as:
draw = PIL.ImageDraw.ImageDraw(tx.image)
draw.rectangle((0, 0, tx.image.width - 1, tx.image.height - 1), outline = arcade.color.RED)
The green box is the Sprite boundary, as in:
arcade.draw_lrtb_rectangle_outline(self.boyfriend.left, self.boyfriend.right, self.boyfriend.top, self.boyfriend.bottom, arcade.color.GREEN)
(though in this demo, the red box seems inconsistent as well, adding to the confusion.)
You can see the code for the custom sprite I'm using here: https://github.com/DigiDuncan/Charm/blob/master/charm/lib/adobexml.py
This should be documented behavior. The other part of this is a feature request:
The effect I'm trying to achieve is to essentially have an option to tell a Sprite that if it's Texture is smaller than it's boundary, it should anchor the Texture to a certain side (e.g.: the bottom.) So basically, I should be able to have the bottom of the red box always touch the green box. I understand why the default behavior would likely be to center it, but that option would be very helpful to me.
Essentially, the Sprite should take something of a "texture_anchor" option, in the set ["center", "top", "bottom", "left", "right", "topleft", "topright", "bottomleft", "bottomright"], defaulting to "center" (which may or may not be current behavior.)
Similar to issue #1096, I don't see doing this unless we support an anchor point, and I don't see that getting added really soon. I think that would require some careful design and prototyping.