mirror of
https://github.com/scratchfoundation/scratch-paint.git
synced 2024-12-23 14:02:50 -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',
|
'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) {
|
||||||
|
|
Loading…
Reference in a new issue