Prize wheel using canvas.
http://lab.miguelmota.com/prize-wheel
npm install prize-wheel
Create a canvas element and give it an ID:
<canvas id="wheel"></canvas>
Initialize the wheel:
// Wheel settings object
var settings = {
el: '#wheel', // Canvas ID
members: ['Hamburgers', 'Tacos', 'Steak', 'Burritos'], // Array of members
colors: ['#C7181D', '#FCB937', '#A1B836', '#371979'], // Background color of each member
radius: 250 // wheel radius
};
// Create a wheel instance with settings
var wheel = new PrizeWheel(settings);
// Initialize the wheel
wheel.init();
// Spin the wheel with a callback after it is done
wheel.spin(function(member) {
alert(member);
});
MIT