function draw(matrix, imageData) {
    let width = imageData.width;
    let height = imageData.height;
    let data = imageData.data;

    for (let x = 0; x < width; x++) {
        for (let y = 0; y < height; y++) {
            // Canvas' y direction is reversed
            let yCanvas = (height - 1) - y;
            let index = (yCanvas * width + x) * BYTES_PER_PIXEL;

            let color = matrix[x][y] * 255;
            data[index] = color;
            data[index + 1] = color;
            data[index + 2] = color;
            data[index + 3] = 255;
        }
    }

    return imageData;
}
/**
 * Draws the matrix into a canvas' pixel data.
 * Assumes that the matrix is normalized.
 */
Draws the matrix into a canvas' pixel data.
Assumes that the matrix is normalized.
Draws the matrix into a canvas ' pixel data . Assumes that the matrix is normalized .
function draw(matrix, imageData) {
    let width = imageData.width;
    let height = imageData.height;
    let data = imageData.data;
    for (let x = 0; x < width; x++) {
        for (let y = 0; y < height; y++) {
            let yCanvas = (height - 1) - y;
            let index = (yCanvas * width + x) * BYTES_PER_PIXEL;
            let color = matrix[x][y] * 255;
            data[index] = color;
            data[index + 1] = color;
            data[index + 2] = color;
            data[index + 3] = 255;
        }
    }
    return imageData;
}
function draw ( matrix , imageData ) { let width = imageData . width ; let height = imageData . height ; let data = imageData . data ; for ( let x = 0 ; x < width ; x ++ ) { for ( let y = 0 ; y < height ; y ++ ) { let yCanvas = ( height - 1 ) - y ; let index = ( yCanvas * width + x ) * BYTES_PER_PIXEL ; let color = matrix [ x ] [ y ] * 255 ; data [ index ] = color ; data [ index + 1 ] = color ; data [ index + 2 ] = color ; data [ index + 3 ] = 255 ; } } return imageData ; }
Draws the matrix into a canvas' pixel data.
Draws the matrix into a canvas ' pixel data .
// Canvas' y direction is reversed