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. This is a Photoshop extension that I am writing, but it's just basic javascript.
I have a template that is built on a 4200 x 4200 square. That script draws squares based on coordinates contained within that template {L,R,T,B}. The template can be applied to any document size. If that document size is not square, my ratios are off. Any ideas on the math behind this?
Thanks for any help and if I am not clear or you need more info let me know!
I have a template that is built on a 4200 x 4200 square. That script draws squares based on coordinates contained within that template {L,R,T,B}. The template can be applied to any document size. If that document size is not square, my ratios are off. Any ideas on the math behind this?
Thanks for any help and if I am not clear or you need more info let me know!
Code:
[FONT=lucida console][COLOR=#0B374D]var wd = width of template[/COLOR][/FONT]
[FONT=lucida console]var hd = height of template
var maxWidth = (activeDocument.width); //width of active document
var maxHeight = 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) ;[/FONT][FONT=Droid Serif]
[/FONT]