font clock.

- Took out old code
- Code now too complexed for emulator so took it off
- Added ROman Numerals to vector fonts
master
adrian w kirk 2021-05-23 22:29:08 +01:00
parent 1647352838
commit 658b10fed3
8 changed files with 80 additions and 97 deletions

View File

@ -223,7 +223,7 @@
"description": "Choose the font and design of clock face from a library of available designs",
"tags": "clock",
"type":"clock",
"allow_emulator":true,
"allow_emulator":false,
"readme": "README.md",
"custom":"custom.html",
"storage": [

View File

@ -151,6 +151,14 @@
name: "grey",
background : [0.5,0.5,0.5],
second_hand: [0.0,0.0,0.0]
},
{
name: "purple",
background : [1.0,0.0,1.0]
},
{
name: "blue",
background : [0.4,0.7,1.0]
}
]
}

File diff suppressed because one or more lines are too long

View File

@ -11,22 +11,6 @@ class DigitNumeralFont extends NumeralFont{
super();
// dimension map provides the dimensions of the character for
// each number for plotting and collision detection
/*this.dimension_map = {
0 : [25,25],
1 : [10,25],
2 : [15,25],
3 : [15,25],
4 : [15,25],
5 : [15,25],
6 : [20,25],
7 : [15,25],
8 : [20,25],
9 : [20,25],
10 : [31,25],
11 : [20,25],
12: [25,25]
};*/
this.widths = atob("BgsVCw8PEBEUEBQUBw==");
this.font = atob("AAAAAAAAAAAAp9bgAAAAAAAAAAAADr+vAAAAAAAAAAAAAOv68AAAAAAAAAAAAA6/rwAAAAAAAAAAAADr+fAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAXwAAAAAAAAAAAAXz//wAAAAAAAAAXz//7q+AAAAAAAXz//8q+//wAAAAXz//8q+//yr3wAXz//8q+//yr3//ZAL/8q+//yr3//ZMAAAW+//2q3//ZQAAAAAC/2q3//pQAAAAAAAAF3//pQAAAAAAAAAAAnpQAAAAAAAAAAAAAAAAABL3//tgQAAAAAAAAj//su9//0gAAAAAC7/vv///73/gAAAAB/8/9u7u7/+34AAAA78/r/////c/+9QAAf9/P/LvLu/+///AADu/++//+7/7Pv79QAv37+/sQAAb/7978AF/f3vwAAAAD+/v+4Aj9779QAAAADs+/vwCP3vv1AAAAAOz7+/A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3d3d1AADMAAAL76//////0ACr9AAAvvr9zMzMyABd/vAAC++v7u7u7qAPz79QAL76//////wPz975AAvvr8rN7Oyw+vv+wAC++vQN37/ODs+/vgAL769A6/v9wN37+/AAvvr0Dq+/3Q/Pv78AC++vQN38/vv8+/3QAL769Ar8397+7/36AAvvr0Bfv8/s/7/PMAC++vQA77+9/a+fwAAL769ABP3f///f8gAAVnSRAAb/mrzP8wAAAAAAAAAC3///wQAAAAAAAAAAAAJiAAAAAAAAAAA2ZmZiAAAAAAAAAK7//////+YAAAAAA//Lu7u7up77AAAABP+//+7u7v/5/QAAAP7fyN///+y/+/cAAH+/n/2qqqvv7vzwAA/f3+r/////v8+/cAD7+/v82rye38/e6wBPv9zrn9388fv7/NAI/O+va+/Pzw3Pv68Aj93689z7/dDc+vrwBPv+v06/z90Pz7++AA+/3vnO/Pz+/PvuwAD7+/o4/O/56/38+QAN/v5QP8/f//7PzxAAP89QAL+f3czfj6AAAK9wAAH/v///z/EAAADQAAAC79q879EAAAAAAAAAAJ3//YAAAAAAAAAAAAAAAAAAAAAL3p9AAAAAAAAAAAAAvvr0AAAAAAAAAAAAC++vQAAAAAAAAAAAAL769AAAAAAAAFrgAAvvr0AAAAAFrv/9AAC++vQAAFvv/9u98AAL769Wvv/8u9//6gAArN7//8u+//67z/AACv/8u+//27z//roAAFu+//273//rvP/wAAv/273//rvP//xxAABb3//rvP//xxAAAAAL/rvP//thAAAAAAAAXP/+thAAAAAAAAAACutgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAGt/qYCvv2kAAAAAAb/69/+/+vP/AAAAAT+z//q/8//6/8QAAP8/7u9/P+7z/v7AADv36//+/v///778gAfv7/Lr/7++3/vz6AG+/7+/9+/v//Pz+0Aj8789d77+/Ds+/zwCf3Pryvuv68N36+vAJ/c+vK+6/rwzfr68An9z68r7r+vDN+vrwCPzvz1v+z78ez6+/AE+/7//fzv3+/Pv98AD7+/ne+/v57e/e/QAO7v3//9/u/v+vr2AAT9/7u9+v68uvz/AAAM/O////v///z/EAAACv+6vP/+u6z/IAAAAATP//1H3//7IAAAAAAAABAAAAEAAAAAAAAABJkwAAAAAAAAAAAAr///+gAAAAEQAAAB783dvP0QAADNAAAA37/93/n8AAC79QAAT5/c/9358wBt/vAADu/v+8/+79Afz79QAPn7+//Pv58Pv975AD+f7/zP3fjw+vv+wAf7789T+/6vTs+/vgCf3fvyP8/789z7+/AG+++/SP7Pvw+fr74AL5/e+837+/X3+v3AAPv7+//d3d797/35AA3+7/vMzMzK75+/MAA/r97//////r/fwAAAz5/7uqqqqt/d8gAAAe/N//////6v9gAAAACv/bqqqr3/4gAAAAAAOM/////aUAAAAAAAAAAAAAAAAAAAAAAAAAAQEQABARAAAAAAAABvvuoF+u6wAAAAAAAG++6gX67rAAAAAAAAb77qBfrusAAAAAAABvvuoF+u6wAAAAAAAE16pwPXunAAAAAAAAAAAAAAAAAAAA==");
var scale = 1; // size multiplier for this font

File diff suppressed because one or more lines are too long

View File

@ -5,22 +5,6 @@ const DIM_27x22 = [27,22];
class DigitNumeralFont extends NumeralFont{
constructor(){
super();
// dimension map provides the dimesions of the character for
// each number for plotting and collision detection
/*this.dimension_map = {
1 : [14,22],
2 : [14,22],
3 : [14,22],
4 : [14,22],
5 : [14,22],
6 : [14,22],
7 : [14,22],
8 : [14,22],
9 : [14,22],
10: [27,22],
11: [27,22],
12: [27,22]
};*/
}
getDimensions(hour){
if (hour < 10){

View File

@ -6,8 +6,6 @@ const DIM_54x44 = [54,44];
class DigitNumeralFont extends NumeralFont{
constructor(){
super();
// dimension map provides the dimesions of the character for
// each number for plotting and collision detection
}
getDimensions(hour){
if (hour < 10){
@ -39,4 +37,56 @@ class DigitNumeralFont extends NumeralFont{
getName(){return "Digit";}
}
module.exports = [DigitNumeralFont];
const DIM_50x40 = [50,40];
const DIM_70x40 = [70,40];
class RomanNumeralFont extends NumeralFont{
constructor(){
super();
}
getText(hour){
switch (hour){
case 1 : return 'I';
case 2 : return 'II';
case 3 : return 'III';
case 4 : return 'IV';
case 5 : return 'V';
case 6 : return 'VI';
case 7 : return 'VII';
case 8 : return 'VIII';
case 9 : return 'IX';
case 10: return 'X';
case 11: return 'XI';
case 12: return 'XII';
default: return '';
}
}
getDimensions(hour){
switch (hour){
case 3:
case 6:
case 9:
return DIM_50x40;
case 12:
return DIM_70x40;
default:
return DIM_70x40;
}
}
hour_txt(hour){ return this.getText(hour); }
draw(hour_txt,x,y){
/*var dim = DIM_70x40;
g.setColor(0.5,0,0);
g.fillPoly([x,y,
x+dim[0],y,
x+dim[0],y+dim[1],
x,y+dim[1]
]);*/
g.setColor(1.0,1.0,1.0);
g.setFontAlign(-1,-1,0);
g.setFont("Vector",50);
g.drawString(hour_txt,x,y);
}
getName(){return "Roman";}
}
module.exports = [DigitNumeralFont,RomanNumeralFont];

View File

@ -28,23 +28,26 @@ var color_schemes = [
var fonts = DEFAULT_NUMERALS;
var numerals = DEFAULT_NUMERALS;
var radius = DEFAULT_RADIUS;
try{
var fonts_info = require("Storage").readJSON(FONTS_FILE);
if(fonts_info != null){
console.log("loaded font:" + JSON.stringify(fonts_info));
fonts = fonts_info.fonts;
numerals = fonts_info.numerals;
radius = fonts_info.radius;
color_schemes = fonts_info.color_schemes;
} else {
fonts = DEFAULT_FONTS;
numerals = DEFAULT_NUMERALS;
radius = DEFAULT_RADIUS;
console.log("no fonts loaded defaulting to:" + fonts);
}
var fonts_info = null;
try {
fonts_info = require("Storage").readJSON(FONTS_FILE);
} catch(e){
console.log("failed to load fonts:" + e);
console.log("failed to load fonts file:" + FONTS_FILE + e);
}
if(fonts_info != null){
console.log("loaded font:" + JSON.stringify(fonts_info));
fonts = fonts_info.fonts;
numerals = fonts_info.numerals;
radius = fonts_info.radius;
color_schemes = fonts_info.color_schemes;
} else {
fonts = DEFAULT_FONTS;
numerals = DEFAULT_NUMERALS;
radius = DEFAULT_RADIUS;
console.log("no fonts loaded defaulting to:" + fonts);
}
if(fonts == null || fonts.length == 0){
fonts = DEFAULT_FONTS;
console.log("defaulting fonts to locale:" + fonts);