How to detect the boundary?

Write a program that enables the user to add and remove points in a two-dimensional plane dynamically, as shown in Figure 15.31a. A minimum bounding rectangle is updated as the points are
added and removed. Assume the radius of each point is 10 pixels.

in a canvas, left-click to add a circle, expand the range of the canvas (rectangle) if the circle is not in the canvas; right-click to delete the circle, and narrow the canvas range if you delete the one on the boundary.
the question is, how do you detect boundaries if you want to shrink them? Do you need any complex data structures?

Jun.16,2022

Store the position of the inner circle as an ordered array (incrementing as an example), delete the add all Operand array and reorder

data = [
    {
        top:10,
        left:100
    }
    ...
]

the data is as above. Finding the maximum and minimum values after each operation is the boundary

.
Menu