Add applyMatrix option to importSVG()

This commit is contained in:
Jürg Lehni 2015-06-16 17:52:34 +02:00
parent 036ba45326
commit 4fde7ab37d
4 changed files with 9 additions and 4 deletions

View file

@ -5,7 +5,9 @@
<title>Arcs Testing</title> <title>Arcs Testing</title>
<script type="text/javascript" src="../../dist/paper-full.js"></script> <script type="text/javascript" src="../../dist/paper-full.js"></script>
<script type="text/paperscript" canvas="canvas"> <script type="text/paperscript" canvas="canvas">
project.importSVG(document.getElementById('svg')); project.importSVG(document.getElementById('svg'), {
applyMatrix: false
});
</script> </script>
</head> </head>
<body> <body>

View file

@ -2101,6 +2101,9 @@ var Item = Base.extend(Emitter, /** @lends Item# */{
* *
* @option [options.expandShapes=false] {Boolean} whether imported shape * @option [options.expandShapes=false] {Boolean} whether imported shape
* items should be expanded to path items * items should be expanded to path items
* @option [options.applyMatrix={@link PaperScope#settings}.applyMatrix]
* {Boolean} whether imported items should have their transformation
* matrices applied to their contents or not
* *
* @param {SVGElement|String} svg the SVG content to import * @param {SVGElement|String} svg the SVG content to import
* @param {Object} [options] the import options * @param {Object} [options] the import options

View file

@ -661,8 +661,8 @@ var Project = PaperScopeItem.extend(/** @lends Project# */{
* @option [options.expandShapes=false] {Boolean} whether imported shape * @option [options.expandShapes=false] {Boolean} whether imported shape
* items should be expanded to path items * items should be expanded to path items
* @option [options.applyMatrix={@link PaperScope#settings}.applyMatrix] * @option [options.applyMatrix={@link PaperScope#settings}.applyMatrix]
* {Boolean} whether imported items should have * {Boolean} whether imported items should have their transformation
* their transformation matrices applied to their contents or not * matrices applied to their contents or not
* *
* @param {SVGElement|String} svg the SVG content to import * @param {SVGElement|String} svg the SVG content to import
* @param {Object} [options] the import options * @param {Object} [options] the import options

View file

@ -628,7 +628,7 @@ new function() {
definitions = {}; definitions = {};
// Now if settings.applyMatrix was set, apply recursively and set // Now if settings.applyMatrix was set, apply recursively and set
// #applyMatrix = true on the item and all children. // #applyMatrix = true on the item and all children.
if (applyMatrix && item) if (item && Base.pick(options.applyMatrix, applyMatrix))
item.matrix.apply(true, true); item.matrix.apply(true, true);
} }
return item; return item;