- From: Ruud Steltenpool <svg@steltenpower.com>
- Date: Mon, 20 Apr 2009 02:11:57 +0200
- To: www-svg@w3.org
According to this:
<svg xmlns="http://www.w3.org/2000/svg" onclick="calculate()">
<script type="text/ecmascript"> <![CDATA[
function calculate(evt) {
bb=document.getElementById("rect").getBBox();
rwi=1;
rwp=bb.width;
swp=screen.width;
swi=swp/rwp*rwi;
rhi=1;
rhp=bb.height;
shp=screen.height;
shi=shp/rhp*rhi;
sdi=Math.sqrt(swi*swi+shi*shi);
blah="rect\n";
blah+=rwi+"x"+rhi+"(inch,given)\n";
blah+=rwp+"x"+rhp+"(pixels,queried)\n";
blah+="\n";
blah+="screen\n";
blah+=swp+"x"+shp+"(pixels,queried)\n";
blah+=swi+"x"+shi+"(inch,calculated)\n";
blah+="diagonal= "+sdi+" inch\n";
blah+="(ERROR: in my case a strong exaggeration)";
blah+="\n";
blah+="\n";
blah+="Without this ERROR i could of course calculate the viewBox i
need in combination with width='100%' and height='100%' in order to
scale any drawing to the prefered physical size\n";
blah+="\n";
blah+="This ERROR of course also means it's very unprecise/unwise to
use units (other than pixels) in general";
alert(blah);
}
]]> </script>
<rect id="rect" width="1in" height="1in"/>
</svg>
Received on Monday, 20 April 2009 00:12:52 UTC