mirror of
https://github.com/Sevichecc/Urara-Blog.git
synced 2025-05-05 14:09:30 +08:00
39 lines
860 B
Text
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 };
|