Move getRotationAngle() into svgutils.js

git-svn-id: http://svg-edit.googlecode.com/svn/trunk@1841 eee81c28-f429-11dd-99c0-75d572ba1ddd
This commit is contained in:
Jeff Schiller
2010-11-05 15:59:30 +00:00
parent b104277fa1
commit 66fd00d10b
2 changed files with 37 additions and 45 deletions

View File

@@ -10,6 +10,7 @@
// Dependencies:
// 1) jQuery
// 2) browsersupport.js
// 3) svgtransformlist.js
(function() {
@@ -462,5 +463,28 @@ svgedit.Utilities.getBBox = function(elem) {
return ret;
};
// Function: svgedit.Utilities.getRotationAngle
// Get the rotation angle of the given/selected DOM element
//
// Parameters:
// elem - Optional DOM element to get the angle for
// to_rad - Boolean that when true returns the value in radians rather than degrees
//
// Returns:
// Float with the angle in degrees or radians
svgedit.Utilities.getRotationAngle = function(elem, to_rad) {
var selected = elem || selectedElements[0];
// find the rotation transform (if any) and set it
var tlist = svgedit.transformlist.getTransformList(selected);
if(!tlist) return 0; // <svg> elements have no tlist
var N = tlist.numberOfItems;
for (var i = 0; i < N; ++i) {
var xform = tlist.getItem(i);
if (xform.type == 4) {
return to_rad ? xform.angle * Math.PI / 180.0 : xform.angle;
}
}
return 0.0;
};
})();