The core logic used to build Circuit JSON from tscircuit React elements.
tscircuit · Online Playground · Development Guide · Core Benchmarks · Contributor Getting Started Video
You can use core to create Circuit JSON, which can then
be converted into Gerbers, viewed online, and much more.
import{Circuit}from"@tscircuit/core"constcircuit=newCircuit()circuit.add(<boardwidth="10mm"height="10mm"><resistorname="R1"resistance="10k"footprint="0402"/><ledname="L1"footprint="0402"/><tracefrom="R1.pin1"to="net.VCC"/><tracefrom="R1.pin2"to="L1.pos"/><tracefrom="L1.neg"to="net.GND"/></board>)circuit.getCircuitJson()import{Board,Resistor,Led,Trace,Circuit}from"@tscircuit/core"constcircuit=newCircuit()constboard=newBoard({width: "10mm",height: "10mm",})circuit.add(board)constR1=newResistor({resistance: "10k",footprint: "0402"})constL1=newLed({footprint: "0402"})board.add(R1)board.add(L1)consttrace=newTrace({width: "0.2mm"})trace.connect(R1.output,L1.anode)board.add(trace)circuit.getCircuitJson()// [{ type: "board", ...}, { type: "resistor", ...}, ...]