xxxxxxxxxx
65
let cent1, cent2
let theta, phi
let ls
let c1px, c2py
function setup() {
createCanvas(600, 600)
cent1 = createVector(200, 400, 100) // x, y, r
cent2 = createVector(450, 100, 70) // x, y, r
ls = createGraphics(600, 600)
theta = 0
phi = 0
stroke("#fff")
strokeWeight(3)
c1px = cent1.x + cent1.z * cos(theta)
c2py = cent2.y + cent2.z * sin(phi + PI / 3)
}
function draw() {
background("#000")
let c1x = cent1.x + cent1.z * cos(theta)
let c1y = cent1.y + cent1.z * sin(theta)
let c2x = cent2.x + cent2.z * cos(phi + PI / 3)
let c2y = cent2.y + cent2.z * sin(phi + PI / 3)
point(c1x, c1y)
point(c2x, c2y)
drawCircle(cent1.x, cent1.y, cent1.z)
drawCircle(cent2.x, cent2.y, cent2.z)
push()
stroke(255, 0, 0, 100)
line(c1x, c1y, c1x, c2y)
line(c2x, c2y, c1x, c2y)
point(c1x, c2y)
ls.stroke(255, 0, 0, 200)
ls.line(c1px, c2py, c1x, c2y)
pop()
image(ls, 0, 0)
theta += 0.02
phi += 0.01
c1px = c1x
c2py = c2y
if (theta >= TAU) theta -= TAU
if (phi >= TAU) theta -= TAU
}
function drawCircle(x, y, r) {
push()
noFill()
strokeWeight(1)
stroke(255, 200)
circle(x, y, 2 * r)
pop()
}