createCanvas(windowWidth, windowHeight);
colorMode(HSB, 360, 100, 100, 255);
_minWidth = min(width, height) * .6;
strokeWeight(_minWidth/20);
for (let i = 0; i < numLine; i++) {
for (let j = 0; j < numLine; j++) {
let step = _minWidth / numLine;
let x = -_minWidth / 2 + step / 2 + step * i;
let y = -_minWidth / 2 + step / 2 + step * j;
let centXy = createVector(x, y);
_aryLine[i + j * numLine] = new BendLine(centXy, r);
for (let i = 0; i < this.numPoints; i++) {
let ang = 2*PI / this.numPoints * i;
this.aryXy[i] = p5.Vector.add(this.centXy, createVector(this.r * cos(ang), this.r * sin(ang)));
for (let i = 0; i < this.numBend; i++) {
this.aryRParameter[i] = [this.r / 30 * 0.8**i, random(2*PI), 2*PI / random(100, 500)];
this.aryinitAngParameter = [];
for (let i = 0; i < this.numBend; i++) {
this.aryinitAngParameter[i] = [2*PI, random(2*PI), 2*PI / random(200, 1000)];
for (let i = 0; i < this.numBend; i++) {
this.aryAngStep[i] = 2*PI / this.numPoints * int(random(3, 8 + i));
[random(1000), random(1000), 1, 0.01],
[random(1000), random(1000), 1, 0.01]];
this.newAryXy = this.aryXy;
for (let i = 0; i < this.numBend; i++) {
this.newAryXy = bend(this.newAryXy, this.aryR[i], this.aryinitAng[i], this.aryAngStep[i], this.numCycle);
for (let i = 0; i < this.aryRParameter.length; i++) {
this.aryR[i] = this.aryRParameter[i][0] * (sin(this.aryRParameter[i][1] + this.aryRParameter[i][2] * frameCount));
for (let i = 0; i < this.aryinitAngParameter.length; i++) {
this.aryinitAng[i] = this.aryinitAngParameter[i][1] + this.aryinitAngParameter[i][0] * (sin(this.aryinitAngParameter[i][2] * frameCount));
for (let i = 0; i < this.newAryXy.length; i++) {
let noiseVal2 = sin(2*PI * 2 * noise(
this.aryColParameter[1][0] + this.aryColParameter[1][2] * cos(2*PI / this.newAryXy.length * i),
this.aryColParameter[1][1] + this.aryColParameter[1][2] * sin(2*PI / this.newAryXy.length * i),
this.aryColParameter[1][3] * frameCount)) * 0.5 + 0.5;
stroke(color(this.h, s, b, alp));
let midCentXy = p5.Vector.lerp(this.newAryXy[i], this.centXy, this.lineRatio);
line(this.newAryXy[i].x, this.newAryXy[i].y, midCentXy.x, midCentXy.y);
function bend(aryXy, r, initAng, angStep, numCycle) {
for (let j = 0; j < numCycle; j++) {
for (let i = 0; i < aryXy2.length; i++) {
let xy_1_2 = p5.Vector.sub(aryXy2[(i+1)%aryXy2.length], aryXy2[i]);
let ang = initAng + angStep * i;
xy_1_2.rotate(-PI/2).setMag(r * sin(ang));
let xy = p5.Vector.add(aryXy2[i], xy_1_2);
translate(width/2, height/2);
for (let i = 0; i < _aryLine.length; i++) {
function windowResized() {
resizeCanvas(windowWidth, windowHeight);