xxxxxxxxxx
38
function setup() {
createCanvas(400, 400);
noLoop()
}
function draw() {
background(220);
let x1 = random(width)
let y1 = random(width)
let x2 = random(width)
let y2 = random(width)
let r = dist(x1, y1, x2, y2) / 2
let theta = atan2(y2 - y1, x2 - x1)
fill(0)
ellipse(x1, y1, 4, 4)
let angle = theta + random([-1, 1]) * random(radians(10))
let c1x = x1 + r * cos(angle)
let c1y = y1 + r * sin(angle)
ellipse(x2, y2, 4, 4)
ellipse(c1x, c1y, 4, 4)
noFill();
beginShape()
vertex(x1, y1)
bezierVertex(c1x, c1y, x2, y2, x2, y2)
endShape()
}
function mousePressed() {
redraw()
}