xxxxxxxxxx
56
let step = 3
let bound = 100
let sides = 500
let radius = 60
let noiseV = 2
let zOff = 0
// let seed = 696969
let waist = 3
let yOff, img, initX, endX
function setup() {
createCanvas(windowWidth,windowHeight);
background(0);
noFill()
strokeWeight(3)
initX = (-height / 2) + bound
endX = (height / 2) - bound
yOff = initX
// noiseSeed(seed);
}
function draw() {
// scale(0.3)
translate(width / 2, height / 2)
stroke(255, map(yOff, initX, endX, 150, 0)) // Opacity
new Polygon(yOff, radius, sides)
zOff += 0.001 // Center Jitter/3rd Noise Dimension
yOff += step
if (yOff > endX) noLoop()
}
class Polygon {
constructor(y0, r, npoints) {
let mulRad = map(y0, initX, endX, 1, 1.3) // Radius Multiplier
let mulFreq = map(y0, initX, endX, 120, 180) // Cosine Frequency
let modRad = cos(100 - y0 / mulFreq) * (r / waist) // Cosine Wave
let folds = Logistic(700, 4, 0.0075, y0) // Folds
let angle = TWO_PI / npoints;
beginShape();
for (let a = 0; a < TWO_PI; a += angle) {
let xf = map(cos(a), -1, 1, 0, noiseV + folds)
let yf = map(sin(a), -1, 1, 0, noiseV + folds)
let sr = map(noise(xf, yf, zOff), 0, 1, 0, (r + modRad) * mulRad)
let sx = 4 * cos(a) * sr;
let sy = y0 + 1 * sin(a) * sr;
vertex(sx, sy);
}
endShape(CLOSE);
}
}
// Logistic Function
function Logistic(midP,limitC, steepK, inputX) {
return limitC / (1 + exp(-steepK * (inputX-midP)))
}