BangleApps/apps/Uke/app.js

260 lines
3.4 KiB
JavaScript
Raw Normal View History

2023-05-25 02:38:48 +00:00
const stringInterval = 30;
const stringLength = 131;
const fretHeight = 35;
const fingerOffset = 17;
const x = 44;
const y = 32;
//chords
const cc = [
"C",
"x",
"x",
"x",
"33"
];
const dd = [
"D",
"22",
2023-06-04 21:26:35 +00:00
"23",
2023-05-25 02:38:48 +00:00
"24",
"x"
];
2023-06-04 21:26:35 +00:00
var ee = [
"E",
"33",
"32",
"34",
"11"
];
const ff = [
"F",
"22",
"x",
"11",
"x"
];
2023-05-25 02:38:48 +00:00
const gg = [
"G",
"x",
"21",
"33",
"22",
];
2023-06-04 21:26:35 +00:00
const aa = [
"A",
2023-05-25 02:38:48 +00:00
"22",
2023-06-04 21:26:35 +00:00
"11",
2023-05-25 02:38:48 +00:00
"x",
"x"
];
2023-06-04 21:26:35 +00:00
const bb = [
"B",
"42",
"43",
"44",
"21"
];
const cm = [
"Cm",
"11",
"x",
"12",
"34"
];
const dm = [
"Dm",
"x",
"22",
"33",
"11"
];
2023-05-25 02:38:48 +00:00
const em = [
"Em",
"x",
"43",
"32",
"21"
];
2023-06-04 21:26:35 +00:00
const fm = [
"Fm",
"33",
"11",
"11",
"11"
];
const gm = [
"Gm",
"x",
2023-05-25 02:38:48 +00:00
"22",
2023-06-04 21:26:35 +00:00
"33",
"11"
];
const am = [
"Am",
"22",
"23",
2023-05-25 02:38:48 +00:00
"11",
2023-06-04 21:26:35 +00:00
"x"
];
const bm = [
"Bm",
2023-05-25 02:38:48 +00:00
"x",
2023-06-04 21:26:35 +00:00
"43",
"32",
"21"
];
const c7 = [
"C7",
"22",
"33",
"11",
2023-05-25 02:38:48 +00:00
"x"
];
2023-06-04 21:26:35 +00:00
const d7 = [
"D7",
"x",
2023-05-25 02:38:48 +00:00
"22",
2023-06-04 21:26:35 +00:00
"11",
"23"
];
const e7 = [
"E7",
2023-05-25 02:38:48 +00:00
"x",
"11",
2023-06-04 21:26:35 +00:00
"x",
2023-05-25 02:38:48 +00:00
"x"
];
2023-06-04 21:26:35 +00:00
const f7 = [
"F7",
"11",
"22",
"11",
"11"
];
const g7 = [
"G7",
"x",
"x",
"x",
2023-05-25 02:38:48 +00:00
"11"
];
2023-06-04 21:26:35 +00:00
const a7 = [
"A7",
"21",
"21",
"21",
"32"
];
const b7 = [
"B7",
"11",
"22",
"x",
"23"
];
var menu = {
2023-06-04 21:26:35 +00:00
"" : { "title" : "Uke Chords" },
"C" : function() { draw(cc); },
"D" : function() { draw(dd); },
"E" : function() { draw(ee); },
"F" : function() { draw(ff); },
"G" : function() { draw(gg); },
"A" : function() { draw(aa); },
"B" : function() { draw(bb); },
"C7" : function() { draw(c7); },
"D7" : function() { draw(d7); },
"E7" : function() { draw(e7); },
"F7" : function() { draw(f7); },
"G7" : function() { draw(g7); },
"A7" : function() { draw(a7); },
"B7" : function() { draw(b7); },
"Cm" : function() { draw(cm); },
"Dm" : function() { draw(dm); },
"Em" : function() { draw(em); },
"Fm" : function() { draw(fm); },
"Gm" : function() { draw(gm); },
"Am" : function() { draw(am); },
"Bm" : function() { draw(bm); },
"About" : function() {
E.showMessage(
"Created By:\nNovaDawn999", {
title:"About"
}
);
}
};
2023-05-25 02:38:48 +00:00
function drawBase() {
for (let i = 0; i < 4; i++) {
g.drawLine(x + i * stringInterval, y, x + i * stringInterval, y + stringLength);
g.fillRect(x- 1, y + i * fretHeight - 1, x + stringInterval * 3 + 1, y + i * fretHeight + 1);
}
}
function drawChord(chord) {
2023-06-04 21:45:23 +00:00
g.drawString(chord[0], g.getWidth() * 0.5 - (chord[0].length * 5), 16);
2023-05-25 02:38:48 +00:00
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 - 5, y + fretHeight * chord[i][0] + 2, true);
g.drawCircle(x + (i - 1) * stringInterval -1, y + fretHeight * chord[i][0], 10);
2023-05-25 02:38:48 +00:00
}
else {
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);
2023-05-25 02:38:48 +00:00
}
}
}
function buttonPress() {
setWatch(() => {
buttonPress();
}, BTN);
E.showMenu(menu);
2023-05-25 02:38:48 +00:00
}
function draw(chord) {
2023-05-25 02:38:48 +00:00
g.clear();
drawBase();
drawChord(chord);
2023-05-25 02:38:48 +00:00
}
function main() {
E.showMenu(menu);
2023-05-25 02:38:48 +00:00
setWatch(() => {
buttonPress();
}, BTN);
}
main();