xxxxxxxxxx
49
var weather;
var api="https://api.openweathermap.org/data/2.5/weather?q="
var city="St Louis";
var APIkey="&appid=1bce8855c246f339b2384bc4e27930a6";
var units="&units=imperial";
function setup() {
createCanvas(400, 400);
input=select('#city');
var button=select('#submit');
button.mousePressed(weatherAsk)
}
function weatherAsk(){
var url=api+input.value()+APIkey+units;
loadJSON(url, gotData);
}
function gotData(data){
// println(data);
weather=data;
}
function draw() {
background(220);
if (weather){
var temp = weather.main.temp;
var humidity = weather.main.humidity;
var wind = weather.wind.speed
console.log(temp);
console.log(humidity);
console.log(wind);
stroke(100, 100, 240);
ellipse(width/2, height/2, temp, temp);
noFill();
stroke(255);
ellipse(width/2, height/2,humidity*2, humidity*2);
stroke(0);
ellipse(width/2, height/2,wind*2, wind*2);
}
}