seveibar/f1c1990s-dev-board
This code manages the entire PCB assembly process for a computer hardware module, including component placement, schematic integration, automated routing, copper pouring, and design rule checks, focused on a four-layer carrier board with integrated support components and connectors.
- Version
- 1.8.0
- License
- unset
- Stars
- 0
modules/f1c100s/scripts/preview-schematic.tsx
import { Circuit } from "tscircuit";
import { ProfilePreview } from "../src/ProfilePreview";
import { convertCircuitJsonToSchematicSvg } from "circuit-to-svg";
import { Resvg } from "@resvg/resvg-js";
const c = new Circuit();
c.add(<ProfilePreview layoutProfile="lcd_top_storage_right" />);
await c.renderUntilSettled();
const json = c.getCircuitJson();
for (const [i, name] of ["interfaces", "power"].entries()) {
const svg = convertCircuitJsonToSchematicSvg(json, {
width: 1800,
height: 1273,
schematicSheetIndex: i,
});
await Bun.write(`previews/schematic-${name}.svg`, svg);
await Bun.write(
`previews/schematic-${name}.png`,
new Resvg(svg).render().asPng(),
);
}
if (process.env.SCHEMATIC_DEBUG_JSON)
await Bun.write(process.env.SCHEMATIC_DEBUG_JSON, JSON.stringify(json));
console.log(
JSON.stringify(
{
errors: json.filter((e) => e.type.endsWith("_error")),
outsideSheet: json.filter(
(e) => e.type === "schematic_element_outside_sheet_warning",
),
sheets: json.filter((e) => e.type === "schematic_sheet"),
components: json.filter((e) => e.type === "schematic_component").length,
},
null,
2,
),
);
await Bun.write(
"previews/schematic.svg",
Bun.file("previews/schematic-interfaces.svg"),
);
await Bun.write(
"previews/schematic.png",
Bun.file("previews/schematic-interfaces.png"),
);