Inline applyTransform() code, since it's so little code now.

This commit is contained in:
Jürg Lehni 2012-12-15 02:22:25 -08:00
parent a677e905bf
commit a690aa48c1

View file

@ -401,7 +401,14 @@ new function() {
// http://www.w3.org/TR/SVG/types.html#DataTypeTransformList
case 'gradientTransform':
case 'transform':
applyTransform(item, svg, name);
var transforms = svg[name].baseVal,
matrix = new Matrix();
for (var i = 0, l = transforms.numberOfItems; i < l; i++) {
var mx = transforms.getItem(i).matrix;
matrix.concatenate(
new Matrix(mx.a, mx.b, mx.c, mx.d, mx.e, mx.f));
}
item.transform(matrix);
break;
// http://www.w3.org/TR/SVG/pservers.html#StopOpacityProperty
case 'stop-opacity':
@ -501,22 +508,6 @@ new function() {
}
}
/**
* Applies the transformations specified on the SVG node to a Paper.js item
*
* @param {SVGSVGElement} svg an SVG node
* @param {Item} item a Paper.js item
*/
function applyTransform(item, svg, name) {
var transforms = svg[name].baseVal,
matrix = new Matrix();
for (var i = 0, l = transforms.numberOfItems; i < l; i++) {
var mx = transforms.getItem(i).matrix;
matrix.concatenate(new Matrix(mx.a, mx.b, mx.c, mx.d, mx.e, mx.f));
}
item.transform(matrix);
}
function importSvg(svg) {
var type = svg.nodeName.toLowerCase(),
importer = importers[type],