xxxxxxxxxx
37
// 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 = 100;
function setup() {
createCanvas(windowWidth, windowHeight);
// generate colors
hues = ts.mirror(ts.spread(num/2, 220, 300));
// generate the pisano periods for the sizes
// of the spheres and reverse
fib = ts.reverse(ts.pisano(num));
}
function draw() {
background(0);
stroke(255);
strokeWeight(2);
colorMode(HSB);
// generate posX and posY values based on phase offset in sinewave
posX = ts.sineFloat(fib.length, 9.03, width/6, width*5/6, frameCount/431);
posY = ts.sineFloat(fib.length, 7.1, width/6, width*5/6, frameCount/512);
for (let f of fib){
fill(hues[f], 50, 100);
circle(posX[f], posY[f], fib[f]);
}
}