xxxxxxxxxx
var thesize = 1; // GLOBAL VARIABLE
function setup() {
createCanvas(windowWidth, windowHeight);
background(255);
}
function draw() {
fill(0);
// var thesize = 1; // I REDECLARED THE VARIABLE AS A LOCAL VARIABLE AAAAAAAAAAAAGDGDHDHGADJGKL
ellipse(mouseX, mouseY, thesize, thesize);
// pmouseX and pmouseY are the previous mouseX and mouseY
//var speed = abs(pmouseX-mouseX) + abs(pmouseY-mouseY);
// hypotenuse:
// var speed = sqrt((pmouseX-mouseX)*(pmouseX-mouseX) + (pmouseY-mouseY)*(pmouseY-mouseY));
var speed = dist(mouseX, mouseY, pmouseX, pmouseY); // hypotenuse
thesize = speed; // make the size based on the speed of the mouse
// binary operators : ==, !=, >, <, >=, <= (return a true or false)
// if(thesize>100) thesize = 1;
}
function keyTyped() {
if(key=='c') {
background(100);
thesize = 1;
}
}