VID_20240323232852.mp4
This project implements a digital and analog clock with a dynamic background color. The JavaScript file script.js
contains the logic for updating the clock and changing the background color.
The getcolor()
function generates a random RGB color value to be used as the background color for the clock. It calculates three random values between 0 and 255 for the red, green, and blue components of the color.
The clock hands' angles are calculated based on the current time using the updateClock()
function. It retrieves the current hour, minute, and second and computes the angles for the hour, minute, and second hands.
The rotateLine(element, angle, value)
function rotates the clock hands (hour, minute, and second) to their respective angles calculated in the updateClock()
function. It also updates the clock numbers accordingly to reflect the current time.
The updateClockAndColor()
function synchronizes the intervals for updating the clock and changing the background color. It calls both updateClock()
and getcolor()
functions to update the clock and background color simultaneously.