diff --git a/panels/clock/script.js b/panels/clock/script.js index 955df314ee7083929c6dc3f187a8b29fc0fc696d..fd702f88e349e82718b09038573de5462a496cae 100644 --- a/panels/clock/script.js +++ b/panels/clock/script.js @@ -19,7 +19,7 @@ this.loaded = function(panel, config) { afgc = analClock ? analClock.getContext("2d") : null, abgc = null, bgColor = "#FFF", - sdColor = "#EEE", + sdColor = "#DDD", icColor = "#000", date = new Date(), monthNames = ["jan","feb","mar","apr","may","jun","jul","aug","sep","oct","nov","dec"], @@ -78,19 +78,18 @@ this.loaded = function(panel, config) { if (height > width) { var size = height / 2; if (!!analClock) { - $(analClock).attr('width', width - 1).attr('height', size - 1); + $(analClock).attr('width', width).attr('height', size); } if (!!digiClock) { - $(digiClock).attr('width', width - 1).attr('height', size - 1); + $(digiClock).attr('width', width).attr('height', size); } } else { var size = height > width / 2 ? width / 2 : height; if (!!analClock) { - $(analClock).attr('width', size - 1).attr('height', height - 1); - width -= size; + $(analClock).attr('width', size).attr('height', height); } if (!!digiClock) { - $(digiClock).attr('width', width - 1).attr('height', height - 1); + $(digiClock).attr('width', width - size - 5).attr('height', height); } } calc(); @@ -283,10 +282,27 @@ this.loaded = function(panel, config) { renderAnalBackground = function() { abgc.fillStyle = bgColor; + console.log(analBGImg); + var + bc = document.createElement('canvas'), + steps = Math.ceil(Math.log(analBGImg.width / (analogRad * 2)) / Math.log(2)) - 1, + bctx; + bc.width = analBGImg.width; + bc.height = analBGImg.height; + bctx = bc.getContext('2d'); + bctx.drawImage(analBGImg, 0, 0, bc.width, bc.height); + for (var i = 0; i < steps; ++i) { + var oc = document.createElement('canvas'); + oc.width = bc.width * 0.5; + oc.height = bc.height * 0.5; + bctx = oc.getContext('2d'); + bctx.drawImage(bc, 0, 0, oc.width, oc.height); + bc = oc; + } abgc.fillRect(-analogX, -analogY, analogWidth, analogHeight); abgc.fillStyle = "black"; - console.log(analBGImg); - abgc.drawImage(analBGImg, -analogRad, -analogRad, analogRad * 2, analogRad * 2); + //abgc.drawImage(buffer, -analogRad, -analogRad, analogRad * 2, analogRad * 2); + abgc.drawImage(bc, -analogRad, -analogRad, analogRad * 2, analogRad * 2); } diff --git a/panels/clock/style.less b/panels/clock/style.less index cb9c2421a4003c68aef45c9d18f834aa945da986..1414f31af5bbaa323625e6b0980f1f96eb854a7c 100644 --- a/panels/clock/style.less +++ b/panels/clock/style.less @@ -1,3 +1,11 @@ [data-analog-clock] { - float:left; + position: relative; + display: inline; + left: 0px; +} + +[data-digital-clock] { + position: relative; + display: inline; + right: 0px; } \ No newline at end of file