Skip to content

Commit

Permalink
[edit] fix export frame position and padWhiteSpace
Browse files Browse the repository at this point in the history
  • Loading branch information
spd789562 committed Oct 15, 2024
1 parent 86e2dc6 commit ce20f65
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
4 changes: 3 additions & 1 deletion src/components/tab/ActionTab/ExportFrameButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ export const ExportFrameButton = (props: ExportAnimateButtonProps) => {
try {
const files: [Blob, string][] = [];
for await (const characterRef of props.characterRefs) {
const frameData = await characterRef.makeCharacterFrames(padWhiteSpace);
const frameData = await characterRef.makeCharacterFrames({
padWhiteSpace,
});
files.push(
...(await getCharacterFrameBlobs(frameData, characterRef.character, {
includeMoveJson: padWhiteSpace === false,
Expand Down
6 changes: 3 additions & 3 deletions src/renderer/character/characterToCanvasFrames.ts
Original file line number Diff line number Diff line change
Expand Up @@ -210,14 +210,14 @@ async function makeFrames(
y: -bound.top,
};
const exportFrames = unprocessedFrames.map((frame) => {
const top = basePos.y + frame.top;
const left = basePos.x + frame.left;

const canvas = document.createElement('canvas');
const ctx = canvas.getContext('2d') as CanvasRenderingContext2D;
const needPad =
options.padWhiteSpace || options.padWhiteSpace === undefined;

const top = needPad ? basePos.y + frame.top : -frame.top;
const left = needPad ? basePos.x + frame.left : -frame.left;

if (needPad) {
canvas.width = maxWidth;
canvas.height = maxHeight;
Expand Down

0 comments on commit ce20f65

Please sign in to comment.