Skip to content

Commit

Permalink
Add check for minimum width in drawAutomated
Browse files Browse the repository at this point in the history
  • Loading branch information
yoonieaj committed Jun 27, 2024
1 parent 53769eb commit 7a0775b
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions memory-viz/src/automate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,25 @@ function drawAutomated(objects: DrawnEntity[], width, configuration) {
// Assigning the objects with coordinates.
const { StackFrames, requiredHeight, requiredWidth } =
drawAutomatedStackFrames(stack_frames, configuration);

// Determining the minimum width of the canvas.
let min_width = 0;
let item_width;
for (const item of other_items) {
item_width = getSize(item).width;
min_width = item_width > min_width ? item_width : min_width;
}

min_width +=
requiredWidth + configuration.padding + configuration.left_margin;

if (width < min_width) {
console.warn(
`Warning: provided width (${width}) is smaller than the minimum width of the canvas (${min_width}).`
);
width = min_width;
}

const { objs, canvas_height } = drawAutomatedOtherItems(
other_items,
width,
Expand Down

0 comments on commit 7a0775b

Please sign in to comment.