xxxxxxxxxx
let tixy = function(t, i, x, y) { return 0; }
let obj = {
"(t,i,x,y) =>": 'sin(t-sqrt((x-7.5)**2+(y-6)**2))'
}
function tryMakeTixy() {
let newTixy = eval('let it = function (t,i,x,y){ return '+obj['(t,i,x,y) =>']+'; }; it');
if (typeof(newTixy) === "function") {
tixy = newTixy;
startMillis = millis();
}
}
function preload() {
let gui = new dat.gui.GUI({width: 360});
//gui.remember(obj);
gui.add(obj, '(t,i,x,y) =>').onChange(tryMakeTixy);
}
let startMillis = 0;
function setup() {
createCanvas(windowWidth, windowHeight);
noStroke();
tryMakeTixy();
}
function draw() {
background(0);
let maxDim = min(windowWidth, windowHeight) / 2.0;
let windowCenterX = windowWidth / 2.0;
let windowCenterY = windowHeight / 2.0;
let t = (millis()-startMillis)/1000.0;
for (var i = 0; i < 256; i++) {
let x = int(i % 16);
let y = int(i / 16);
let value = tixy(t, i, x, y);
if (value<0) fill(color(265, 62, 75));
else fill(color(255));
let size = map(abs(value), 0.0, 1.0, 0.0, maxDim/8.0, true);
ellipse(map(x, -0.5, 15.5, windowCenterX-maxDim, windowCenterX+maxDim),
map(y, -0.5, 15.5, windowCenterY-maxDim, windowCenterY+maxDim), size, size);
}
}