Mark 6
by Daniel Cheung
HTML
<div id="output">
</div>
<p>All numbers</p>
<div id="display">
</div>
CSS
body {
font-family: "Arial";
}
.slot {
background-color: #fff;
border-radius: 30px;
padding: 10px;
display:inline-block;
box-shadow: 0 1px 3px -1px rgba(0,0,0,0.2);
position:relative;
z-index:1;
}
.slot > .ball::before {
content: " ";
display: block;
position:absolute;
bottom: -3px;
right: -2px;
width: 40px;
height: 10px;
background: radial-gradient(ellipse at center, rgba(0,0,0,0.5) 0%, rgba(0,0,0,0) 60%);
background-position: 0 0;
z-index: -1;
}
.ball {
display: inline-block;
width: 40px;
height: 40px;
border-radius: 20px;
background-color: #f90;
line-height:36px;
text-align: center;
color: #000;
font-family: "Arial";
font-size: 12px;
margin: 0 2px;
background:
radial-gradient(ellipse at center, white 50%, transparent 51%);
background-position: 6px 4px;
background-size: 28px 28px;
background-repeat: no-repeat;
position:relative;
font-weight:bold;
}
.ball::after {
content: " ";
display: block;
position: absolute;
border-radius: 20px;
top:0;
left:0;
width:40px;
height:40px;
background:
radial-gradient(ellipse at center, rgba(255,255,255,0.65) 20%, rgba(255,255,255,0) 65%),
radial-gradient(ellipse at center, rgba(255,255,255,0.25) 0%, rgba(255,255,255,0) 65%),
radial-gradient(ellipse at center, rgba(255,255,255,0.5) 50%, rgba(255,255,255,0) 65%),
radial-gradient(ellipse at center, rgba(0,0,0,0) 20%, rgba(0,0,0,0.8) 100%);
background-position: 0px -6px, 20px 25px, 10px 2px, -16px -25px;
background-size: 40px 30px, 20px 20px, 20px 10px, 70px 70px;
background-repeat: no-repeat;
transform: rotate(-15deg);
z-index:2;
}
#display {
width: 440px;
height: 440px;
transform: rotate(-90deg);
}
#display > * {
transform: rotate(90deg);
}
.red {
background-color: #f10;
}
.green {
background-color: #7f8;
}
.blue {
background-color: #7cf;
}
JavaScript
$(function(){
var array = [];
var results = [];
for (let i = 1; i < 50; i++)
array.push(i++);
for (let i = 0; i < 7; i++)
results.push(array.splice(Math.round(Math.random()*(array.length-1)),1));
$("#output").append("<p>Numbers</p><div class='slot'></div>");
results.forEach((item, i) => {
if (i == 6)
$("#output").append("<p>Special Number</p><div class='slot'></div>");
$("#output .slot").last().append(`<span class="ball ${getBallColor(item)}">${item}</span>`);
});
for (let i = 1; i < 50; i++)
$("#display").append(`<span class="ball ${getBallColor(i)}">${i}</span>`);
});
function getBallColor(n) {
n--;
var shift = Math.floor(n / 10);
var pos = (Math.floor((n + shift) / 2)) % 3;
var colors = ["red", "blue", "green"];
return colors[pos];
}