Radians Clock


In this project, you are going to extend the Cartesian Mouse project into a real-time clock that converts seconds into a position on a circle using trig functions.

Check out a working version here


Directions
  1. If you are coding outside of WoofJS.com (like in Sublime), insert the Woof_JS source tag into the <head>section of your project page:

    <script src="https://rawgit.com/stevekrouse/WoofJS/master/dist/woof.js"></script>

    Your code now speaks Woof!

  2. Setup your background to be an all-black, or another dark color.

  3. Draw the two cartesian axis lines. In the example they are red and green, but use any colors you like.
  4. Declare two text labels objects, one to show the time (timeText), the other the degrees (degreeText).
  5. Declare the secondHand marker by using the new Circle({}) call.

  6. Draw the clock face. Do this by going around the 60-second clock face, and for each second, plot a dot on the circle. HINT: convert each second to radians, and then get an (x,y) pair for each dot by using Math.sin() and Math.cos().

  7. Get fancy by changing colors and dot-sizes in the clock face.

  8. Setup a forever function.

    forever( function() {
        YOUR CODE GOES HERE
    });


    This will take care of updating the clock in real time.

  9. In the forever function, get the current Date() and pull from it the latest hours, minutes and seconds. Display those in the timeText label.

  10. Now plot the secondHand marker on the clock face by converting the current second into an X,Y dot, as you did before.

  11. Display the radians and degrees corresponding to the second in the degreeText label.

  12. Add the 2PI symbol at 12 o'clock. HINT: 960 is the charCode for the PI symbol.

  13. Add a descriptive label on the upper left of the canvas with the name of this project, and any other info you want to show the user.

  14. Keep working on the project and customizing until you are satisfied. Ask your teacher/TA to upload it to your public folder.



(c) 2017 by Code Craft Academy