Merge pull request #232 from fsih/ensureClockwise

Convert SVGs to clockwise when importing
This commit is contained in:
DD Liu 2017-12-19 16:39:59 -05:00 committed by GitHub
commit c58620e842
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -26,7 +26,8 @@ class PaperCanvas extends React.Component {
'setCanvas', 'setCanvas',
'importSvg', 'importSvg',
'handleKeyDown', 'handleKeyDown',
'handleWheel' 'handleWheel',
'_ensureClockwise'
]); ]);
} }
componentDidMount () { componentDidMount () {
@ -125,6 +126,8 @@ class PaperCanvas extends React.Component {
item = item.reduce(); item = item.reduce();
} }
paperCanvas._ensureClockwise(item);
if (typeof rotationCenterX !== 'undefined' && typeof rotationCenterY !== 'undefined') { if (typeof rotationCenterX !== 'undefined' && typeof rotationCenterY !== 'undefined') {
item.position = item.position =
paper.project.view.center paper.project.view.center
@ -143,6 +146,15 @@ class PaperCanvas extends React.Component {
} }
}); });
} }
_ensureClockwise (item) {
if (item instanceof paper.Group) {
for (const child of item.children) {
this._ensureClockwise(child);
}
} else if (item instanceof paper.PathItem) {
item.clockwise = true;
}
}
setCanvas (canvas) { setCanvas (canvas) {
this.canvas = canvas; this.canvas = canvas;
if (this.props.canvasRef) { if (this.props.canvasRef) {