I am currently experimenting with using Raphael to create a unique clock feature on my website. My goal is to animate the seconds hand to mimic the movement of a traditional clock.
Below is the code snippet I have implemented:
window.onload = function() {
var paper = new Raphael(0, 0, 400, 400);
var backGround = paper.rect(0, 0, 400, 400);
backGround.attr({
fill: "orange"
});
var face = paper.circle(100, 100, 95);
face.attr({
"fill": "#f5f5f5",
"stroke": "#ff0000",
"stroke-width": "3"
})
var hand = paper.path("M100 110L100 25");
hand.attr({
stroke: "#ffff00",
"stroke-width": 1
});
function startTime() {
var hands = now.getSeconds();
hands = checkTime(hands);
hand.animate({
transform: ['r', ((hands * 6) - 180), 200, 200]
});
setTimeout(function() {
startTime()
}, 1000);
function checkTime(i) {
if (i < 10) {
i = "0" + i
};
return i;
}
star
<script src="https://cdnjs.cloudflare.com/ajax/libs/raphael/2.1.4/raphael-min.js"></script>