xxxxxxxxxx
90
// To use an image as a button, replace the createButton() function with createImage() and attach the same functionality to the image as you would to the button.
// You must include the dom library in this sketch.
// This is adapted from the button example in the p5 dom library. https://p5js.org/reference/#/p5/createButton
let fortunes = [
"Holding to the affections to resist, shaking the heart to cement",
"What the soul does to the body, the artist does to the people",
"My only country is my memory and it has no hymns",
"Hope is an uncharted territory",
"Vision will not die destroying eyes",
"Embrace your land, find your river",
"Memory is ungovernable",
"The heart is the size of a fist",
"We will sprout again as native forest",
"May their revolution give them a piece of red sky",
"Radical tenderness against capital",
"Our dead are more alive every day in a song of love that reborns them",
"Where the stubborn humidity of their memory does not dry up",
];
let currentFortune = "";
var button;
var button2;
function preload() {
fondo =loadImage('/assets/datacenter.jpg');
}
function setup() {
createCanvas(windowWidth, windowHeight);
background(fondo);
button = createImg(
'arveja.png');
button.position(5,160,150,190);
button.mousePressed(pickFortune);
button1 = createImg(
'azul.png',
'azul');
button1.position(170,150,80,100);
button1.mousePressed(pickFortune);
button2 = createImg(
'personality.png',
'the p5 magenta asterisk');
button2.position(280,150,70,90);
button2.mousePressed(pickFortune);
button3 = createImg(
'personality.png',
'the p5 magenta asterisk');
button3.position(860,150,110,130);
button3.mousePressed(pickFortune);
button4 = createImg(
'personality.png',
'the p5 magenta asterisk');
button4.position(750,150,90,110);
button4.mousePressed(pickFortune);
button5 = createImg(
'personality.png',
'the p5 magenta asterisk');
button5.position(650,150,90,90);
button5.mousePressed(pickFortune);
}
function draw() {
fill(255)
textStyle(BOLD);
textFont('Courier New');
textSize(21);
fill(255);
stroke(0);
strokeWeight(4);
textAlign(CENTER, CENTER);
text(currentFortune, 500, 250)
}
function changeBG() {
var val = random(255);
background(val);
}
function pickFortune() {
currentFortune = random(fortunes)
}