My memory of math may be a bit fuzzy, but I can't seem to recall how to solve this particular issue. In jQuery, I have been adding randomized clipping paths to my images using the following code:
var max=100;
var spread=5;
jQuery.each( $("img"), function( i, val ) {
$(val).clipPath(
[
[Math.floor(Math.random()*spread*10)/10, Math.floor(Math.random()*spread*10)/10],
[max-Math.floor(Math.random()*spread*10)/10, Math.floor(Math.random()*spread*10)/10],
[max-Math.floor(Math.random()*spread*10)/10, max-Math.floor(Math.random()*spread*10)/10],
[Math.floor(Math.random()*spread*10)/10, max-Math.floor(Math.random()*spread*10)/10]
],
{isPercentage:true}
);
})
The code works perfectly fine; however, because the values are in percentages, they can sometimes result in extreme changes with the image size increasing significantly. How can I adjust the "spread" variable to account for increasing height/width values? Would using Math.log be helpful in this situation?
Thank you.