fix contain dim change

pull/6086/head
Ryan Di 3 weeks ago
parent ec39094933
commit 913921631b

@ -384,8 +384,6 @@ const configExportDimension = async ({
? "contain" ? "contain"
: "none"); : "none");
const containPadding = cfg.fit === "contain";
cfg.padding = cfg.padding ?? 0; cfg.padding = cfg.padding ?? 0;
cfg.scale = cfg.scale ?? 1; cfg.scale = cfg.scale ?? 1;
@ -502,25 +500,13 @@ const configExportDimension = async ({
width = ret.width; width = ret.width;
height = ret.height; height = ret.height;
cfg.scale = ret.scale ?? cfg.scale; cfg.scale = ret.scale ?? cfg.scale;
} else if (containPadding) { } else if (cfg.fit === "contain") {
// const whRatio = width / height;
// console.log("cfg.padding", cfg.padding);
// const wRatio = (width - cfg.padding * 2) / width;
// const hRatio = (height - cfg.padding * 2) / height;
// exportScale = Math.min(wRatio, hRatio);
// width -= cfg.padding * 2;
// height -= (cfg.padding * 2) / whRatio;
const whRatio = width / height;
width -= cfg.padding * 2; width -= cfg.padding * 2;
height -= (cfg.padding * 2) / whRatio; height -= cfg.padding * 2;
const wRatio = width / origWidth; const wRatio = width / origWidth;
const hRatio = height / origHeight; const hRatio = height / origHeight;
// scale the orig canvas to fit in the target frame // scale the orig canvas to fit in the target region
exportScale = Math.min(wRatio, hRatio); exportScale = Math.min(wRatio, hRatio);
} }

Loading…
Cancel
Save