Home javascript How to implement a circle with degrees on js?

How to implement a circle with degrees on js?




I want to do something similar as on this site
Here is such a range of degrees that varies from the position of the cursor.

How can I implement it?

Answer 1, Authority 100%

There was the topic “Eyes, following the cursor”

Eyes that follow the cursor on JS

In fact, you need to do the same, only instead of changing the position of the eye to output an angle (which is also calculated)

i.e. The algorithm should be:

  1. define the center of the circle (define its borders and calculate the center)
  2. Define the position of the mouse cursor in the
  3. window

  4. calculate the angle (it is better to use asin , acos , and not atan so as not to get division at some angles)
  5. output the arrow position on the circle (using the rotation transformation style to the desired angle)
  6. output the value of the angle

Programmers, Start Your Engines!

Why spend time searching for the correct question and then entering your answer when you can find it in a second? That's what CompuTicket is all about! Here you'll find thousands of questions and answers from hundreds of computer languages.

Recent questions