function NewWidth() { w_r=im.width/(window.innerWidth*gap) h_r=im.height/(window.innerHeight*gap) if( w_r > h_r ) return window.innerWidth*gap else return im.width*gap / (im.height/window.innerHeight) } function NewHeight() { w_r=im.width/(window.innerWidth*gap) h_r=im.height/(window.innerHeight*gap) if( h_r > w_r ) return window.innerHeight*gap else return im.height*gap / (im.width/window.innerWidth) } // Define this once and before it will be called, hence at the top of this file function DrawImg() { // another call to this func will occur on load, so skip this one if( im.width == 0 ) return canvas.width=NewWidth(im) canvas.height=NewHeight(im) // actually draw the pixel images to the canvas at the right size if( grayscale ) context.filter='grayscale(1)' context.drawImage(im, 0, 0, canvas.width, canvas.height ) // -50 is a straight up hack, no idea why this works, but its good enough for me if( throbber ) $('#throbber').attr('style', 'display:show; position:absolute; left:'+canvas.width/2+'px; top:'+(canvas.height/2-50)+'px' ) else $('#throbber').hide(); // show (or not) the whole figcaption with fname in it - based on state of fname_toggle if( $('#fname_toggle').prop('checked' ) ) { $('.figcaption').attr('style', 'display:show' ) // reset fname for new image (if navigated left/right to get here) $('#fname').html(objs[current].name) } else $('.figcaption').attr('style', 'display:none' ) // if we have faces, the enable the toggles, otherwise disable them // and reset model select too if( objs[current].faces.length ) { $('#faces').attr('disabled', false) $('#distance').attr('disabled', false) $('#model').val( Number(objs[current].face_model) ) } else { $('#faces').attr('disabled', true) $('#distance').attr('disabled', true) // if no faces, then model is N/A (always 1st element - or 0 in select) $('#model').val(0) } // okay, we want faces drawn so lets do it if( $('#faces').prop('checked') ) { // draw rect on each face for( i=0; i