Allow variable width in font

This commit is contained in:
dylan
2023-05-08 21:39:08 -07:00
parent 107a5370b1
commit ad5acdeb12
6 changed files with 967 additions and 806 deletions

View File

@@ -52,7 +52,7 @@ const update = () => {
char = char.toUpperCase();
}
}
if (char in font) {
if (char in font.chars) {
currentLine = currentLine.slice(0, index)+char+currentLine.slice(index);
index += 1;
} else if (key === K.BACKSPACE) {
@@ -111,7 +111,7 @@ const update = () => {
const drawTextAbove = () => {
textLinesAbove.forEach((line, i) => {
fillRect(0, 1+i*lineHeight, 4*(line.length+1)+1, lineHeight+1, COLOR.BLACK);
drawText(-1, 1+i*lineHeight, line);
drawText(0, 1+i*lineHeight, line);
});
}
@@ -122,7 +122,7 @@ const draw = () => {
fillRect(0, 1+textLinesAbove.length*lineHeight, 4*(2+maxLineLen+1)+1, lineHeight+1, COLOR.BLACK);
fillRect((2+index)*4, textLinesAbove.length*lineHeight+1, 4, lineHeight-1, COLOR.RED);
drawText(-1, 1+textLinesAbove.length*lineHeight, "> "+currentLine);
drawText(0, 1+textLinesAbove.length*lineHeight, "> "+currentLine);
}
export const repl = {