Skip to content

Commit

Permalink
Update script.js
Browse files Browse the repository at this point in the history
  • Loading branch information
Demothedread authored Jan 22, 2024
1 parent 66db454 commit 1fc2ac9
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions script.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,14 @@ function generateShapes(maxWidth, maxHeight, minShapes, maxShapes, lines) {

if (isShapeValid(newShape, shapes, lines)) {
shapes.push(newShape);
console.log("how many shapes:", shapes)
console.log("how many shapes:", shapes.length);
}

return shapes;
}

return shapes;
}


function generateQuadrangleBetweenLines(lines, maxWidth, maxHeight) {
// Separate vertical and horizontal lines
let verticalLines = lines.filter(line => line.orientation === 'vertical').sort((a, b) => a.x - b.x);
Expand All @@ -78,10 +79,11 @@ function generateQuadrangleBetweenLines(lines, maxWidth, maxHeight) {
return {
x: vertGap.start + vertGap.thickness,
y: horizGap.start + horizGap.thickness,
width: vertGap.end - vertGap.start - vertGap.thickness,
height: horizGap.end - horizGap.start - horizGap.thickness
width: vertGap.end - (vertGap.start + vertGap.thickness),
height: horizGap.end - (horizGap.start + horizGap.thickness)
};
}
}

function selectRandomGap(lines, maxDimension) {
let gapIndex = Math.floor(Math.random() * (lines.length - 1));
Expand Down Expand Up @@ -168,7 +170,7 @@ function placeButtons(shapes) {
shapes.forEach(shape => {
if (placedButtons < buttons.length) {
let button = document.getElementById(buttons[placedButtons]);
button.style.position = 'absolute';
button.style.position = "absolute";
button.style.left = `${shape.x + (shape.width / 2)}px`;
button.style.top = `${shape.y + (shape.height / 2)}px`;
placedButtons++;
Expand Down

0 comments on commit 1fc2ac9

Please sign in to comment.