81 lines
2.9 KiB
JavaScript
81 lines
2.9 KiB
JavaScript
const { Color, Naplps, Point } = require("telidon");
|
|
const Menu = require("../helpers/menu.js");
|
|
|
|
module.exports = class Horloge extends Menu {
|
|
bgColor = new Color(0.125,0.5,0.5);
|
|
fgColor = new Color(1,1,1);
|
|
menu = {
|
|
"": "./views/mainmenu.js"
|
|
};
|
|
constructor(/** @type Naplps */naplps) {
|
|
super(naplps);
|
|
naplps.nsr();
|
|
naplps.pdiMode();
|
|
naplps.options.pelSize = new Point(0.01,0.01);
|
|
naplps.setDomain();
|
|
naplps.setColor(new Color(0.125,0.5,0.5));
|
|
naplps.setRectFilled([
|
|
new Point(0,0),
|
|
new Point(1,0.75),
|
|
]);
|
|
|
|
naplps.setColor(new Color(1,1,1));
|
|
naplps.setArcFilled([
|
|
new Point(0.5,0.2),
|
|
new Point(0,0.5),
|
|
]);
|
|
naplps.setColor(new Color(0,0,0));
|
|
naplps.setArcOutlined([
|
|
new Point(0.5,0.2),
|
|
new Point(0,0.5),
|
|
]);
|
|
|
|
var date = new Date();
|
|
|
|
this.interval = setInterval(()=>{
|
|
naplps.pdiMode();
|
|
naplps.doubleHeightText();
|
|
naplps.setColor(new Color(0.125,0.5,0.5));
|
|
naplps.pointSetAbs(new Point(0.4,0.1));
|
|
naplps.text(date.toLocaleTimeString());
|
|
naplps.setColor(new Color(1,1,1));
|
|
naplps.pointSetAbs(new Point(0.5,0.45));
|
|
var t = Math.floor((date.getTime()-date.getTimezoneOffset()*60000)/1000);
|
|
var h = t%43200/21600*Math.PI;
|
|
var m = t%3600/1800*Math.PI;
|
|
var s = t%60/30*Math.PI;
|
|
naplps.lineRel([
|
|
new Point(Math.sin(h)*0.12,Math.cos(h)*0.12),
|
|
new Point(-Math.sin(h)*0.12,-Math.cos(h)*0.12),
|
|
new Point(Math.sin(m)*0.16,Math.cos(m)*0.16),
|
|
new Point(-Math.sin(m)*0.16,-Math.cos(m)*0.16),
|
|
new Point(Math.sin(s)*0.2,Math.cos(s)*0.2),
|
|
]);
|
|
date = new Date();
|
|
naplps.setColor(new Color(1,1,1));
|
|
naplps.pointSetAbs(new Point(0.4,0.1));
|
|
naplps.text(date.toLocaleTimeString());
|
|
naplps.normalText();
|
|
naplps.setColor(new Color(0,0,0));
|
|
naplps.pointSetAbs(new Point(0.5,0.45));
|
|
var t = Math.floor((date.getTime()-date.getTimezoneOffset()*60000)/1000);
|
|
var h = t%43200/21600*Math.PI;
|
|
var m = t%3600/1800*Math.PI;
|
|
var s = t%60/30*Math.PI;
|
|
naplps.lineRel([
|
|
new Point(Math.sin(h)*0.12,Math.cos(h)*0.12),
|
|
new Point(-Math.sin(h)*0.12,-Math.cos(h)*0.12),
|
|
new Point(Math.sin(m)*0.16,Math.cos(m)*0.16),
|
|
new Point(-Math.sin(m)*0.16,-Math.cos(m)*0.16),
|
|
new Point(Math.sin(s)*0.2,Math.cos(s)*0.2),
|
|
]);
|
|
}, 1000);
|
|
this.start();
|
|
}
|
|
|
|
leave() {
|
|
clearInterval(this.interval);
|
|
this.naplps.options.pelSize = new Point(0,0);
|
|
this.naplps.setDomain();
|
|
}
|
|
} |