wip picture to board
This commit is contained in:
@ -28,11 +28,10 @@ export function picToBlackAndWhite(pixels, width, height) {
|
||||
// convert an ImageData into a 2D array of boolean (0, 1) values
|
||||
export function picToBoard(pixels, width, height) {
|
||||
const flat = pixels.reduce((acc, pixel, index) => {
|
||||
if (index % 4 == 0) {
|
||||
const count = pixels[index] + pixels[index + 1] + pixels[index + 2];
|
||||
const value = count >= 255 ? 1 : 0;
|
||||
acc[index] = value;
|
||||
}
|
||||
const i = index * 4;
|
||||
const count = pixels[i] + pixels[i + 1] + pixels[i + 2];
|
||||
const value = count >= 255 ? 1 : 0;
|
||||
acc[index] = value;
|
||||
return acc;
|
||||
}, []);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user