T
Tuxedo
How can a height value based on a width and an aspect ratio be calculated
in Javascript?
In a basic html situation, where the width of an object is known first, say
an html div by its ID scrollWidth property, how can the height of that div
(or some other object) be calculated and set by an aspect ratio?
For example, an 834 pixels wide x 246 pixels tall rectangle, or a 500
pixels wide x 147 pixels tall rectancle, both have an aspect ratio of
139:41, at least according to a nifty Aspect Ratio Calculator application
at: http://andrew.hedges.name/experiments/aspect_ratio
Only knowing the exact width to start with, the resulting height may be
rounded to the nearest pixel value of a given aspect ratio.
How can this best be calculated in Javascript?
Many thanks for any ideas!
Tuxedo
in Javascript?
In a basic html situation, where the width of an object is known first, say
an html div by its ID scrollWidth property, how can the height of that div
(or some other object) be calculated and set by an aspect ratio?
For example, an 834 pixels wide x 246 pixels tall rectangle, or a 500
pixels wide x 147 pixels tall rectancle, both have an aspect ratio of
139:41, at least according to a nifty Aspect Ratio Calculator application
at: http://andrew.hedges.name/experiments/aspect_ratio
Only knowing the exact width to start with, the resulting height may be
rounded to the nearest pixel value of a given aspect ratio.
How can this best be calculated in Javascript?
Many thanks for any ideas!
Tuxedo