From 839cdf2b855e09a4bf838e0b59fc5b9e42a2b2ba Mon Sep 17 00:00:00 2001 From: Rick Sidwell Date: Tue, 25 Nov 2025 10:44:56 -0700 Subject: [PATCH] Fix 2.x Table and JSON examples --- .../en/14_Loading_And_Saving_Data/01_JSON/code.js | 10 +++------- .../en/14_Loading_And_Saving_Data/02_Table/code.js | 1 + 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/src/content/examples/en/14_Loading_And_Saving_Data/01_JSON/code.js b/src/content/examples/en/14_Loading_And_Saving_Data/01_JSON/code.js index a9ecb95963..c9740ce01e 100644 --- a/src/content/examples/en/14_Loading_And_Saving_Data/01_JSON/code.js +++ b/src/content/examples/en/14_Loading_And_Saving_Data/01_JSON/code.js @@ -8,12 +8,6 @@ let mousePressY = 0; // Remember whether bubble is currently being created let creatingBubble = false; -// Put any asynchronous data loading in preload to complete before "setup" is run -function preload() { - // Load the JSON file and then call the loadData() function below - loadJSON('/assets/bubbles.json', loadData); -} - // Convert saved bubble data into Bubble Objects function loadData(bubblesData) { bubbles = []; @@ -31,9 +25,11 @@ function loadData(bubblesData) { } } -function setup() { +async function setup() { let p5Canvas = createCanvas(640, 360); + await loadJSON('/assets/bubbles.json', loadData); + // When canvas is clicked, call saveMousePress() p5Canvas.mousePressed(saveMousePress); diff --git a/src/content/examples/en/14_Loading_And_Saving_Data/02_Table/code.js b/src/content/examples/en/14_Loading_And_Saving_Data/02_Table/code.js index 017ebac599..c64d6131d1 100644 --- a/src/content/examples/en/14_Loading_And_Saving_Data/02_Table/code.js +++ b/src/content/examples/en/14_Loading_And_Saving_Data/02_Table/code.js @@ -25,6 +25,7 @@ function loadData(table) { // Put object in array bubbles.push(new Bubble(x, y, radius, name)); } + return table; } async function setup() {