0hmX/mt41k512m8da-107-it-p-fanout

This code defines the physical footprint, routing, and layout configuration for a DDR3 memory module using surface-mount pads, vias, and copper traces on a printed circuit board (PCB).

Version
0.2.3
License
unset
Stars
0

scripts/render.ts

import { convertCircuitJsonToPcbSvg } from 'circuit-to-svg'
import { createRequire } from 'node:module'
import { LAYOUT_PROFILES } from '../src/profiles'
import { mkdirSync, copyFileSync } from 'node:fs'
const require=createRequire(import.meta.url)
const { Resvg }=require('@resvg/resvg-js')
mkdirSync('previews',{recursive:true})
for(const profile of LAYOUT_PROFILES){
 const svg=await Bun.file(`dist/${profile}/pcb.svg`).text()
 await Bun.write(`previews/${profile}.svg`,svg)
 const png=new Resvg(svg,{fitTo:{mode:'width',value:1100}}).render().asPng()
 await Bun.write(`previews/${profile}.png`,png)
 const circuit=await Bun.file(`dist/${profile}/circuit.json`).json()
 for(const layer of ["top","inner1"] as const){
  const layerSvg=convertCircuitJsonToPcbSvg(circuit,{layer,width:1100,height:850})
  await Bun.write(`previews/${profile}-${layer}.png`,new Resvg(layerSvg).render().asPng())
 }
 const pairDetail=convertCircuitJsonToPcbSvg(circuit,{layer:"inner1",width:1100,height:600,viewport:{minX:-5.2,maxX:-1,minY:1.8,maxY:4.2}})
 await Bun.write(`previews/${profile}-dqs-detail.png`,new Resvg(pairDetail).render().asPng())
 const panels=["top","inner1","inner2","bottom"].map((layer,i)=>{
  const panel=convertCircuitJsonToPcbSvg(circuit,{layer:layer as any,width:550,height:450})
  const x=(i%2)*550,y=Math.floor(i/2)*490
  return `<text x="${x+275}" y="${y+26}" fill="white" font-family="sans-serif" font-size="20" text-anchor="middle">${layer}</text>`+panel.replace('<svg ',`<svg x="${x}" y="${y+40}" `)
 }).join('')
 const layersSvg=`<svg xmlns="http://www.w3.org/2000/svg" width="1100" height="980"><rect width="1100" height="980" fill="#000"/>${panels}</svg>`
 await Bun.write(`previews/${profile}-layers.svg`,layersSvg)
 await Bun.write(`previews/${profile}-layers.png`,new Resvg(layersSvg).render().asPng())
 copyFileSync(`dist/${profile}/circuit.json`,`src/generated/${profile}.circuit.json`)
}