SVG Clock Practice
How do I make an svg clock practice?
What is a svg clock practice? How do you make a svg clock practice? This script and codes were developed by Ajala Comfort on 11 January 2023, Wednesday.
SVG Clock Practice - Script Codes HTML Codes
<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>SVG Clock Practice</title> <link rel="stylesheet" href="css/style.css">
</head>
<body>
<svg width="100%" height="700"> <circle cx="250" cy="250" r="113" fill="rgba(20,20,20,0.05)" /> <circle cx="250" cy="250" r="100" fill="#2ecc71" stroke="#FFF" stroke-width="20" /> <g id="hands"> <line id="hourshand" x1="250" y1="250" x2="250" y2="170" stroke="#FFF" stroke-width="4" stroke-linecap="round" > <animateTransform attributeName="transform" attributeType="XML" type="rotate" from="0 250 250" to="360 250 250" dur="43200s" repeatCount="indefinite" /> </line> <line id="minuteshand" x1="250" y1="250" x2="250" y2="170" stroke="#FFF" stroke-width="2" stroke-linecap="round" > <animateTransform attributeName="transform" attributeType="XML" type="rotate" from="0 250 250" to="360 250 250" dur="3600s" repeatCount="indefinite" /> </line> <line id="secondshand" x1="250" y1="250" x2="250" y2="200" stroke="#bdc3c7" stroke-width="4" stroke-linecap="round" > <animateTransform attributeName="transform" attributeType="XML" type="rotate" from="0 250 250" to="360 250 250" dur="60s" repeatCount="indefinite" /> </line> </g>
</svg> <script src='https://code.jquery.com/jquery-2.2.4.min.js'></script> <script src="js/index.js"></script>
</body>
</html>
SVG Clock Practice - Script Codes CSS Codes
svg{background:beige;}
SVG Clock Practice - Script Codes JS Codes
/**
LOGIC1. Get the maths behind time 2.Relate the time to degree angle3.Set the hands to the angles
**/
var date = new Date();
var timeAngles = {hour:getHourAngle(date.getHours()),minutes:getSecondsandMinutesAngle(date.getMinutes()),seconds:getSecondsandMinutesAngle(date.getSeconds())}
function getSecondsandMinutesAngle(seconds){ return parseInt(seconds) * 6;//dff in 6 degrees
}
function getHourAngle(hour){return hour < 12 ? parseInt(hour) * 30 : (24-parseInt(hour)) * 30; //diff in 30 degrees
}
function set(val){return [val,250,250].join(" ");}
//SET HANDS
$("#hourshand > *").attr("from",set(timeAngles.hour ))
$("#minuteshand > *").attr("from",set(timeAngles.minutes ))
$("#secondshand > *").attr("from",set(timeAngles.seconds ))
function addTicks(repeat,angle){ if(repeat <= 0){return false;} $(document.createElementNS('http://www.w3.org/2000/svg','line')).attr({ x1:250,y1:160,x2:250,y2:180,transform: 'rotate(' + (angle) + ' 250 250)',stroke:"#FFF","stroke-width":repeat % 3 === 0 || repeat == 0 ? "5" : "1" }).appendTo("svg"); repeat -=1; angle = repeat * 30; return addTicks(repeat,angle);
}
//CALL TICK FUNCTION
addTicks(12,0);
Developer | Ajala Comfort |
Username | AJALACOMFORT |
Uploaded | January 11, 2023 |
Rating | 3 |
Size | 2,436 Kb |
Views | 6,072 |
Find the perfect freelance services for your business! Fiverr's mission is to change how the world works together. Fiverr connects businesses with freelancers offering digital services in 500+ categories. Find Developer!
Name | Size |
Calculator with ReactJs | 4,475 Kb |
Hashtables | 1,836 Kb |
Tic-Tac-Toe Free Code Camp Challenge | 5,214 Kb |
Palindrome Word | 3,421 Kb |
Material Chat app Interface with ReactJS | 5,851 Kb |
Calender with ReactJS | 6,983 Kb |
Recipe Book | 4,813 Kb |
Second Website | 6,234 Kb |
Basic ReactJs Form | 5,214 Kb |
Slide Show with ReactJs | 3,672 Kb |
Jasper is the AI Content Generator that helps you and your team break through creative blocks to create amazing, original content 10X faster. Discover all the ways the Jasper AI Content Platform can help streamline your creative workflows. Start For Free!
Name | Username | Size |
Count checked checkboxes with jQuery | Mestika | 2,343 Kb |
Very Simple Slider | Doodlemarks | 2,682 Kb |
Chuck Norris Background | Manz | 1,967 Kb |
SVG email test v2.0 | M_J_Robbins | 2,090 Kb |
Flat iOS 7 Safari Icon | Rss | 3,332 Kb |
Basic jQuery Filter list | Mtedwards | 2,464 Kb |
Twitch JSON API | Jvhti | 2,808 Kb |
IbrahimJabbari-Effect14 | Ibrahimjabbari | 1,919 Kb |
Wip elementary os navbar | Nickcolley | 2,993 Kb |
Ball physics | Blackkbot | 3,874 Kb |
Surf anonymously, prevent hackers from acquiring your IP address, send anonymous email, and encrypt your Internet connection. High speed, ultra secure, and easy to use. Instant setup. Hide Your IP Now!