xxxxxxxxxx
59
let myTable;
let row = [];
let similarWords = [];
let myWord = "food";
let field;
let names = [];
let button;
function preload() {
myTable = loadTable('Book1.csv', 'csv', 'header');
field = createInput();
button = createButton("Favorite Food");
button.mousePressed(addName);
similarWords = RiTa.similarBySound(myWord);
}
function setup() {
createCanvas(400, 400);
textSize(18);
fill(0);
textFont('Futura');
for (let i = 0; i < myTable.getRowCount(); i++) {
row[i] = int(random(myTable.getRowCount()));
print(row[i]);
}
}
function draw() {
background(255);
for (let i = 0; i < myTable.getColumnCount(); i++) {
text(myTable.getString(row[i], i), 50 + (100 * i), height / 2);
}
text("My favorite food is " + names[0], 50, 100);
text(similarWords.join(" "), 10, 300, 400, 400);
}
function mousePressed() {
for (let i = 0; i < myTable.getRowCount(); i++) {
row[i] = int(random(myTable.getRowCount()));
print(row[i]);
}
}
function addName(){
let f = field.value();
names.splice(0,1,f);
print(names);
}