function
setup() {
createCanvas(600, 300);
textSize(20);
text(
"Click on the button below to "
+
"save the Table Object"
, 20, 20);
text(
"Select the output format:"
, 20, 60);
radio = createRadio();
radio.position(30, 80);
radio.option(
'csv'
);
radio.option(
'tsv'
);
radio.option(
'html'
);
saveBtn = createButton(
"Save Table to file"
);
saveBtn.position(30, 120);
saveBtn.mousePressed(saveFile);
table =
new
p5.Table();
table.addColumn(
'Invention'
);
table.addColumn(
'Inventors'
);
let tableRow = table.addRow();
tableRow.setString(
'Invention'
,
'Telescope'
);
tableRow.setString(
'Inventors'
,
'Galileo'
);
tableRow = table.addRow();
tableRow.setString(
'Invention'
,
'Steam Engine'
);
tableRow.setString(
'Inventors'
,
'James Watt'
);
tableRow = table.addRow();
tableRow.setString(
'Invention'
,
'Radio'
);
tableRow.setString(
'Inventors'
,
'Guglielmo Marconi'
);
}
function
saveFile() {
outputFormat = radio.value();
saveTable(table,
'tableOutput'
, outputFormat);
}