I'm trying to make a final sketch which final goal is basically to have an input box, submitting a word in it, and getting the spelling of the word, letter by letter. I have both sketches made, the input box one, and the spelling one, but I have tried multiple times and I can't seem to combine both sketches. For all it's worth here's the code.
let input, button, visualization;
var img;
function setup() {
// create canvas
createCanvas(600 , 600);
input = createInput();
input.position(20, 65);
button = createButton('submit');
button.position(input.x + input.width, 65);
button.mousePressed(visualize);
visualization = createElement('h2', 'Type a word to get its spelling');
visualization.position(20, 5);
textAlign(CENTER);
textSize(50);
}
function visualize() {
const word = input.value();
visualization.html('This is the spelling of ' + word + '!');
input.value('');
}
for the input box.
var sourceText = 'word';
var curIndex = 0;
function setup() {
createCanvas(400, 400);
frameRate(3);
}
function draw() {
background(50);
fill(255);
textSize(144);
textAlign(CENTER, CENTER);
text(
sourceText.substring(curIndex, curIndex+1),
width/2, height/2);
curIndex++;
if (curIndex > sourceText.length) {
curIndex = 0;
}
}
For the spelling visualization.