Example 1: spin the wheel html
// winwheel.js is the best js library to build a spin the wheel or wheel of fortune
//download the library and you are ready to go
<html>
<head>
<title>Wheel of fortune Wheel</title>
<script src='Winwheel.js'></script>
</head>
<body>
<canvas id='canvas' width='880' height='300'>
Canvas not supported, use another browser.
</canvas>
<script>
let theWheel = new Winwheel({
'outerRadius' : 212,
'innerRadius' : 75,
'textFontSize' : 24,
'textOrientation' : 'vertical',
'textAlignment' : 'outer',
'numSegments' : 24,
'segments' :
[
{'fillStyle' : '#ee1c24', 'text' : '300'},
{'fillStyle' : '#3cb878', 'text' : '450'},
{'fillStyle' : '#f6989d', 'text' : '600'},
{'fillStyle' : '#00aef0', 'text' : '750'},
{'fillStyle' : '#f26522', 'text' : '500'},
{'fillStyle' : '#000000', 'text' : 'BANKRUPT', 'textFontSize' : 16, 'textFillStyle' : '#ffffff'},
{'fillStyle' : '#e70697', 'text' : '3000'},
{'fillStyle' : '#fff200', 'text' : '600'},
{'fillStyle' : '#f6989d', 'text' : '700'},
{'fillStyle' : '#ee1c24', 'text' : '350'},
{'fillStyle' : '#3cb878', 'text' : '500'},
{'fillStyle' : '#f26522', 'text' : '800'},
{'fillStyle' : '#a186be', 'text' : '300'},
{'fillStyle' : '#fff200', 'text' : '400'},
{'fillStyle' : '#00aef0', 'text' : '650'},
{'fillStyle' : '#ee1c24', 'text' : '1000'},
{'fillStyle' : '#f6989d', 'text' : '500'},
{'fillStyle' : '#f26522', 'text' : '400'},
{'fillStyle' : '#3cb878', 'text' : '900'},
{'fillStyle' : '#000000', 'text' : 'BANKRUPT', 'textFontSize' : 16, 'textFillStyle' : '#ffffff'},
{'fillStyle' : '#a186be', 'text' : '600'},
{'fillStyle' : '#fff200', 'text' : '700'},
{'fillStyle' : '#00aef0', 'text' : '800'},
{'fillStyle' : '#ffffff', 'text' : 'LOOSE TURN', 'textFontSize' : 12}
],
'animation' :
{
'type' : 'spinToStop',
'duration' : 10,
'spins' : 3,
'callbackFinished' : alertPrize,
'callbackSound' : playSound,
'soundTrigger' : 'pin'
},
'pins' :
{
'number' : 24,
'fillStyle' : 'silver',
'outerRadius': 4,
}
});
let audio = new Audio('tick.mp3');
function playSound()
{
audio.pause();
audio.currentTime = 0;
audio.play();
}
function alertPrize(indicatedSegment)
{
if (indicatedSegment.text == 'LOOSE TURN') {
alert('Sorry but you loose a turn.');
} else if (indicatedSegment.text == 'BANKRUPT') {
alert('Oh no, you have gone BANKRUPT!');
} else {
alert("You have won " + indicatedSegment.text);
}
}
</script>
</body>
</html>
Example 2: how to make spinner in html
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
.loader {
border: 16px solid #f3f3f3;
border-radius: 50%;
border-top: 16px solid #3498db;
width: 120px;
height: 120px;
-webkit-animation: spin 2s linear infinite;
animation: spin 2s linear infinite;
}
@-webkit-keyframes spin {
0% { -webkit-transform: rotate(0deg); }
100% { -webkit-transform: rotate(360deg); }
}
@keyframes spin {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
}
</style>
</head>
<body>
<h2>How To Create A Loader</h2>
<div class="loader"></div>
</body>
</html>