probe-map.mjs 1.1 KB

1234567891011121314151617181920212223242526272829
  1. // 探查中央一张图区域:底图、点位/设备标记是位图还是矢量
  2. import { readFileSync } from 'node:fs'
  3. const j = JSON.parse(readFileSync('.scratch/lanhu-cockpit-asset-replacement/research/raw/desktop-06.json', 'utf8'))
  4. function find(node, want, path = '') {
  5. const p = path ? `${path}/${node.name}` : node.name
  6. if (node.name === want) return { node, path: p }
  7. for (const ch of node.layers || []) {
  8. const r = find(ch, want, p)
  9. if (r) return r
  10. }
  11. return null
  12. }
  13. function dump(node, depth = 0) {
  14. const pad = ' '.repeat(depth)
  15. const paths = node.paths || []
  16. const fills = (node.style?.fills || []).map((f) => (f.type === 'image' ? 'image' : f.type)).join('+')
  17. const extra = fills.includes('image') ? ' [BITMAP]' : ''
  18. console.log(`${pad}${node.type}:${node.name} ${Math.round(node.frame?.width ?? 0)}x${Math.round(node.frame?.height ?? 0)} paths=${paths.length} fills=${fills}${extra}`)
  19. for (const ch of (node.layers || []).slice(0, 18)) dump(ch, depth + 1)
  20. }
  21. const map = find(j.artboard, 'CentralMap')
  22. if (map) {
  23. console.log('=== CentralMap:', map.path)
  24. dump(map.node)
  25. }