Update app.js

- increased legibility
- reworked GUI
pull/2774/head
NovaDawn999 2023-05-25 05:53:01 -05:00 committed by GitHub
parent 855f196fd3
commit c5b21bf64d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 30 additions and 17 deletions

View File

@ -72,12 +72,28 @@ var ee = [
var index = 0;
var chords = [];
var menu = {
"" : {
"title" : "Uke Chords"
},
"C" : function() { draw(cc); },
"D" : function() { draw(dd); },
"E" : function() { draw(ee); },
"Em" : function() { draw(em); },
"A" : function() { draw(aa); },
"Am" : function() { draw(am); },
"F" : function() { draw(ff); },
"G" : function() { draw(gg); },
"About" : function() {
E.showMessage(
"Created By:\nNovaDawn999", {
title:"About"
}
);
}
};
function init() {
g.setFontAlign(0,0); // center font
g.setFont("6x8",2); // bitmap font, 8x magnified
chords.push(cc, dd, gg, am, em, aa, ff, ee);
}
function drawBase() {
for (let i = 0; i < 4; i++) {
@ -87,18 +103,18 @@ function drawBase() {
}
function drawChord(chord) {
g.drawString(chord[0], g.getWidth() * 0.5 + 2, 18);
g.drawString(chord[0], g.getWidth() * 0.5 - 3, 18);
for (let i = 0; i < chord.length; i++) {
if (i === 0 || chord[i][0] === "x") {
continue;
}
if (chord[i][0] === "0") {
g.drawString(chord[i][1], x + (i - 1) * stringInterval + 1, y + fretHeight * chord[i][0], true);
g.drawCircle(x + (i - 1) * stringInterval -1, y + fretHeight * chord[i][0], 8);
g.drawString(chord[i][1], x + (i - 1) * stringInterval - 5, y + fretHeight * chord[i][0] + 2, true);
g.drawCircle(x + (i - 1) * stringInterval -1, y + fretHeight * chord[i][0], 10);
}
else {
g.drawString(chord[i][1], x + (i - 1) * stringInterval + 1, y -fingerOffset + fretHeight * chord[i][0], true);
g.drawCircle(x + (i - 1) * stringInterval -1, y -fingerOffset + fretHeight * chord[i][0], 8);
g.drawString(chord[i][1], x + (i - 1) * stringInterval -5, y -fingerOffset + fretHeight * chord[i][0] + 2, true);
g.drawCircle(x + (i - 1) * stringInterval -1, y -fingerOffset + fretHeight * chord[i][0], 10);
}
}
}
@ -107,22 +123,19 @@ function buttonPress() {
setWatch(() => {
buttonPress();
}, BTN);
index++;
if (index >= chords.length) { index = 0; }
draw();
E.showMenu(menu);
}
function draw() {
function draw(chord) {
g.clear();
drawBase();
drawChord(chords[index]);
drawChord(chord);
}
function main() {
init();
draw();
E.showMenu(menu);
setWatch(() => {
buttonPress();
}, BTN);