xxxxxxxxxx
/*
Inspired by the Tixy land: https://tixy.land/
by Juan Carlos Ponce Campuzano
Date: 12/Dec/2024
*/
let rows = 70;
let cols = 70;
let diameter = 9;
let t = 0;
function setup() {
createCanvas(650, 650);
colorMode(HSB, 360, 100, 100); // Set color mode to HSB (hue, saturation, brightness)
}
function draw() {
background(0); // Set background color to black
for (let i = 0; i < rows; i++) {
for (let j = 0; j < cols; j++) {
let x = i * (width / cols) + diameter / 2;
let y = j * (height / rows) + diameter / 2;
let patternValue = funPattern(myLog(i, -j), myAtan2(i, -j), t);
let r = funRadius(patternValue);
if (patternValue < 0) {
// Map patternValue to hue for rainbow effect
let hue = map(patternValue, -1, 0, 0, 360);
fill(hue, 100, 100); // Rainbow color for negative pattern value
} else {
fill("#262626"); // White color for hearts with positive pattern value
}
ellipse(x, y, r);
}
}
t += 0.03;
}
let u = 35;
let v = -35;
let myLog = (x, y) => {
x = x - u;
y = y - v;
if (x == 0 && y == 0) {
return 0;
} else return 6 * log(sqrt(x * x + y * y));
};
let myAtan2 = (x, y) => {
x = x - u;
y = y - v;
if (x == 0 && y == 0) {
return 0;
} else return 6 * atan2(y, x);
};
let funPattern = (x, y, t) => {
let scale = 1;
return cos(cos(scale * x - t) + 2 * cos(scale * y - abs(sin(scale * x - t))));
};
let funRadius = (x) => diameter * abs(2 / (1 + exp(-5 * x)) - 1);