Update lib.js

master
xxDUxx 2022-02-10 11:44:49 +01:00 committed by GitHub
parent 50c17ab3bb
commit c85c501378
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 45 additions and 45 deletions

View File

@ -1,7 +1,8 @@
exports.drawClock = function(fontIndex) {
var digits = [];
if (!require("Storage").read("contourclock-"+Math.abs(parseInt(fontIndex+0.5))+".json")) return (false);
var font = JSON.parse(require("Storage").read("contourclock-"+Math.abs(parseInt(fontIndex+0.5))+".json"));
fontFile=require("Storage").read("contourclock-"+Math.abs(parseInt(fontIndex+0.5))+".json");
if (fontFile==undefined) return(false); //exit if font file not found
var font = JSON.parse(fontFile);
for (var n in font.characters) {
digits.push({width: parseInt(font.characters[n].width),
height: font.size,
@ -9,11 +10,10 @@ exports.drawClock = function(fontIndex) {
transparent: 1,
buffer:E.toArrayBuffer(atob(font.characters[n].buffer))});
}
if (n!=10) return (false); //font file seems to be invalid
var x=0;
var y = g.getHeight()/2-digits[0].height/2;
var date = new Date();
//g.clearRect(0,24,g.getWidth()-1,137);
g.clearRect(0,38,g.getWidth()-1,138);
d1=parseInt(date.getHours()/10);
d2=parseInt(date.getHours()%10);
@ -46,4 +46,4 @@ exports.drawClock = function(fontIndex) {
g.setBgColor(bg);
}
return font.name;
}
}