JSFiddle - React, Tailwind, and code Playground
HTML
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script src="http://www.html5canvastutorials.com/libraries/kinetic-v4.3.0-beta2.js"></script>
<div id="container"></div>
JavaScript
h = $(window).height();
w = $(window).width();
y = h / 2;
x = w / 2;
r = y / 2;
var stage = new Kinetic.Stage({
container: 'container',
width: w,
height: h
});
var layer = new Kinetic.Layer();
var redArc = new Kinetic.Shape({
drawFunc: function (canvas) {
var ctx = canvas.getContext();
ctx.beginPath();
ctx.arc(x, y, r, 0, Math.PI / 2, true);
canvas.fillStroke(this);
},
x: x,
y: y,
stroke: 'rgb(255,0,0)',
strokeWidth: 20,
offset: [x, y]
});
var orangeArc = new Kinetic.Shape({
drawFunc: function (canvas) {
var ctx = canvas.getContext();
ctx.beginPath();
ctx.arc(x, y, (r - 20), 0, Math.PI / 2, true);
canvas.fillStroke(this);
},
x: x,
y: y,
stroke: 'rgb(255,165,0)',
strokeWidth: 20,
offset: [x, y]
});
var yellowArc = new Kinetic.Shape({
drawFunc: function (canvas) {
var ctx = canvas.getContext();
ctx.beginPath();
ctx.arc(x, y, (r - 40), 0, Math.PI / 2, true);
canvas.fillStroke(this);
},
x: x,
y: y,
stroke: 'rgb(255,255,0)',
strokeWidth: 20,
offset: [x, y]
});
var greenArc = new Kinetic.Shape({
drawFunc: function (canvas) {
var ctx = canvas.getContext();
ctx.beginPath();
ctx.arc(x, y, (r - 60), 0, Math.PI / 2, true);
canvas.fillStroke(this);
},
x: x,
y: y,
stroke: 'rgb(165,255,0)',
strokeWidth: 20,
offset: [x, y]
});
layer.add(redArc);
layer.add(orangeArc)
layer.add(yellowArc);
layer.add(greenArc);
stage.add(layer);
var angularSpeed = Math.PI / 2;
var redAnim = new Kinetic.Animation(function (frame) {
var angleDiff = frame.timeDiff * angularSpeed / 800;
redArc.rotate(angleDiff);
}, layer);
var orangeAnim = new Kinetic.Animation(function (frame) {
var angleDiff = -(frame.timeDiff * angularSpeed / 1000);
orangeArc.rotate(angleDiff);
}, layer);
var yellowAnim = new Kinetic.Animation(function (frame)...