I am working on a small webapp in which I need to rotate shapes. I would like to achieve this by grabbing a point on the circle and dragging it to rotate the image.
Here is a brief illustration to help explain things:

My main circle can be dragged anywhere on the canvas. I know that this is radius (r) and where 12 hours (p0) will always be (cx, cy - r). Which I need to know, what degree p1 will be (0-360º), so I can rotate the contents of the main circle accordingly with Raphael.rotate ().
I found several different JavaScript formulations to find this ( example ), but no one seems to give me values between 0-360 and my basic math skills are terribly imperfect.
The demo version of Color Picker (sliding the cursor along the ring on the right) has the behavior that I want, but even after viewing the source Code, I can’t exactly reproduce it.
It would be recognized that anything pointing me in the right direction would be appreciated.
source share