Skip to content

Getting Started

Installation

bash
npm install velo-circuit

Or import directly from the source:

ts
import { createEditor } from './src/core/index.ts'

Minimal Example

ts
import { createEditor } from 'velo-circuit'

const editor = createEditor()

editor.mount(document.getElementById('canvas'), {
  initialDsl: 'R0-p(R1,C1)-Wo2',
  width: 800,
  height: 600,
})

// React to circuit changes
editor.on('ast-changed', () => {
  const dsl = editor.getValue()
  console.log(dsl) // e.g. "R0-p(R1,C1)-Wo2"
})

// Listen for errors
editor.on('error', (e) => {
  console.error('Parse error:', e.payload)
})

// Update circuit programmatically
editor.setValue('R0-C1-L2')

// Undo / redo
editor.undo()
editor.redo()

// Cleanup
editor.destroy()

What is a Circuit DSL?

Circuits are described with the Boukamp notation, used in electrochemical impedance spectroscopy (EIS).

SymbolMeaningExample
-Series connectionR0-C1
p(a,b)Parallel connectionp(R0,C1)
RResistorR0
CCapacitorC1
LInductorL2
QCPEQ0
W, Ws, WoWarburgWo3

Next Steps