User:Ember314/lerp.js

/*** this is a simple script that uses linear interpolation to make an object nicely follow your cursor * use as you like * see if I care ***/ var FOLLOW_AMNT = 0.15; //change this if you want $('body').prepend(' '); $('body').prepend(" "); $('body').prepend(' #funCanvas{ position: absolute; left: 0; right: 0;top: 0;bottom: 0;height: 200%;width: 100%; z-index: 1000000;pointer-events: none; overflow: auto;} '); var sketchHeight, sketchWidth, objX=0, objY=0; function setup { sketchWidth = document.getElementById("funCanvas").offsetWidth; sketchHeight = document.getElementById("funCanvas").offsetHeight; var canvas = createCanvas(sketchWidth, sketchHeight); canvas.parent('funCanvas'); }

function draw { clear /*optional*/ objX=lerp(objX,mouseX,FOLLOW_AMNT); objY=lerp(objY,mouseY,FOLLOW_AMNT); circle(objX,objY,50,50) }