JSFiddle - React, Tailwind, and code Playground
by rlemon
JavaScript
var chords = [
{
x: 1,
y: 7,
h: 2,
w: 2},
{
x: 4,
y: 1,
h: 3,
w: 2},
];
var occupied = {
x: [],
y: []
};
chords.forEach(function(chord) {
occupied.x.push( chord.x );
occupied.x.push( chord.x + (chord.w-1) );
occupied.y.push( chord.y );
occupied.y.push( chord.y + (chord.h-1) );
});
console.log( occupied );