Update
There is no need to set a default value for the box-shadow
property of #player1
in your CSS, as it will be dynamically assigned using JavaScript when the page loads (Am I right in assuming that was your intention?). You can try the following approach:
Diving into Pure JavaScript
Check out the demo (RGB values are hardcoded)
$(window).ready(function(){
var sourceImage = document.getElementById("art");
var colorThief = new ColorThief();
var color = colorThief.getColor(sourceImage);
document.getElementById('player1').style['boxShadow'] = '10px 10px 5px rgba('+ color[0] + ', ' + color[1] + ', ' + color[2] + ', 0.5)';
});
However, Internet Explorer does not support .style['boxShadow']
. As an alternative, consider utilizing jQuery with the following code:
Embracing jQuery
See the demo here (RGB values are hardcoded)
$(window).ready(function(){
var sourceImage = document.getElementById("art");
var colorThief = new ColorThief();
var color = colorThief.getColor(sourceImage);
$('#player1').css('box-shadow', '10px 10px 5px rgba('+ color[0] + ', ' + color[1] + ', ' + color[2] + ', 0.5)');
});
This implementation also works flawlessly in Internet Explorer.