Rotation is just an extra step. The math to rotate is:
NewX=(x-centerX)*cos(a)-(y-centerY)*sin(a)+centerX
NewY=(x-centerX)*sin(a)+(y-centerY)*cos(a)+centerY
So you’d take the mouse location and rotate it by sprite.angle around the sprite’s location as the center. And you’d just use that rotated mouse location in the steps in the previous post.
The scaling is already handled.
You could have it work with the origin in other locations such as centered but it just takes fiddling with the math a bit.