let waveType = ["sin", "cos"];
let pallete = ["#333333", "#5D737E", "#FFF07C", "#87BBA2", "#F0F7EE"];
colorMode(HSB, 360, 100, 100, 100);
cells = int(random(2, 5));
graphics = createGraphics(width, height);
graphics.colorMode(HSB, 360, 100, 100, 100);
drawNoiseBackground(100000, graphics);
offset = width / cells / int(random(5, 10));
margin = offset / int(random(2, 5));
w = (width - offset * 2 - margin * (cols - 1)) / cols;
h = (height - offset * 2 - margin * (rows - 1)) / rows;
for (let j = 0; j < rows; j++) {
for (let i = 0; i < cols; i++) {
let x = map(i, 0, cols - 1, offset, width - offset - w);
let y = map(j, 0, rows - 1, offset, height - offset - h);
waves.push(new Wave(x, y, w, h));
function drawNoiseBackground(_n, _graphics) {
for (let i = 0; i < _n; i++) {
let x = random(1) * width;
let y = random(1) * height;
_graphics.fill(0, 0, 100, 3);
_graphics.ellipse(x, y, w, h);
constructor(_x, _y, _w, _h) {
this.waveTypes = [waveType[int(random(2))], waveType[int(random(2))]];
this.bound = new Bound(_x, _y, _w, _h);
this.freqA = sqrt(random(1)) * 3 * (random(100) > 50 ? -1 : 1);
this.freqB = sqrt(random(1)) * 3 * (random(100) > 50 ? -1 : 1);
this.freqC = sqrt(random(1)) * 3 * (random(100) > 50 ? -1 : 1);
let cc = int(random(pallete.length)) % pallete.length;
translate(this.bound.x, this.bound.y + this.bound.h / 2);
for (let x1 = 0; x1 < this.bound.w; x1 += .9) {
let y1 = eval(this.waveTypes[0] + "((x1+f) * this.freqA) * " + this.waveTypes[1] + "((x1+f) * this.freqB) * this.bound.w / 4");
let y2 = eval(this.waveTypes[0] + "((x2+f) * this.freqA) * " + this.waveTypes[1] + "((x2+f) * this.freqB) * this.bound.w / 4");
let angle = atan2(y2 - y1, x2 - x1);
let d = sin((x1 + y1) * this.freqC) * margin * 2;
if (dDir != this.prevDDir) {
c = int(random(pallete.length)) % pallete.length;
c = int(random(pallete.length)) % pallete.length;
ellipse(0, -d / 2, d, d);
constructor(_x, _y, _w, _h) {