0๐
1/ to change real value to integer, you can use :
var intvalue = Math.floor( floatvalue );
var intvalue = Math.ceil( floatvalue );
var intvalue = Math.round( floatvalue );
2/ for deformed image:
try Math.abs(val);
Source:stackexchange.com