mirror of
https://github.com/processing/processing4.git
synced 2026-01-26 18:01:07 +01:00
cleanup JSON example more
This commit is contained in:
@@ -63,14 +63,19 @@ void draw() {
|
||||
bubbles = new Bubble[bubbleData.size()];
|
||||
|
||||
for (int i = 0; i < bubbleData.size(); i++) {
|
||||
// Get each object in the array
|
||||
JSONObject bubble = bubbleData.getObject(i);
|
||||
// Get a position object
|
||||
JSONObject position = bubble.getJSONObject("position");
|
||||
// Get x,y from position
|
||||
int x = position.getInt("x");
|
||||
int y = position.getInt("y");
|
||||
|
||||
float diameter = (float)bubble.getDouble("diameter");
|
||||
|
||||
// Get diamter and label
|
||||
float diameter = bubble.getFloat("diameter");
|
||||
String label = bubble.getString("label");
|
||||
|
||||
// Put object in array
|
||||
bubbles[i] = new Bubble(x, y, diameter, label);
|
||||
}
|
||||
}
|
||||
@@ -85,7 +90,7 @@ void draw() {
|
||||
position.setInt("y", mouseY);
|
||||
|
||||
// Add position to bubble
|
||||
//newBubble.setJSONObject("position", position);
|
||||
newBubble.setJSONObject("position", position);
|
||||
|
||||
// Add diamater and label to bubble
|
||||
newBubble.setFloat("diameter", random(40, 80));
|
||||
|
||||
Reference in New Issue
Block a user