mirror of
https://github.com/scratchfoundation/scratch-paint.git
synced 2024-12-23 05:52:42 -05:00
Merge pull request #232 from fsih/ensureClockwise
Convert SVGs to clockwise when importing
This commit is contained in:
commit
c58620e842
1 changed files with 13 additions and 1 deletions
|
@ -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) {
|
||||
|
|
Loading…
Reference in a new issue