-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from ClasspadDev/dev
Dev
- Loading branch information
Showing
71 changed files
with
10,866 additions
and
804 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,3 +24,7 @@ dist-ssr | |
*.njsproj | ||
*.sln | ||
*.sw? | ||
|
||
# Generated files | ||
.svelte-kit | ||
dist |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
font.ts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file was deleted.
Oops, something went wrong.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
const dlg_font_list = { | ||
"charmap": "!#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[]^_abcdefghijklmnopqrstuvwxyz{|}~0123456789_éàù€_↺_⚙️_", | ||
"charWidths": [ | ||
4, 9, 8, 11, 9, 4, 7, 7, 8, 8, 5, 8, 5, 7, | ||
// 0123456789 ... | ||
7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 4, 4, 9, 8, 9, 7, 12, | ||
// ABCDEF ... | ||
8, 8, 8, 8, 7, 7, 8, 8, 4, 7, 8, 7, 10, 8, 8, 8, 8, 8, 8, 8, 8, 8, 12, 9, 10, 7, 6, 6, 9, 8, | ||
// abcdef ... | ||
7, 7, 7, 7, 7, 6, 7, 7, 4, 5, 7, 4, 10, 7, 8, 7, 7, 6, 7, 6, 7, 7, 10, 7, 7, 6, 7, 4, 7, 11, | ||
// 0123456789' ' | ||
7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 4, 5, 7, 7, 7, 9, 8, 22, 8, 21, 8 | ||
|
||
|
||
] | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>Paste Image to Canvas</title> | ||
<style> | ||
#canvas { | ||
image-rendering: pixelated; /* Ensure pixelated rendering */ | ||
width: 1024px; /* Scaled width (x4) */ | ||
height: 18px; /* Scaled height (x4) */ | ||
border: 1px solid black; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<canvas id="canvas" width="1024" height="18"></canvas> <!-- 20x40 px canvas --> | ||
<script src="script.js"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
document.addEventListener('paste', (event) => { | ||
const clipboardItems = event.clipboardData.items; | ||
for (const item of clipboardItems) { | ||
if (item.type.startsWith('image/')) { | ||
const blob = item.getAsFile(); | ||
const reader = new FileReader(); | ||
reader.onload = (event) => { | ||
const img = new Image(); | ||
img.onload = () => { | ||
const canvas = document.getElementById('canvas'); | ||
const ctx = canvas.getContext('2d'); | ||
ctx.clearRect(0, 0, canvas.width, canvas.height); // Clear the canvas | ||
ctx.drawImage(img, 0, 0, img.width, img.height); | ||
|
||
const imageData = ctx.getImageData(0, 0, img.width, img.height); | ||
const data = imageData.data; | ||
let matrix = []; | ||
for (let y = 0; y < img.height; y++) { | ||
let row = []; | ||
for (let x = 0; x < img.width; x++) { | ||
const index = (y * img.width + x) * 4; | ||
const r = data[index]; // Red channel | ||
// Determine the value (0 for white, 1 for red) | ||
const value = r == 90 ? 1 : r == 231 ? 2 : 0; | ||
row.push(value); | ||
} | ||
matrix.push(row); | ||
} | ||
|
||
// Print the matrix in the desired format | ||
let matrixString = matrix.map(row => row.join(', ')).join(',\n'); | ||
console.log(matrixString); | ||
}; | ||
img.src = event.target.result; | ||
}; | ||
reader.readAsDataURL(blob); | ||
} | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
const dlg_font_list = { | ||
"charmap": "!#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[]^_abcdefghijklmnopqrstuvwxyz{|}~0123456789_éàù€_↺_⚙️_", | ||
"charWidths": [ | ||
4, 9, 8, 11, 9, 4, 7, 7, 8, 8, 5, 8, 5, 7, | ||
// 0123456789 ... | ||
7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 4, 4, 9, 8, 9, 7, 12, | ||
// ABCDEF ... | ||
8, 8, 8, 8, 7, 7, 8, 8, 4, 7, 8, 7, 10, 8, 8, 8, 8, 8, 8, 8, 8, 8, 12, 9, 10, 7, 6, 6, 9, 8, | ||
// abcdef ... | ||
7, 7, 7, 7, 7, 6, 7, 7, 4, 5, 7, 4, 10, 7, 8, 7, 7, 6, 7, 6, 7, 7, 10, 7, 7, 6, 7, 4, 7, 11, | ||
// 0123456789' ' | ||
7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 4, 5, 7, 7, 7, 9, 8, 22, 8, 21, 8 | ||
] | ||
} | ||
|
||
const charmap = dlg_font_list.charmap.split(""); | ||
const charWidths = dlg_font_list.charWidths; | ||
|
||
const canvas = document.getElementById('canvas'); | ||
const ctx = canvas.getContext('2d'); | ||
|
||
const img = new Image(); | ||
img.src = 'dialog_font_list.png'; // Ensure this path is correct | ||
|
||
img.onload = () => { | ||
ctx.drawImage(img, 0, 0); | ||
|
||
const ui_char_map = {}; | ||
let x = 0; | ||
for (let i = 0; i < charmap.length; i++) { | ||
const char = charmap[i]; | ||
const width = charWidths[i]; | ||
|
||
// Extract the character's pixel data | ||
const imageData = ctx.getImageData(x, 0, width, 18); | ||
const data = imageData.data; | ||
|
||
// Convert to 0 and 1 format based on the red channel | ||
let charData = []; | ||
for (let y = 0; y < 18; y++) { | ||
let row = []; | ||
for (let xx = 0; xx < width; xx++) { | ||
const index = (y * width + xx) * 4; | ||
const r = data[index]; | ||
|
||
const value = r == 90 ? 1 : r == 231 ? 2 : 0; | ||
|
||
row.push(value); | ||
} | ||
charData = charData.concat(row); | ||
} | ||
|
||
// Add the character data to the output object | ||
ui_char_map[char] = { | ||
size: [width, 18], | ||
data: charData | ||
}; | ||
|
||
// Move to the next character position, considering the 1px space | ||
x += width + 1; | ||
} | ||
|
||
// Print the resulting JSON object to the console | ||
console.log(JSON.stringify(ui_char_map, null, 2)); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -44,7 +44,6 @@ h1 { | |
#app { | ||
max-width: 1280px; | ||
margin: 0 auto; | ||
padding: 2rem; | ||
text-align: center; | ||
} | ||
|
||
|
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.