Created
November 17, 2015 18:30
-
-
Save bmoren/60722881b05622b69a53 to your computer and use it in GitHub Desktop.
idle state for mouse movement in p5.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//if the mouse is not moving for x time then do something. | |
mouseIsMoving = false; | |
function setup(){ | |
createCanvas(windowWidth,windowHeight); | |
} | |
function draw() { | |
if(mouseIsMoving == true){ | |
fill(100); | |
}else{ | |
fill(0); | |
} | |
ellipse(100,100,100,100); | |
} | |
function mouseMoved() { | |
mouseIsMoving = true; | |
setTimeout(function(){ // this is to delay the execution of the code within, this is pure javaScript | |
mouseIsMoving = false; | |
},3000) //it takes a time in MS | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment