mirror of
https://github.com/scratchfoundation/scratch-paint.git
synced 2025-01-25 05:39:52 -05:00
Merge pull request #1079 from fsih/addRotationCenter
Add default rotation center for bitmap images
This commit is contained in:
commit
0e3b79e143
2 changed files with 9 additions and 2 deletions
|
@ -96,9 +96,9 @@ SVGs of up to size 480 x 360 will fit into the view window of the paint editor,
|
||||||
|
|
||||||
`imageFormat`: 'svg', 'png', or 'jpg'. Other formats are currently not supported.
|
`imageFormat`: 'svg', 'png', or 'jpg'. Other formats are currently not supported.
|
||||||
|
|
||||||
`rotationCenterX`: x coordinate relative to the top left corner of the sprite of the point that should be centered.
|
`rotationCenterX`: x coordinate relative to the top left corner of the sprite of the point that should be centered. If left undefined, image will be horizontally centered.
|
||||||
|
|
||||||
`rotationCenterY`: y coordinate relative to the top left corner of the sprite of the point that should be centered.
|
`rotationCenterY`: y coordinate relative to the top left corner of the sprite of the point that should be centered. If left undefined, image will be vertcally centered.
|
||||||
|
|
||||||
`rtl`: True if the paint editor should be laid out right to left (meant for right to left languages)
|
`rtl`: True if the paint editor should be laid out right to left (meant for right to left languages)
|
||||||
|
|
||||||
|
|
|
@ -148,6 +148,13 @@ class PaperCanvas extends React.Component {
|
||||||
if (!this.queuedImageToLoad) return;
|
if (!this.queuedImageToLoad) return;
|
||||||
this.queuedImageToLoad = null;
|
this.queuedImageToLoad = null;
|
||||||
|
|
||||||
|
if (typeof rotationCenterX === 'undefined') {
|
||||||
|
rotationCenterX = imgElement.width / 2;
|
||||||
|
}
|
||||||
|
if (typeof rotationCenterY === 'undefined') {
|
||||||
|
rotationCenterY = imgElement.height / 2;
|
||||||
|
}
|
||||||
|
|
||||||
getRaster().drawImage(
|
getRaster().drawImage(
|
||||||
imgElement,
|
imgElement,
|
||||||
(ART_BOARD_WIDTH / 2) - rotationCenterX,
|
(ART_BOARD_WIDTH / 2) - rotationCenterX,
|
||||||
|
|
Loading…
Reference in a new issue