| 1234567891011121314151617181920212223242526272829 |
- // 探查中央一张图区域:底图、点位/设备标记是位图还是矢量
- import { readFileSync } from 'node:fs'
- const j = JSON.parse(readFileSync('.scratch/lanhu-cockpit-asset-replacement/research/raw/desktop-06.json', 'utf8'))
- function find(node, want, path = '') {
- const p = path ? `${path}/${node.name}` : node.name
- if (node.name === want) return { node, path: p }
- for (const ch of node.layers || []) {
- const r = find(ch, want, p)
- if (r) return r
- }
- return null
- }
- function dump(node, depth = 0) {
- const pad = ' '.repeat(depth)
- const paths = node.paths || []
- const fills = (node.style?.fills || []).map((f) => (f.type === 'image' ? 'image' : f.type)).join('+')
- const extra = fills.includes('image') ? ' [BITMAP]' : ''
- 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}`)
- for (const ch of (node.layers || []).slice(0, 18)) dump(ch, depth + 1)
- }
- const map = find(j.artboard, 'CentralMap')
- if (map) {
- console.log('=== CentralMap:', map.path)
- dump(map.node)
- }
|