xxxxxxxxxx
73
///*
let input, submit, value1;
function setup() {
createCanvas(400, 400);
resetSketch();
submit = createButton('Enter');
submit.position(width / 2 - 0.5 * submit.width, height * 3 / 5);
submit.mousePressed(val);
input = createInput();
input.position(width / 2 - 0.5 * input.width, height / 2);
}
function val() {
if (value1 < 1) {
const typed = input.value();
input.value('');
textSize(32);
fill(255);
textAlign(CENTER);
text(typed, width / 2, height / 3);
value1++;
} else if (value1 > 0) {
resetSketch();
} else {
value1++;
}
}
function resetSketch() {
value1 = 0;
background(0);
}
//*/
/*
let input, button, greeting, poop;
function setup() {
// create canvas
createCanvas(710, 400);
input = createInput();
input.position(20, 65);
button = createButton('submit');
button.position(input.x + input.width, 65);
button.mousePressed(greet);
greeting = createElement('h2', 'what is your name?');
greeting.position(20, 5);
textAlign(CENTER);
textSize(50);
}
function greet() {
const name = input.value();
input.value('');
for (let i = 0; i < 200; i++) {
push();
fill(random(255), 255, 255);
translate(random(width), random(height));
rotate(random(2 * PI));
text(name, 0, 0);
pop();
}
}
*/