xxxxxxxxxx
44
// Using a randomseed to generate psuedorandom values
// and create repeating values in randomness
// This sketch demonstrates the workings of:
// Gen.fill(), Gen.spread(), Rand.seed(), Rand.randomFloat()
// require libraries from TotalSerialism
const Gen = TotalSerialism.Generative;
const Mod = TotalSerialism.Transform;
const Rand = TotalSerialism.Stochastic;
var col = 8;
var row = 8;
var amt = 64;
var speed = 5;
var reset = 15 * speed; //the reset speed for pattern length
var seed = 95843; //the seed will change the psuedorandomness
var vals = Gen.fill(0, amt) //empty array with 0's
function setup() {
createCanvas(windowWidth, windowHeight);
}
function draw() {
background(0);
translate(width/2, height/2);
var posX = Gen.spread(amt, -width/2, width/2);
if (frameCount % reset === 0 || frameCount === 1){
Rand.seed(5839);
}
if (frameCount % speed === 0 || frameCount === 1){
vals = Mod.rotate(vals, -1);
vals[vals.length-1] = Rand.randomFloat(1, -1, 1)[0];
}
for (let i in vals){
stroke(255);
strokeWeight(2);
line(posX[i], 0, posX[i], vals[i]*height/2);
}
}