Urara-Blog/node_modules/.pnpm-store/v3/files/b6/f27cdf8dc581725d882f57dc3927888ae135c59e2d6b25439a0b82d1b6aa8b432c57ff4930b18da0411339e2e94108436cb4706f7545cfc7567ba5e6c59083
2022-08-14 01:14:53 +08:00

39 lines
860 B
Text

const separator = /[\s,]+/;
function flipFromString(custom, flip) {
flip.split(separator).forEach((str) => {
const value = str.trim();
switch (value) {
case "horizontal":
custom.hFlip = true;
break;
case "vertical":
custom.vFlip = true;
break;
}
});
}
function alignmentFromString(custom, align) {
align.split(separator).forEach((str) => {
const value = str.trim();
switch (value) {
case "left":
case "center":
case "right":
custom.hAlign = value;
break;
case "top":
case "middle":
case "bottom":
custom.vAlign = value;
break;
case "slice":
case "crop":
custom.slice = true;
break;
case "meet":
custom.slice = false;
}
});
}
export { alignmentFromString, flipFromString };