Resize obj based on the size of the clipping mask contained in it to match the size of another obj
Hello everyone,
i have a script with a function that resizes and positions one object (`odjFit`) to fit within another object (`odjTo`). It calculates a scaling factor based on the dimensions of the two objects, resizes `odjFit` accordingly, and aligns their centers.
function fitObj(odjFit, odjTo) {
var w1 = odjFit.width, h1 = odjFit.height, w2 = odjTo.width, h2 = odjTo.height;
var r = Math.min(w2/w1, h2/h1);
odjFit.resize(r*100,r*100);
var x1 = odjFit.left + odjFit.width/2, y1 = odjFit.top, x2 = odjTo.left + odjTo.width/2, y2 = odjTo.top;
odjFit.translate(x2 - x1, y2 - y1);
};
the problem is that the object odjFit contains a clipping mask with objects way bigger than the mask itself so the function calculates w1and h1 considering these objects too. I want it to calculates w1 and h1 based only on the width and height of the object odjFit itself (which is the same as the dimensions of the clipping mask). Then the objects inside the clipping mask should be resized accordingly.
I hope i made myself clear.
Thanks for the help.
Cheers.
