xxxxxxxxxx
var thesize = 1; // GLOBAL VARIABLE
function setup() {
createCanvas(windowWidth, windowHeight);
background(255);
}
function draw() {
var speed = dist(mouseX, mouseY, pmouseX, pmouseY); // hypotenuse
var angle = atan2((pmouseY-mouseY),(pmouseX-mouseX));
// console.log(speed);
// pmouseX and pmouseY are the previous mouseX and mouseY
colorMode(RGB);
strokeWeight(speed);
noFill();
stroke(speed, 0, 255-speed, 20);
line(pmouseX, pmouseY, mouseX, mouseY);
colorMode(HSB);
var h = map(angle, -PI, PI, 0, 360); // map(input, minin, maxin, minout, maxout)
var s = 100;
var b = 100;
fill(h, s, b, 0.3); // HSB is 0-360 for the H, 0-100 for the S & B, 0-1 for the alpha
noStroke();
if(mouseIsPressed) ellipse(mouseX, mouseY, speed, speed);
}
function keyTyped() {
if(key=='c') {
background(255);
thesize = 1;
}
}