static/js/drawer.js
// mode 0 is per stroke eval, 1 is assess, 2 is convolution, 3 is pooling
mode 0 is per stroke eval, 1 is assess, 2 is convolution, 3 is pooling
mode 0 is per stroke eval 1 is assess 2 is convolution 3 is pooling
function cropAndEval(canvas,mode){
    if (drawingCoords.length >= 2){
        xCoords = drawingCoords.map(coord=>coord.x);
        yCoords = drawingCoords.map(coord=>coord.y);
        drawingCorners={min:[Math.min(...xCoords),Math.min(...yCoords)],max:[Math.max(...xCoords),Math.max(...yCoords)]};
        var pRatio = window.devicePixelRatio;
        var pixels = canvas.getContext('2D').getImageData(Math.floor(drawingCorners.min[0] * pRatio), Math.floor(drawingCorners.min[1] * pRatio),
            Math.ceil((drawingCorners.max[0] - Math.floor(drawingCorners.min[0])) * pRatio)+2, Math.ceil((drawingCorners.max[1] - Math.floor(drawingCorners.min[1]))  * pRatio)+2);
        evalImg(pixels,canvas,mode);
    }else{
        alert('No drawing');
    }
}
function cropAndEval ( canvas , mode ) { if ( drawingCoords . length >= 2 ) { xCoords = drawingCoords . map ( coord => coord . x ) ; yCoords = drawingCoords . map ( coord => coord . y ) ; drawingCorners = { min : [ Math . min ( ... xCoords ) , Math . min ( ... yCoords ) ] , max : [ Math . max ( ... xCoords ) , Math . max ( ... yCoords ) ] } ; var pRatio = window . devicePixelRatio ; var pixels = canvas . getContext ( '2D' ) . getImageData ( Math . floor ( drawingCorners . min [ 0 ] * pRatio ) , Math . floor ( drawingCorners . min [ 1 ] * pRatio ) , Math . ceil ( ( drawingCorners . max [ 0 ] - Math . floor ( drawingCorners . min [ 0 ] ) ) * pRatio ) + 2 , Math . ceil ( ( drawingCorners . max [ 1 ] - Math . floor ( drawingCorners . min [ 1 ] ) ) * pRatio ) + 2 ) ; evalImg ( pixels , canvas , mode ) ; } else { alert ( 'No drawing' ) ; } }
mode 0 is per stroke eval, 1 is assess, 2 is convolution, 3 is pooling
mode 0 is per stroke eval 1 is assess 2 is convolution 3 is pooling
// process image // grab corner coordinates // Use the corners to grab pixel data array of the drawing // evaluate drawing