xxxxxxxxxx
function setup() {
createCanvas(1112, 834);
colorMode(HSB, 255);
time = 0.01
}
function draw() {
translate(width/2, height/2)
scale(1, -1)
blendMode(BLEND)
background(255)
stroke(0)
strokeWeight(2)
noStroke()
blendMode(DIFFERENCE)
n = 200
l = 200
k = 10
h = 10
a = 100
point(-a, 0)
point(a, 0)
for(j = 0; j < k; j++){
fill(j*23, 255, 255)
step = fract((j+time)/k)*k-k/2
beginShape()
for(i = -l; i <= l; i++){
sigma = i/l*PI
tau = step
x = a * sinh(tau)/(cosh(tau)-cos(sigma))
y = a * sin(sigma)/(cosh(tau)-cos(sigma))
vertex(x, y)
}
endShape(CLOSE)
}
for(j=0; j<h; j++){
fill(j*23, 255, 255)
step = fract((j+time)/h)*PI-PI/2
beginShape()
for(i = -n; i <= n; i++){
sigma = PI/2+step
tau = -i/n*3
x = a * sinh(tau)/(cosh(tau)-cos(sigma))
y = a * sin(sigma)/(cosh(tau)-cos(sigma))
vertex(x, y)
}
for(i = -n; i <= n; i++){
sigma = -PI/2+step
tau = i/n*3
x = a * sinh(tau)/(cosh(tau)-cos(sigma))
y = a * sin(sigma)/(cosh(tau)-cos(sigma))
vertex(x, y)
}
endShape(CLOSE)
}
time += 0.02
}
function sinh(x){
return((exp(x)-exp(-x))/2)
}
function cosh(x){
return((exp(x)+exp(-x))/2)
}
//save JPG
let lapse = 0; // mouse timer
function mousePressed(){
// prevents mouse press from registering twice
if (millis() - lapse > 400){
save("img_" + month() + '-' + day() + '_' + hour() + '-' + minute() + '-' + second() + ".jpg");
lapse = millis();
}
}