krishnax12/t113-minimal-linux
Allwinner T113-S3 dual-Cortex-A7 SoC with integrated 128MB DDR3, multi-rail decoupling, 24MHz and 32.768kHz oscillators, filtering, and exposed test points.
- Version
- 0.1.1
- License
- unset
- Stars
- 0
scripts/render-previews.mjs
import fs from "node:fs/promises"
import path from "node:path"
import {
convertCircuitJsonToSchematicSvg,
convertCircuitJsonToPcbSvg,
} from "circuit-to-svg"
import { Resvg } from "@resvg/resvg-js"
const sourcePath = process.argv[2] ?? "routed.circuit.json"
const circuitJson = JSON.parse(await fs.readFile(sourcePath, "utf8"))
await fs.mkdir("dist/schematics", { recursive: true })
await fs.mkdir("dist/previews", { recursive: true })
for (const sheet of circuitJson.filter(
(element) => element.type === "schematic_sheet",
)) {
const fileName = sheet.name.toLowerCase().replaceAll(" ", "-")
const svg = convertCircuitJsonToSchematicSvg(circuitJson, {
schematicSheetId: sheet.schematic_sheet_id,
})
await fs.writeFile(`dist/schematics/${fileName}.svg`, svg)
await fs.writeFile(
`dist/previews/${fileName}.png`,
new Resvg(svg, { fitTo: { mode: "width", value: 2000 } }).render().asPng(),
)
}
for (const layer of ["top", "bottom", "inner1", "inner2"]) {
const svg = convertCircuitJsonToPcbSvg(circuitJson, { layer })
await fs.writeFile(`dist/previews/pcb-${layer}.svg`, svg)
await fs.writeFile(
`dist/previews/pcb-${layer}.png`,
new Resvg(svg, { fitTo: { mode: "width", value: 1600 } }).render().asPng(),
)
}