I need to find a ratio for a rectangle bound such that the rectangles enclosed within that are not less than a preset value, say 20 unit.
figure
I should be able to scale the black rectangle only uniformly (both x and y axis together) and the rectangles within the box should scale appropriately. but the catch is that, when we reduce the scale of the bounding rectangle it should stop at a value where the smallest rectangle inside the the bounding rectangle is not less than 20 units (height or length, whichever is longer). I need to find the minimum scale ratio for the outer rectangle such that , the ratio will prevent the smallest rectangle's length or width(whichever is largest) from going below 20
for example, if the minimum scale ratio of the rectangle = 0.5 , the rectangle can't be scaled below 50% of it's largest side. I need to find the minimum scale ratio of the black rectangle so that it prevents the smallest rectangle from going below 20 units.
So far i have done like,
selection is the black rectangle
selectionScaleValue = Math.max(selection.width, selection.height)
also finds the smallest rectangle within the bounding rectangle, but i have no luck with the addressed issue. I currently fetches the
- selection rectangle height and width
- the smallest rectangle's height and width
- minimum size for the inner rectangle till it can down scaled (20 units)
I need to find the minimum scale ratio of the black rectangle so that it prevents the smallest rectangle from going below 20 units.