hrithik18k/open-ring-flex

A flexible wearable PCB integrating inductive battery charging, BLE control with SPI flash and 32 MHz crystal, SAM L10 capacitive touch/wear sensing, haptic MOSFET drive with a large capacitor bank, RF antenna matching, and SWD programming/test connectors.

Version
1.0.4
License
CC-BY-NC-SA-4.0
Stars
0

scripts/render-schematic.ts

import { readFileSync, writeFileSync, mkdirSync } from "node:fs"
import {
  convertCircuitJsonToSchematicSvg,
  convertCircuitJsonToStackedSchematicSheetsSvg,
} from "circuit-to-svg"
import { Resvg } from "@resvg/resvg-js"

// Render the native sheet records without modifying the circuit JSON.
const circuit = JSON.parse(readFileSync("dist/index/circuit.json", "utf8"))
const output = "dist/index/schematic-sheets"
mkdirSync(output, { recursive: true })
for (const sheet of circuit.filter((el: any) => el.type === "schematic_sheet")) {
  const svg = convertCircuitJsonToSchematicSvg(circuit, {
    schematicSheetId: sheet.schematic_sheet_id,
    width: 1800,
    height: 1200,
  })
  const filename = `${output}/${sheet.name}`
  writeFileSync(`${filename}.svg`, svg)
  writeFileSync(`${filename}.png`, new Resvg(svg).render().asPng())
}
writeFileSync(`${output}/all-sheets.svg`, convertCircuitJsonToStackedSchematicSheetsSvg(circuit, {
  width: 1600,
  height: 1000,
}))
console.log(`Rendered ${output}`)