WIM/WIM4.1/tp/tp4/ex1/main.js
2022-05-17 12:35:25 +02:00

55 lines
736 B
JavaScript

let color = ["#F00", "#0F0", "#00F", "#FF0", "#F0F", "#0FF"];
let height= 150
let witdh = 70;
let rayon = 50;
let valueMax = 0;
function name(argument) {
return 1;
}
data.forEach(el => valueMax += el.value);
window.onload = (()=> {
let ctx = document
.querySelector("canvas")
.getContext("2d");
let precedent_value = 0;
ctx.moveTo(witdh, height);
for (var i = 0; i<1; i++ ) {
ctx.fillStyle = color[i];
ctx.save();
ctx.beginPath();
ctx.lineTo(0, rayon);
ctx.arc(0, 0, rayon, 0, (Math.PI*2) *(data[i].value/valueMax), false);
ctx.restore();
ctx.rotate((Math.PI*2) *(data[i].value/valueMax));
ctx.lineTo(0, rayon);
ctx.fill();
ctx.stroke();
ctx.closePath();
ctx.restore();
}
})