So I have a Sprite, which itself has a Texture, and which may be scaled/rotated/translated. I should probably also note that it is centered, i.e.
Sprite.setOrigin(Sprite.getLocalBounds().width / 2, Sprite.getLocalBounds().height / 2);
I also have a given Point (sf::Vector2f) in global space.
If the point is within the Sprite's local bounds, I want to figure out the color of the exact pixel of the source Texture the point corresponds to.
Obviously I somehow need to convert from global to local space, but I'm not sure how to do this. My previous attempt was:
//I also tried without subtracting the position,
//since I assume that the sprite's translation is also included in its transform
Point.x -= Sprite.getPosition().x;
Point.y -= Sprite.getPosition().y;
//I also tried getTransform(), which unsurprisingly didn't work either
Point = Sprite.getInverseTransform().transformPoint(Point);
sf::Color PointColor = Sprite.getTexture()->copyToImage().getPixel(Point.x, Point.y);
What is the correct way of doing this?