Added colors in chrome android

This commit is contained in:
Kasper Rynning-Tønnesen
2015-07-30 12:45:04 +02:00
parent 9ac2f14c6b
commit 6fc9a7c392
4 changed files with 14 additions and 1 deletions

View File

@@ -157,6 +157,15 @@ var Helper = {
if(l>0.5)l=0.5; //make sure it isnt too light
return "hsl("+Math.floor(h*360)+", "+Math.floor(s*100)+"%, "+Math.floor(l*100)+"%)";
},
componentToHex: function(c) {
var hex = c.toString(16);
return hex.length == 1 ? "0" + hex : hex;
},
rgbToHex: function(r, g, b) {
return "#" + Helper.componentToHex(r) + Helper.componentToHex(g) + Helper.componentToHex(b);
}
}

View File

@@ -141,11 +141,14 @@ var Youtube = {
setBGimage: function(id){
if(id !== undefined)
{
console.log($("meta[name=theme-color]").attr("content", ""));
var img = new Image();
img.onload = function ()
{
var colorThief = new ColorThief();
document.getElementsByTagName("body")[0].style.backgroundColor = Helper.rgbToHsl(colorThief.getColor(img));
$("meta[name=theme-color]").attr("content", Helper.rgbToHex(colorThief.getColor(img)));
};
img.crossOrigin = 'Anonymous';