mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-20 22:39:50 -05:00
Inline applyTransform() code, since it's so little code now.
This commit is contained in:
parent
a677e905bf
commit
a690aa48c1
1 changed files with 8 additions and 17 deletions
|
@ -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],
|
||||
|
|
Loading…
Reference in a new issue