@@ -183,11 +183,14 @@ p5.prototype.loadFont = function (path, onSuccess, onError) {
183
183
* operation before setup() and draw() are called.</p>
184
184
*
185
185
* <div><code>
186
- * var weather;
186
+ * // Examples use USGS Earthquake API:
187
+ * // https://earthquake.usgs.gov/fdsnws/event/1/#methods
188
+ * var earthquakes;
187
189
* function preload() {
188
- * var url = 'http://api.openweathermap.org/data/2.5/weather?q=London,UK'+
189
- * '&APPID=7bbbb47522848e8b9c26ba35c226c734';
190
- * weather = loadJSON(url);
190
+ * // Get the most recent earthquake in the database
191
+ * var url = 'https://earthquake.usgs.gov/fdsnws/event/1/query?' +
192
+ * 'format=geojson&limit=1&orderby=time';
193
+ * earthquakes = loadJSON(url);
191
194
* }
192
195
*
193
196
* function setup() {
@@ -196,10 +199,12 @@ p5.prototype.loadFont = function (path, onSuccess, onError) {
196
199
*
197
200
* function draw() {
198
201
* background(200);
199
- * // get the humidity value out of the loaded JSON
200
- * var humidity = weather.main.humidity;
201
- * fill(0, humidity); // use the humidity value to set the alpha
202
- * ellipse(width/2, height/2, 50, 50);
202
+ * // Get the magnitude and name of the earthquake out of the loaded JSON
203
+ * var earthquakeMag = earthquakes.features[0].properties.mag;
204
+ * var earthquakeName = earthquakes.features[0].properties.place;
205
+ * ellipse(width/2, height/2, earthquakeMag * 10, earthquakeMag * 10);
206
+ * textAlign(CENTER);
207
+ * text(earthquakeName, 0, height - 30, width, 30);
203
208
* }
204
209
* </code></div>
205
210
*
@@ -209,20 +214,22 @@ p5.prototype.loadFont = function (path, onSuccess, onError) {
209
214
* <div><code>
210
215
* function setup() {
211
216
* noLoop();
212
- * var url = 'http ://api.openweathermap.org/data/2.5/weather?q=NewYork' +
213
- * '&APPID=7bbbb47522848e8b9c26ba35c226c734 ';
214
- * loadJSON(url, drawWeather );
217
+ * var url = 'https ://earthquake.usgs.gov/fdsnws/event/1/query?' +
218
+ * 'format=geojson&limit=1&orderby=time ';
219
+ * loadJSON(url, drawEarthquake );
215
220
* }
216
221
*
217
222
* function draw() {
218
223
* background(200);
219
224
* }
220
225
*
221
- * function drawWeather(weather) {
222
- * // get the humidity value out of the loaded JSON
223
- * var humidity = weather.main.humidity;
224
- * fill(0, humidity); // use the humidity value to set the alpha
225
- * ellipse(width/2, height/2, 50, 50);
226
+ * function drawEarthquake(earthquakes) {
227
+ * // Get the magnitude and name of the earthquake out of the loaded JSON
228
+ * var earthquakeMag = earthquakes.features[0].properties.mag;
229
+ * var earthquakeName = earthquakes.features[0].properties.place;
230
+ * ellipse(width/2, height/2, earthquakeMag * 10, earthquakeMag * 10);
231
+ * textAlign(CENTER);
232
+ * text(earthquakeName, 0, height - 30, width, 30);
226
233
* }
227
234
* </code></div>
228
235
*
0 commit comments