2013-07-23 2 views

답변

13

사실 찾기가 어려웠습니다. SVGElement의 메소드를 검색하면 SVGElement에 메소드가 없다는 페이지가 표시됩니다. 이 방법의 톤이 사실 않습니다,하지만 그들은 상속 : 당신은 당신이 요소입니다 당신이 SVGPoint를 변환하는 getCTM 또는 getScreenCTM의 결과를 사용하여 배울 수 있습니다 원하는에 따라

http://www.w3.org/TR/SVG/types.html#InterfaceSVGLocatable

:

root = document.getElementById('root') 
rec = document.getElementById('rec') 
point = root.createSVGPoint() 
# This is the top-left relative to the SVG element 
ctm = rec.getCTM() 
console.log point.matrixTransform(ctm) 
# This is the top-left relative to the document 
ctm = rec.getScreenCTM() 
console.log point.matrixTransform(ctm) 

http://jsfiddle.net/kitsu_eb/ZXVAX/3/

+0

니스를 참조하십시오! matrixTransform에 대해서는 몰랐습니다. javascript는 당신의 바이올린에서 비어 있습니다. 업데이트 했습니까? 이것을 시험해보고 있습니다. –

+1

작동! 감사. Working Fiddle : http://jsfiddle.net/T8aZP/14/ –

+0

thedeeno의 링크 된 바이올린을 시도했지만 기대했던 결과를 얻지 못했습니다. 다음은 getBBox를 사용하여 점의 초기 좌표를 설정하는 포크입니다. http://jsfiddle.net/kitsu_eb/T8aZP/15/ –

관련 문제