implement rudimetary canvas reading
This commit is contained in:
parent
98215a557a
commit
1f48f97af4
1 changed files with 11 additions and 1 deletions
12
index.php
12
index.php
|
@ -135,7 +135,17 @@
|
|||
document.onmouseup = function() {
|
||||
drawing = false;
|
||||
// write image-bits for posting
|
||||
bits.value = "101";
|
||||
let canvasData = canvas.getImageData(0, 0, 128, 64);
|
||||
bits.value = "";
|
||||
|
||||
// not best method, ideally want to create an array and then merge
|
||||
for (let i = 0; i < canvasData.data.length; i += 4) {
|
||||
if (canvasData.data[i] == 0) {
|
||||
bits.value += "1";
|
||||
} else {
|
||||
bits.value += "0";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
canvas.onmousemove = function() {
|
||||
|
|
Reference in a new issue