xxxxxxxxxx
29
//in this practice
//we created a flower.json file
//and used loadJSON function to load data
//from that file
//in Dan's video 10.2, he had to use preload() to make sure
//data is loaded before it is called
//but in this practice, we didnt need to do that
//Notice there is a bug that requires a "/" in front of "flower.json"
//in order for it to load the data. It is not required in every json file though
let flower;
function preload() {
flower = loadJSON("/flower.json");
}
function setup() {
createCanvas(400, 400);
}
function draw() {
background(0);
fill(flower.r, flower.g, flower.b);
text(flower.name, 10, 50);
}