xxxxxxxxxx
38
// include the package as ts.
const ts = TotalSerialism;
// assign sub-libraries to the ts namespace
// using globalThis as namespace can result in name clashes
Object.assign(ts, ts.Generative, ts.Algorithmic, ts.Utility, ts.Transform);
let hues, posX, fib;
let num = 20;
function setup() {
createCanvas(windowWidth, windowHeight);
frameRate(120);
// generate colors
hues = ts.spread(num, 100, 460);
// generate the fibonacci sequence for the size
// of the spheres and reverse so largest sphere is drawn first
fib = ts.reverse(ts.fibonacci(num));
}
function draw() {
background(0);
stroke(255);
strokeWeight(4);
colorMode(HSB);
// generate posX and posY values based on phase offset in sinewave
posX = ts.sineFloat(num, 1, width/4, width/4*3, frameCount/231);
posY = ts.sineFloat(num, 1, width/4, width/4*3, frameCount/312);
for (let f in fib){
fill(hues[f], 50, 100);
circle(posX[f], posY[f], fib[f]);
}
}