UNPKG

@cs-open/react-fabric

Version:
1 lines 1.85 kB
{"version":3,"file":"position.mjs","sources":["../../../src/utils/position.ts"],"sourcesContent":["/**\n * 判断sunPosition是否在parentPosition内\n * @param parentPosition 父级位置 (格式: x1,y1,x2,y2,x3,y3,x4,y4)\n * @param sunPosition 子级位置 (格式: x1,y1,x2,y2,x3,y3,x4,y4)\n * @returns boolean\n */\nconst includes = (parentPosition: string | number[], sunPosition: string | number[]) => {\n if (!parentPosition || !sunPosition) return false\n\n // 转换为数组\n const parentPoints = Array.isArray(parentPosition) ? parentPosition : parentPosition.split(',').map(Number)\n const sunPoints = Array.isArray(sunPosition) ? sunPosition : sunPosition.split(',').map(Number)\n\n // 验证坐标点数量\n if (parentPoints.length !== 8 || sunPoints.length !== 8) return false\n\n // 转换为数字并解构\n const [x1, y1, x2, y2, x3, y3, x4, y4] = parentPoints.map(Number)\n const [x1s, y1s, x2s, y2s, x3s, y3s, x4s, y4s] = sunPoints.map(Number)\n\n return x1s >= x1 && y1s >= y1 && x2s <= x2 && y2s >= y2 && x3s <= x3 && y3s <= y3 && x4s >= x4 && y4s <= y4\n}\n\nexport default includes\n"],"names":["includes","parentPosition","sunPosition","parentPoints","sunPoints","x1","y1","x2","y2","x3","y3","x4","y4","x1s","y1s","x2s","y2s","x3s","y3s","x4s","y4s"],"mappings":"aAMMA,MAAAA,EAAW,CAACC,EAAmCC,IAAmC,CACtF,GAAI,CAACD,GAAkB,CAACC,EAAa,MAAO,GAG5C,MAAMC,EAAe,MAAM,QAAQF,CAAc,EAAIA,EAAiBA,EAAe,MAAM,GAAG,EAAE,IAAI,MAAM,EACpGG,EAAY,MAAM,QAAQF,CAAW,EAAIA,EAAcA,EAAY,MAAM,GAAG,EAAE,IAAI,MAAM,EAG9F,GAAIC,EAAa,SAAW,GAAKC,EAAU,SAAW,EAAG,MAAO,GAGhE,KAAM,CAACC,EAAIC,EAAIC,EAAIC,EAAIC,EAAIC,EAAIC,EAAIC,CAAE,EAAIT,EAAa,IAAI,MAAM,EAC1D,CAACU,EAAKC,EAAKC,EAAKC,EAAKC,EAAKC,EAAKC,EAAKC,CAAG,EAAIhB,EAAU,IAAI,MAAM,EAErE,OAAOS,GAAOR,GAAMS,GAAOR,GAAMS,GAAOR,GAAMS,GAAOR,GAAMS,GAAOR,GAAMS,GAAOR,GAAMS,GAAOR,GAAMS,GAAOR,CAC3G"}