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',
'importSvg',
'handleKeyDown',
'handleWheel'
'handleWheel',
'_ensureClockwise'
]);
}
componentDidMount () {
@ -125,6 +126,8 @@ class PaperCanvas extends React.Component {
item = item.reduce();
}
paperCanvas._ensureClockwise(item);
if (typeof rotationCenterX !== 'undefined' && typeof rotationCenterY !== 'undefined') {
item.position =
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) {
this.canvas = canvas;
if (this.props.canvasRef) {