xxxxxxxxxx
138
let jsonFile;
let dataPoints = [];
let sentence = ['you', 'are', 'what', 'you', 'listen', 'to'];
let ts = 11;
let word;
let sceneNum = 0;
let button;
function preload() {
jsonFile = loadJSON('chau_data.json');
myFont = loadFont('Supply-UltraLight.otf');
}
function setup() {
createCanvas(600, 600);
console.log(jsonFile)
button = createButton('Continue');
button.position(265, 350);
button.mousePressed(changeSc);
button.show();
button.hide();
for (let x in jsonFile) {
let currentDot =
{
x: width - 550 / jsonFile[x].day,
y: random(10, 580),
day: jsonFile[x].day,
time: jsonFile[x].time,
song: jsonFile[x].song,
artist: jsonFile[x].artist
};
dataPoints.push(currentDot)
}
setInterval(one, 1000);
setInterval(two, 2000);
setInterval(three, 3000);
setInterval(four, 4000);
setInterval(five, 5000);
setInterval(six, 6000);
}
function draw() {
switch (sceneNum) {
case 0:
scene0(); // DISCLAIMER
break;
case 1:
scene1(); // DATA PORTRAIT
button.hide();
break;
}
if (sceneNum == 0) {
button = createButton('Continue');
button.position(265, 350);
button.show();
button.mousePressed(changeSc);
} else {
button.hide();
}
}
function scene0() {
background(0);
push();
textSize(14);
fill(255);
text('Warning: The next page contains effects, like flashing lights or certain visual patterns, that can be harmful to people with photosensitive epilepsy.', 120, 250, 350);
pop();
}
function scene1() {
background(0);
for (let i = 0; i < dataPoints.length; i++) {
fill(random(255), random(255), random(255));
noStroke();
// ellipse(dataPoints[i].x, dataPoints[i].y, dataPoints[i].day * 3);
ellipse(dataPoints[i].x, dataPoints[i].y, random(dataPoints[i].day, dataPoints[i].day + 20));
if (dist(mouseX, mouseY, dataPoints[i].x, dataPoints[i].y) < 5) {
fill('white');
textSize(ts);
text(dataPoints[i].song, dataPoints[i].x + 10, dataPoints[i].y);
text(dataPoints[i].artist, dataPoints[i].x + 10, dataPoints[i].y + 12.5);
}
}
push();
textSize(40);
fill(255);
translate(0, 300);
textFont(myFont);
text(word, 120, 0);
pop();
}
function changeSc() {
sceneNum++;
removeElements();
}
function one() {
word = sentence[0];
}
function two() {
word = sentence[1];
}
function three() {
word = sentence[2];
}
function four() {
word = sentence[3];
}
function five() {
word = sentence[4];
}
function six() {
word = sentence[5];
}