xxxxxxxxxx
144
let data;
function preload() {
data = loadTable('data.csv', 'csv', 'header');
}
function setup() {
createCanvas(windowWidth,windowHeight);
noFill();
background(255,10);
}
function draw() {
background(0,10);
// Grain Effect
Grain();
// Function to add grain effect
function Grain() {
let grainIntensity = 100*(frameCount*1); // intensity
for (let i = 0; i < grainIntensity; i++) {
let x = random(width);
let y = random(height);
let c = color(random(255), random(255), random(255),80); // Random color with some transparency
stroke(c);
point(x, y);
}
}
// Add Glitch Effect
Glitch();
// Function to add glitch effect
function Glitch() {
if (random() < 0.06) { // probability for glitch effect
let glitchWidth = random(200, windowWidth);
let glitchHeight = height;
let xOffset = random(-width * 1.5, width * 1); // Horizontal displacement
copy(0, 0, width, height, xOffset, 0, glitchWidth, glitchHeight);
}
}
if (data) {
let numRows = data.getRowCount();
let pulse = data.getColumn("pulse");
let breath = data.getColumn("breath");
let blink = data.getColumn("blink");
for (let i = 0; i < numRows; i++) {
// Pulse data shapes
let xPulse = windowWidth * 0.3 + sin(frameCount * 0.01 + i) * 300;
let yPulse = 100 + i * 80 + cos(frameCount * 0.01 + i) * 50;
let radiusPulse = pulse[i] * 0.5;
let cPulse = map(pulse[i], 255, true);
stroke(255, cPulse);
strokeWeight(0.5);
ellipse(xPulse, yPulse, radiusPulse * 2.5, radiusPulse * 2.5);
// Tangent lines for Pulse
TangentLines(xPulse, yPulse, radiusPulse, random(0,50)*(frameCount*0.01), [255, cPulse]);
// Breath data shapes
let xBreath = windowWidth * 0.5 + sin(frameCount * 0.1 + i * 20) * 15;
let yBreath = 100 + i * 80 + cos(frameCount * 0.01 + i * 2) * 40;
let sizeBreath = breath[i] * 20;
let cBreath = map(breath[i], 255, 100, true,100);
// noFill();
fill(255,255,255,0, cBreath);
ellipse(xBreath, yBreath, sizeBreath, sizeBreath);
// flowing lines for Breath
FlowingLines(xBreath, yBreath, sizeBreath / 2, 40, [255, 255, 255,10, cBreath]);
// Blink data shapes
let xBlink = windowWidth * 0.5 + sin(frameCount * 0.1 + i * 2) * 3;
let yBlink = 100 + i * 190 + cos(frameCount * 0.1 + i * 5) * 30;
let sizeBlink = blink[i] * 1.7;
let cBlink = map(blink[i], 255, true);
stroke(cBlink,50);
strokeWeight(2);
beginShape();
vertex(xBlink - sizeBlink, yBlink - sizeBlink);
vertex(xBlink + sizeBlink, yBlink - sizeBlink);
vertex(xBlink, yBlink + sizeBlink);
endShape(CLOSE);
// surreal shapes around Blink
SurrealShapes(xBlink, yBlink, sizeBlink, [cBlink]);
}
}
}
// Function to draw tangent lines around a circle
function TangentLines(x, y, radius, numLines, color) {
let angleStep = TWO_PI / numLines;
for (let i = 0; i < numLines; i++) {
let angle = i * angleStep;
let x1 = x + cos(angle) * radius;
let y1 = y + sin(angle) * radius;
let x2 = x + cos(angle + PI) * (radius + 50);
let y2 = y + sin(angle + PI) * (radius + 50);
stroke(color);
line(x1, y1, x2, y2);
}
}
// Function to draw flowing lines
function FlowingLines(x, y, radius, numLines, color) {
let angleStep = TWO_PI / numLines;
for (let i = 0; i < numLines; i++) {
let angle = i * angleStep;
let x1 = x + cos(angle) * radius;
let y1 = y + sin(angle) * radius;
let x2 = x + cos(angle + PI / 2) * (radius * 2);
let y2 = y + sin(angle + PI / 2) * (radius * 0.5);
stroke(color);
line(x1, y1, x2, y2);
}
}
// Function to draw surreal shapes
function SurrealShapes(x, y, size, color) {
let numShapes = random (100,100) * frameCount*(0.3);
for (let i = 0; i < numShapes; i++) {
let angle = i * TWO_PI / numShapes;
let xOffset = cos(angle) * size * 5;
let yOffset = sin(angle) * size * 50;
let xPos = x + xOffset;
let yPos = y + yOffset;
stroke(color);
strokeWeight(0.3);
ellipse(xPos, yPos, size / 2, size / 2);
}
}