From 8b03c5af547f66a86d9978ea5aff54c93a768164 Mon Sep 17 00:00:00 2001 From: DD Liu Date: Sun, 24 May 2020 22:18:55 -0400 Subject: [PATCH 1/2] Set the rotation center of bitmaps with no rotation center to the center of the stage --- src/containers/paper-canvas.jsx | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/containers/paper-canvas.jsx b/src/containers/paper-canvas.jsx index 2b2ce63a..256f864b 100644 --- a/src/containers/paper-canvas.jsx +++ b/src/containers/paper-canvas.jsx @@ -148,6 +148,13 @@ class PaperCanvas extends React.Component { if (!this.queuedImageToLoad) return; this.queuedImageToLoad = null; + if (typeof rotationCenterX === 'undefined') { + rotationCenterX = imgElement.width / 2; + } + if (typeof rotationCenterY === 'undefined') { + rotationCenterY = imgElement.height / 2; + } + getRaster().drawImage( imgElement, (ART_BOARD_WIDTH / 2) - rotationCenterX, From eebdc3799156dada4fab3c1c7ae8cc8342bfd56c Mon Sep 17 00:00:00 2001 From: DD Liu Date: Sun, 24 May 2020 22:26:43 -0400 Subject: [PATCH 2/2] Update readme to explain what rotation center does when missing --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index b27c400b..98f2e99d 100644 --- a/README.md +++ b/README.md @@ -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. -`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)