- From: Kevin Lindsey <kevin@kevlindev.com>
- Date: Wed, 27 Nov 2002 10:42:49 -0600
- To: "Sigurd Lerstad" <sigler@bredband.no>, <www-svg@w3.org>
Sigurd, > My question is if the currentTranslate should be performed after or before > the currentScale, that is: > > should the image be scaled, and then translated or should the image be > translated, and then scaled (the scaling would also affect the translation) The short answer is the latter. <svg onload="init(evt)"> <script type="text/ecmascript"> function init(evt) { if ( window.svgDocument == null ) svgDocument = evt.target.ownerDocument; var svgRoot = svgDocument.rootElement; svgRoot.currentScale = 2; svgRoot.currentTranslate.x = 10; svgRoot.currentTranslate.y = 10; } </script> <rect width="10" height="10" fill="blue"/> </svg> should look the same as: <svg> <rect width="10" height="10" fill="blue" transform="translate(10,10) scale(2)"/> </svg> the rect's new dimensions could be calculated in a manner similar to this pseudo-code: var scale = 2; var translate = new Point(10,10); rect.x = rect.x * scale + translate.x; rect.y = rect.y * scale + translate.y; rect.width *= scale; rect.height *= scale; Kevin KevLinDev - http://www.kevlindev.com
Received on Saturday, 30 November 2002 21:26:58 UTC