Ratio of square sizes
So I'm out of my league on this math problem. I'll try to explain as simply as possible. Any help would be awesome.
I have a template that is built on a 4200 x 4200 square. That template draws squares based on coordinates contained within that template {L,T,R,B}. The template can be applied to any document size. If that document size is not square, my ratios are off. It's obviously an issue with my math so here is the script:
Thanks for any help you may have with my math deficiencies!!
var wd = width of template
var hd = height of template
var maxWidth = (activeDocument.width); //width of active document
var maxHeight = parseFloat(activeDocument.height); //height of active document
var ratioRec = wd/hd; //aspect ratio of template
var ratioView = maxWidth/maxHeight; //aspect ratio of document
var ratio = ratioView/ratioRec;
var ratioW = maxWidth/wd;
var ratioT = (maxHeight/hd);
//Sizing variables, this is where the problem is
var left = (left * ratioW);
var right = (right * ratioW) ;
var top = (top * ratioT);
var bottom = (bottom * ratioT) ;
