xxxxxxxxxx
28
function setup() {
createCanvas(400, 400);
}
function draw() {
background(220,200,204);
let mouse= createVector(mouseX,mouseY);
let V_center=createVector(width/2, height/2);
mouse.sub(V_center);
// mouse.mult(0.5);
// if(((position.x > width) || (position.x < 0)) )
//magnitude or distance function
// stroke(255, 105, 180);
// fill(255, 105, 180);
// let m = mouse.mag();
// rect(4,4,m,20);
// normalize function will normalized the magnitude to make it 1 but the direction will stay the same
mouse.normalize();
mouse.mult(150);
translate(width/2,height/2);
stroke(255, 105, 180);
line(0,0,mouse.x,mouse.y);
}