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'

Three integration paths

PathAPIDoc
Full editorcreateEditor() or adapter preset: 'extended'Below
Embed canvas onlypreset: 'lite' or litePlugins()Editor Presets
Read-only diagramrenderDslPreviewSvg()Static SVG

Standalone building blocks: Grid API, DSL Editor API.

Extended editor (default)

ts
import { createEditor, allPlugins } from 'velo-circuit'

const editor = createEditor({ plugins: allPlugins() })

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

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

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

editor.setValue('R0-C1-L2')
editor.undo()
editor.redo()
editor.destroy()

Static diagram (no editor)

For read-only SVG in any app or docs site:

ts
import { renderDslPreviewSvg } from 'velo-circuit'

const svg = renderDslPreviewSvg('R0-p(R1,C1)-Wo2', {
  themeMode: 'dark',
  colorMode: 'multicolor',
  connectionStyle: 'curved',
})

See Static SVG Rendering for wire styles, color modes, and framework integration.

What is a Circuit DSL?

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

Operator / codeMeaningExample
-SeriesR0-C1
p(a,b)Parallelp(R0,C1)
R, C, LPassivesR0, C1, L2
QCPEQ0{5e-5,0.8}
W, Ws, WoWarburg variantsW2, Ws1, Wo3
GGerischerG0{1e-3,0.1}
PdwParallel Diffusion WarburgPdw0
CC, HNDispersionCC1{50,1e-3,0.8}

All eleven element kinds

CodeLabelParams
RResistorR
CCapacitorC
LInductorL
QCPEQ₀, n
WWarburg (infinite)σ
WsWarburg (short)Y₀, B
WoWarburg (open)Y₀, B
GGerischerY₀, K
PdwParallel Diffusion WarburgD1, D2, θ, Λ
CCCole-ColeR, τ, α
HNHavriliak-NegamiR, τ, α, β

See Element Types for units, ranges, and symbols.

Lite embed (framework)

tsx
import { useCircuitEditor } from 'velo-circuit/react'

const { containerRef } = useCircuitEditor({ preset: 'lite', initialDsl: 'R0-p(R1,C1)' })

Next Steps