I am trying to create a roulette with image on each slice of canvas. So far I am successful in creating a circle and in rotating that circle. Here's a sample code:
var c = document.getElementById("myCanvas");
var ctx = c.getContext("2d");
var radius = 100;
for (var i = 0; i < 8; i++) {
ctx.beginPath();
ctx.fillStyle = 'rgb(' + Math.floor(255 - 42.5 * i) + ', 95, 180)';
// We have to add this, otherwise, it will fill the minimum area needed to fill the arc
ctx.moveTo(300, 300);
ctx.arc(300, 300, radius, i * Math.PI / 4, (i + 1) * ((Math.PI / 4)), false);
ctx.closePath();
ctx.fill();
}
ctx.stroke();
#myCanvas {
border: 1px solid #d3d3d3;
}
<canvas id="myCanvas" width="500" height="500">
Your browser does not support the HTML5 canvas tag.
</canvas>
It creates a circle with slices. Now what I am trying to do is to put images in those slices. I have used drawImage() but it didn't fulfill my purpose. So please if someone knows any solution kindly answer it. Its been 4 days that I am stuck in this issue.