JSFiddle - React, Tailwind, and code Playground
by ponyspy
HTML
<div calss="circle" id="canvas"></div>
CSS
#canvas {
margin: 20px 20px;
width: 120px;
height: 120px;
outline: 1px solid red;
}
JavaScript
var archtype = Raphael("canvas", 200, 200);
archtype.customAttributes.arc = function (xloc, yloc, value, total, R) {
var alpha = 360 / total * value,
a = (90 - alpha) * Math.PI / 180,
x = xloc + R * Math.cos(a),
y = yloc - R * Math.sin(a),
path;
if (total == value) {
path = [
["M", xloc, yloc - R],
["A", R, R, 0, 1, 1, xloc - 0.01, yloc - R]
];
} else {
path = [
["M", xloc, yloc - R],
["A", R, R, 0, +(alpha > 180), 1, x, y]
];
}
return {
path: path
};
};
var success = 50
var fail = success + 15
var text = "Урок 1"
var text = archtype.text(60, 60, text).attr({
'fill':'black',
'font-size':'12pt',
'font-family': 'sans-serif'
});
var arc_main = archtype.path().attr({
"stroke": "#c4c9c8",
"stroke-width": 8,
arc: [60, 60, 100, 100, 50]
});
var arc_fail = archtype.path().attr({
"stroke-width": 8,
"stroke": "#f00",
arc: [60, 60, 0, 100, 50]
});
var arc_success = archtype.path().attr({
"stroke-width": 8,
"stroke": "green",
arc: [60, 60, 0, 100, 50]
});
arc_fail.animate({
arc: [60, 60, fail, 100, 50]
}, 1000, "bounce");
arc_success.animate({
arc: [60, 60, success, 100, 50]
}, 1200, "bounce");