mohan-bee/stm32-midi-keys
Clips rectangular ground-region geometry to fit within the board’s scaled rounded-edge outline using polygon intersection.
- Version
- 1.0.2
- License
- unset
- Stars
- 0
scripts/preview.ts
import { readFileSync, writeFileSync, mkdirSync, existsSync } from 'node:fs'
import { convertCircuitJsonToPcbSvg } from 'circuit-to-svg'
import sharp from 'sharp'
const reference=JSON.parse(readFileSync('board.circuit.json','utf8'))
const silk=JSON.parse(readFileSync('silkscreen.json','utf8'))
reference.push(...silk)
mkdirSync('previews',{recursive:true})
writeFileSync('reference.circuit.json',JSON.stringify(reference,null,2))
for(const [name,data] of [['reference',reference],...(existsSync('dist/index/circuit.json') ? [['native',JSON.parse(readFileSync('dist/index/circuit.json','utf8'))]]:[])] as const) {
for(const layer of ['top','bottom'] as const) {
const svg=convertCircuitJsonToPcbSvg(data,{width:1700,height:600,layer,showFabricationNotes:false,showCourtyards:false,showSolderMask:true,shouldDrawErrors:false,showErrorsInTextOverlay:false,showPcbNotes:false})
writeFileSync(`previews/${name}-${layer}.svg`,svg)
await sharp(Buffer.from(svg)).png().toFile(`previews/${name}-${layer}.png`)
}
}