From e3fc267821461a5529a99b22e0b480e92aa5f8a8 Mon Sep 17 00:00:00 2001 From: s2 Date: Wed, 13 Dec 2017 09:04:14 +0100 Subject: [PATCH] fix favicon size --- src/bg.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/bg.js b/src/bg.js index ac2fc89..42142d6 100644 --- a/src/bg.js +++ b/src/bg.js @@ -4,8 +4,6 @@ let tabIcons = {}; var changeIcon = function(color, currentIcon, options) { var canvas = document.createElement('canvas'); - canvas.width = 16; - canvas.height = 16; var ctx = canvas.getContext('2d'); var img = new Image(); @@ -16,12 +14,14 @@ var changeIcon = function(color, currentIcon, options) { } img.onload = function() { + canvas.width = this.naturalWidth; + canvas.height = this.naturalHeight; ctx.drawImage(img, 0, 0); ctx.fillStyle = color; if (options.globals.orientation === 'vertical') { - ctx.fillRect(0, 0, options.globals.width, 16); + ctx.fillRect(0, 0, (options.globals.width / 16) * canvas.width, canvas.height); } else { - ctx.fillRect(0, 0, 16, options.globals.width); + ctx.fillRect(0, 0, canvas.width, (options.globals.width / 16) * canvas.height); } var link = document.createElement('link');