export type NativeUVBounds = [number,number,number,number]; // min U, min V, max U, max V export interface NativeUVCustomRegion { enabled:boolean; bounds:NativeUVBounds } export function parseNativeUVBounds(value:unknown, requireArea=true):NativeUVBounds { if(!Array.isArray(value)||value.length!==4||value.some(n=>typeof n!=='number'||!Number.isFinite(n)||!Number.isFinite(Math.fround(n))))throw new Error('UV 区域需要四个有限坐标'); const bounds=value.map(Math.fround) as NativeUVBounds; if(requireArea&&(!(bounds[2]>bounds[0])||!(bounds[3]>bounds[1])||!Number.isFinite(Math.fround(bounds[2]-bounds[0]))||!Number.isFinite(Math.fround(bounds[3]-bounds[1]))))throw new Error('UV 区域的最大坐标必须大于最小坐标,且范围不能溢出'); return bounds; }