xxxxxxxxxx
29
//this is a lil sketch of a transactional library, where you receive one book (a word) for every book you return to the library (buffer). Feel free to edit/take/break/ignore.
let buffer = ["sometimes","love","is","a","photograph","of","a","photograph"];
let mybooks = ["click","to","return","books"];
function setup() {
createCanvas(windowWidth, windowHeight);
noStroke();
textAlign(CENTER);
background(0);
}
function draw() {
background(0);
let c = color(255,255,255);
fill(c);
textSize(32);
for (let i = 0; i < mybooks.length; i++) {
text(mybooks[i], width/2, height*(i+1)/(mybooks.length+1));
}
}
function mousePressed(){
let swapcount = floor(map(mouseY,0,height,0,mybooks.length));
let randn = int(random(buffer.length));
let swapword = mybooks[swapcount];
mybooks[swapcount] = buffer[randn];
buffer[randn] = swapword;
}