xxxxxxxxxx
200
let fontRegular, fontItalic;
let genreurl;
let storyurl;
// let toggle = true;
let sceneNum = 1;
let btn1, btn2;
function preload() {
fontItalic = loadFont('SourceSansPro-LightItalic.ttf');
fontRegular = loadFont('SourceSansPro-Regular.ttf');
fontLight = loadFont('SourceSansPro-Light.ttf');
// loadJSON(genreurl + storyurl, gotData);
storyurl = loadJSON('https://binaryjazz.us/wp-json/genrenator/v1/story/5/', gotData);
genreurl = loadJSON('https://binaryjazz.us/wp-json/genrenator/v1/genre/5/', gotData);
}
function setup() {
createCanvas(600, 600);
background('#1D2747');
btn1 = createButton('Switch to stories');
btn1.position(170, 490);
btn1.mousePressed(change);
btn1.hide();
btn1.style('color','white');
btn1.style('border','1px solid white');
btn1.style('background','none');
btn1.style('width','130px');
btn1.style('height','40px');
btn1.style('border-radius','15px');
// btn1.style('cursor','HAND');
btn2 = createButton('Switch to genres');
btn2.position(width - 155, 490);
btn2.mousePressed(change);
btn2.hide();
btn2.style('color','white');
btn2.style('border','0.5px solid white');
btn2.style('background','none');
btn2.style('width','130px');
btn2.style('height','40px');
btn2.style('border-radius','15px');
// btn1.style('cursor','HAND');
btn3 = createButton('Generate again');
btn3.position(30, 490);
btn3.mousePressed(preload);
btn3.hide();
btn3.style('color','white');
btn3.style('border','1px solid white');
btn3.style('background','none');
btn3.style('width','130px');
btn3.style('height','40px');
btn3.style('border-radius','15px');
// btn1.style('cursor','HAND');
btn4 = createButton('Generate again');
btn4.position(300, 490);
btn4.mousePressed(preload);
btn4.hide();
btn4.style('color','white');
btn4.style('border','1px solid white');
btn4.style('background','none');
btn4.style('width','130px');
btn4.style('height','40px');
btn4.style('border-radius','15px');
// btn1.style('cursor','HAND');
//0101
for (let x = -10; x < 650; x += 45) {
for (let y = 92; y < 270; y += 60) {
let arr = ['0', '0', '0', '0', '1'];
let num = arr[int(random(5))];
// console.log(num);
fill('#ec407a');
textSize(65);
textFont(fontRegular);
text(num, x, y);
}
}
noStroke();
fill('#2B2D86');
rect(0, 0, width, 40);
rect(0, 220, width, 500);
//quote on top
fill(255);
textAlign(CENTER);
textFont(fontItalic);
// textStyle(ITALIC);
textSize(15);
text('“Without music, life would be a mistake.” ― Friedrich Nietzsche', width / 2, 25);
}
function draw() {
switch (sceneNum) {
case 1:
push();
fill('#2B2D86');
rect(0, 220, width, 500);
pop();
push();
fill(255);
textAlign(CENTER);
textFont(fontItalic);
text('Explore more about what caught your eyes at http://everynoise.com/everynoise1d.cgi?scope=all', width / 2, height - 20);
textAlign(CENTER);
text('Refresh the page to generate a new list :P', width / 2, 260);
pop();
// text(story, width / 2, height / 2);
//story
push()
for (let i = 0; i < 5; i++) {
textAlign(LEFT);
textFont(fontRegular, 17);
text(genreurl[i], 30, 305 + i * 40);
// toggle = true;
}
btn1.show();
btn3.show();
btn2.hide();
btn4.hide();
pop()
break;
case 2:
push();
fill('#2B2D86');
rect(0, 220, width, 500);
pop();
push();
fill(255);
textAlign(CENTER);
textFont(fontItalic);
text('Explore more about what caught your eyes at http://everynoise.com/everynoise1d.cgi?scope=all', width / 2, height - 20);
textAlign(CENTER);
text('Refresh the page to generate a new list :P', width / 2, 260);
pop();
//genres
push()
for (let i = 0; i < 5; i++) {
textAlign(RIGHT);
textFont(fontRegular, 17);
text(storyurl[i], width - 30, 305 + i * 40);
// toggle = false;
}
btn1.hide()
btn2.show();
btn3.hide();
btn4.show();
pop()
break;
}
}
function change() {
if (sceneNum == 1) {
sceneNum += 1;
} else {
sceneNum -= 1;
}
// gotData(storydata, genredata);
}
// function reload(){
// window.location.reload();
// }
function gotData(storydata, genredata) {
storydata = storyurl;
genredata = genreurl;
// if (toggle == true){
// window.location.reload();
// toggle = false;
// } else {
// window.location.reload();
// toggle = true;
// }
}