xxxxxxxxxx
75
/********************************/
/***-- Variables to change ---***/
/********************************/
let questionText = "what do you need to know?";
let x = 40, y = 40;
let n = 3;
let numSentences = 3;
//trying to load a background image
//let bg;
/****************************************/
/***-- DO NOT EDIT BELOW THIS LINE ---***/
/****************************************/
let markov;
let source;
let displayText = [""];
function preload() {
source = loadStrings('source.txt');
}
function setup() {
createCanvas(500, 500);
createCanvas(windowWidth,windowHeight)
background(100);
fill(0);
textSize(18)
inp = createInput(questionText);
inp.position(50, 450);
inp.size(200);
button = createButton('submit');
button.position(250, 450);
button.mousePressed(generateText);
// create a markov model w' n=4
markov = RiTa.markov(n);
// load text into the model
markov.addText(source.join(' '));
drawText();
}
/*function draw(){
image(background, width/2, height/2)
}
function preload (){
background = loadImage('Gemini_Generated_Image_dci9wwdci9wwdci9.jpg')
}*/
function drawText() {
background(255, 255, 255);
text(displayText.join(' '), x, y, 420, 440);
}
function generateText() {
displayText = markov.generate(numSentences);
drawText();
// load text into the model
markov.addText(source.join(' '));
drawText();
}
function drawText() {
background(255, 255, 255);
text(displayText.join(' '), x, y, 420, 440);
}
function generateText() {
displayText = markov.generate(numSentences);
drawText();
}