You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
16 lines
552 B
16 lines
552 B
import { isBetween } from './math';
|
|
/**
|
|
* <zh/> 解析原点(锚点)
|
|
*
|
|
* <en/> Parse the origin/anchor
|
|
* @param anchor - <zh/> 原点 | <en/> Anchor
|
|
* @returns <zh/> 标准原点 | <en/> Standard anchor
|
|
*/
|
|
export function parseAnchor(anchor) {
|
|
const parsedAnchor = (typeof anchor === 'string' ? anchor.split(' ').map((v) => parseFloat(v)) : anchor.slice(0, 2));
|
|
if (!isBetween(parsedAnchor[0], 0, 1) || !isBetween(parsedAnchor[1], 0, 1)) {
|
|
return [0.5, 0.5];
|
|
}
|
|
return parsedAnchor;
|
|
}
|
|
//# sourceMappingURL=anchor.js.map
|