xxxxxxxxxx
let weather;
let currentIndex = 0;
let windSpeed;
function preload() {
weather = loadJSON("https://api.open-meteo.com/v1/forecast?latitude=52.52&longitude=13.41&hourly=wind_direction_180m,wind_speed_180m");
}
function setup() {
createCanvas(400, 400);
// console.log(weather);
windSpeed = weather.hourly.wind_speed_180m;
// console.log(windSpeed);
}
function draw() {
background(220);
//console.log(windSpeed[currentIndex]);
let mappedWindSpeed = map(windSpeed[currentIndex], 0, 50, 0, 200);
line (width/2, height/2, width/2 + mappedWindSpeed, height/2);
currentIndex++;
if (currentIndex > windSpeed.length - 1) {
currentIndex = 0;
}
}