tries to split a semicircular area into color segments in HTML canvas. Here is what I tried
ctx.save();
ctx.translate(c.width / 2, (c.height / 2)-1);
ctx.strokeStyle = "red"
ctx.lineWidth = 3;
ctx.lineCap = "round";
var x=400;
var factor=1;
for (var i = 0; i < x; i++) {
ctx.beginPath();
ctx.strokeStyle = "rgba(255,0,0,1)";
ctx.rotate((-Math.PI * factor) / x);
ctx.moveTo(122, 0);
ctx.lineTo(70, 0);
ctx.stroke();
An alternative way would be to use concentric arc () segments. I'm trying to do it now. But anyone who can cast some light will be of great help.
source
share