Add new draw styles, tidy up draw functionality
parent
c449a258f1
commit
7647a7a921
|
|
@ -1333,7 +1333,7 @@
|
||||||
"name": "Numerals Clock",
|
"name": "Numerals Clock",
|
||||||
"shortName": "Numerals Clock",
|
"shortName": "Numerals Clock",
|
||||||
"icon": "numerals.png",
|
"icon": "numerals.png",
|
||||||
"version":"0.07",
|
"version":"0.08",
|
||||||
"description": "A simple big numerals clock",
|
"description": "A simple big numerals clock",
|
||||||
"tags": "numerals,clock",
|
"tags": "numerals,clock",
|
||||||
"type":"clock",
|
"type":"clock",
|
||||||
|
|
|
||||||
|
|
@ -5,3 +5,4 @@
|
||||||
0.05: Fix settings issue
|
0.05: Fix settings issue
|
||||||
0.06: Improve rendering of Numeral 1, fix issue with alarms not showing up
|
0.06: Improve rendering of Numeral 1, fix issue with alarms not showing up
|
||||||
0.07: Add date on touch and some improvements (see settings and readme)
|
0.07: Add date on touch and some improvements (see settings and readme)
|
||||||
|
0.08: Add new draw styles, tidy up draw functionality
|
||||||
|
|
|
||||||
|
|
@ -24,18 +24,33 @@ var _mCol = ["#55ff55","#ffffff","#00EFEF","#FFBF00"];
|
||||||
var _rCol = 0;
|
var _rCol = 0;
|
||||||
var interval = 0;
|
var interval = 0;
|
||||||
const REFRESH_RATE = 10E3;
|
const REFRESH_RATE = 10E3;
|
||||||
|
var drawFuncs = {
|
||||||
|
fill : function(poly,isHole){
|
||||||
|
if (isHole) g.setColor(0);
|
||||||
|
g.fillPoly(poly,true);
|
||||||
|
},
|
||||||
|
framefill : function(poly,isHole){
|
||||||
|
var c = g.getColor();
|
||||||
|
g.setColor(isHole ? 0 : ((c&0b1111011111011110)>>1)); // 16 bit half bright
|
||||||
|
g.fillPoly(poly,true);
|
||||||
|
g.setColor(c);
|
||||||
|
g.drawPoly(poly,true);
|
||||||
|
},
|
||||||
|
frame : function(poly,isHole){
|
||||||
|
g.drawPoly(poly,true);
|
||||||
|
},
|
||||||
|
thickframe : function(poly,isHole){
|
||||||
|
g.drawPoly(poly,true);
|
||||||
|
g.drawPoly(translate(1,0,poly),true);
|
||||||
|
g.drawPoly(translate(1,1,poly),true);
|
||||||
|
g.drawPoly(translate(0,1,poly),true);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
function translate(tx, ty, p){
|
function translate(tx, ty, p){
|
||||||
return p.map((x, i)=> x+((i%2)?ty:tx));
|
return p.map((x, i)=> x+((i&1)?ty:tx));
|
||||||
}
|
}
|
||||||
|
|
||||||
function fill(poly){
|
|
||||||
return g.fillPoly(poly,true);
|
|
||||||
}
|
|
||||||
|
|
||||||
function frame(poly){
|
|
||||||
return g.drawPoly(poly,true);
|
|
||||||
}
|
|
||||||
|
|
||||||
let settings = require('Storage').readJSON('numerals.json',1);
|
let settings = require('Storage').readJSON('numerals.json',1);
|
||||||
if (!settings) {
|
if (!settings) {
|
||||||
|
|
@ -47,13 +62,13 @@ if (!settings) {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
function drawNum(num,col,x,y,func){
|
function drawNum(num,col,x,y,func,funcName){
|
||||||
g.setColor(col);
|
g.setColor(col);
|
||||||
let tx = x*100+25;
|
let tx = x*100+25;
|
||||||
let ty = y*104+32;
|
let ty = y*104+32;
|
||||||
for (let i=0;i<numerals[num].length;i++){
|
for (let i=0;i<numerals[num].length;i++){
|
||||||
if (i>0) g.setColor((func==fill)?"#000000":col);
|
g.setColor(col);
|
||||||
func(translate(tx,ty,numerals[num][i]));
|
func(translate(tx,ty,numerals[num][i]), i>0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -69,11 +84,13 @@ function draw(date){
|
||||||
l1 = ("0"+(_12hour?d.getHours()%12:d.getHours())).substr(-2);
|
l1 = ("0"+(_12hour?d.getHours()%12:d.getHours())).substr(-2);
|
||||||
l2 = ("0"+d.getMinutes()).substr(-2);
|
l2 = ("0"+d.getMinutes()).substr(-2);
|
||||||
}
|
}
|
||||||
|
var drawFunc = drawFuncs[settings.drawMode];
|
||||||
|
if (drawFunc==undefined) drawFunc=drawFuncs.fill;
|
||||||
g.clearRect(0,24,240,240);
|
g.clearRect(0,24,240,240);
|
||||||
drawNum(l1[0],_hCol[_rCol],0,0,eval(settings.drawMode));
|
drawNum(l1[0],_hCol[_rCol],0,0,drawFunc);
|
||||||
drawNum(l1[1],_hCol[_rCol],1,0,eval(settings.drawMode));
|
drawNum(l1[1],_hCol[_rCol],1,0,drawFunc);
|
||||||
drawNum(l2[0],_mCol[_rCol],0,1,eval(settings.drawMode));
|
drawNum(l2[0],_mCol[_rCol],0,1,drawFunc);
|
||||||
drawNum(l2[1],_mCol[_rCol],1,1,eval(settings.drawMode));
|
drawNum(l2[1],_mCol[_rCol],1,1,drawFunc);
|
||||||
}
|
}
|
||||||
|
|
||||||
function setUpdateInt(set){
|
function setUpdateInt(set){
|
||||||
|
|
|
||||||
|
|
@ -14,26 +14,26 @@
|
||||||
let numeralsSettings = storage.readJSON('numerals.json',1);
|
let numeralsSettings = storage.readJSON('numerals.json',1);
|
||||||
if (!numeralsSettings) resetSettings();
|
if (!numeralsSettings) resetSettings();
|
||||||
if (numeralsSettings.menuButton===undefined) numeralsSettings.menuButton=22;
|
if (numeralsSettings.menuButton===undefined) numeralsSettings.menuButton=22;
|
||||||
let dm = ["fill","frame"];
|
let dm = ["fill","frame","framefill","thickframe"];
|
||||||
let col = ["rnd","r/g","y/w","o/c","b/y"];
|
let col = ["rnd","r/g","y/w","o/c","b/y"];
|
||||||
let btn = [[24,"BTN1"],[22,"BTN2"],[23,"BTN3"],[11,"BTN4"],[16,"BTN5"]];
|
let btn = [[24,"BTN1"],[22,"BTN2"],[23,"BTN3"],[11,"BTN4"],[16,"BTN5"]];
|
||||||
var menu={
|
var menu={
|
||||||
"" : { "title":"Numerals"},
|
"" : { "title":"Numerals"},
|
||||||
"Colors": {
|
"Colors": {
|
||||||
value: 0|numeralsSettings.color,
|
value: 0|numeralsSettings.color,
|
||||||
min:0,max:4,
|
min:0,max:col.length-1,
|
||||||
format: v=>col[v],
|
format: v=>col[v],
|
||||||
onchange: v=> { numeralsSettings.color=v; updateSettings();}
|
onchange: v=> { numeralsSettings.color=v; updateSettings();}
|
||||||
},
|
},
|
||||||
"Draw mode": {
|
"Draw": {
|
||||||
value: 0|dm.indexOf(numeralsSettings.drawMode),
|
value: 0|dm.indexOf(numeralsSettings.drawMode),
|
||||||
min:0,max:1,
|
min:0,max:dm.length-1,
|
||||||
format: v=>dm[v],
|
format: v=>dm[v],
|
||||||
onchange: v=> { numeralsSettings.drawMode=dm[v]; updateSettings();}
|
onchange: v=> { numeralsSettings.drawMode=dm[v]; updateSettings();}
|
||||||
},
|
},
|
||||||
"Menu button": {
|
"Menu button": {
|
||||||
value: btn.findIndex(e=>e[0]==numeralsSettings.menuButton),
|
value: btn.findIndex(e=>e[0]==numeralsSettings.menuButton),
|
||||||
min:0,max:4,
|
min:0,max:btn.length-1,
|
||||||
format: v=>btn[v][1],
|
format: v=>btn[v][1],
|
||||||
onchange: v=> { numeralsSettings.menuButton=btn[v][0]; updateSettings();}
|
onchange: v=> { numeralsSettings.menuButton=btn[v][0]; updateSettings();}
|
||||||
},
|
},
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue