JSFiddle - React, Tailwind, and code Playground

by Drath

JavaScript

//PSEUDO system for testing

var particles = [];
particles.push({x:33, y:555});
particles.push({x:11, y:788});
particles.push({x:901, y:22});
particles.push({x:25, y:700});

var clearminx = 0, clearmaxx = 1000, clearminy = 0, clearmaxy = 1000;
    
//Add extra 5 on to particles max due to their max width/height
for(var i in particles) {
    if (particles[i].x >= clearminx) {
        clearminx = particles[i].x+5;
    } 
    if (particles[i].y >= clearminy) {
        clearminy = particles[i].y+5;
    }          
 
    if (particles[i].x <= clearmaxx ) {
        clearmaxx = particles[i].x;
    } 
    if (particles[i].y <= clearmaxy) {
        clearmaxy = particles[i].y;
    }       
}
 
document.write("Min X: " + clearmaxx + "<br />");
document.write("Min Y: " + clearmaxy + "<br />");
document.write("Max X: " + clearminx + "<br />");
document.write("Max Y: " + clearminy + "<br />");