sketch
var dx1;
var dy1;
var dx2;
var dy2;
var numLines = 50;
function setup() {
createCanvas(400, 400);
background(220);
}
function draw() {
background(200);
//line(mouseX, mouseX, 150-mouseY, 300+mouseY);
//line(mouseX, mouseX, 350-mouseY, 100+mouseY);
var x1 = mouseX;
var y1 = mouseX;
var x2 = mouseX;
var y2 = mouseX;
dx1 = (mouseX-mouseY)/numLines;
dy1 = (mouseX-mouseY)/numLines;
dx2 = (150-mouseY-350-mouseY)/numLines;
dy2 = (300+mouseY-100+mouseY)/numLines;
for (var i = 0; i <= numLines; i += 1) {
stroke(0);
line(x1, y1, x2, y2);
x1 += dx1;
y1 += dy1;
x2 += dx2;
y2 += dy2;
}
var r = 20;
fill(255,140,140);
noStroke();
circle(mouseY, mouseX, 2*r);
fill(140,140,255);
circle(width-mouseY, height-mouseX, 40);
var xc1 = mouseY;
var yc1 = mouseX+r;
var xc2 = width-mouseY;
var yc2 = height-mouseX-r;
for (var i = 0; i <= 2*PI; i += PI/4) {
stroke(0);
line(xc1, yc1, xc2, yc2);
if (i <= PI/2) {
xc1 += r*Math.sin(i);
yc1 -= r-r*Math.cos(i);
xc2 -= r*Math.sin(i);
yc2 += r-r*Math.cos(i);
} else if (i > PI/2 & i <= PI) {
xc1 -= r*Math.sin(i);
yc1 -= r-r*Math.cos(i);
xc2 += r*Math.sin(i);
yc2 += r-r*Math.cos(i);
} else if (i > PI & i <= 3*PI/2) {
xc1 -= r*Math.sin(i);
yc1 += r-r*Math.cos(i);
xc2 += r*Math.sin(i);
yc2 -= r-r*Math.cos(i);
} else if (i > 3*PI/2 & i <= 2*PI) {
xc1 += r*Math.sin(i);
yc1 += r-r*Math.cos(i);
xc2 -= r*Math.sin(i);
yc2 -= r-r*Math.cos(i);
}
}
}