Akiha-circuit draws electric circuit diagram from ASCII art.

How to use

Node.js

Install Akiha-circuit:

npm install -g akiha-circuit

To bury SVG files to your file, you type the below command.

akiha-circuit <filename>.akihac.<extension>

HTML(.htm, .html), Markdown(.md) and Asciidoc(.adoc, .asciidoc) are avaiable as extention.

Browser

Write this HTML fragment in your HTML file.

<script src="akiha-circuit.js"></script>

To output circuit diagram, you surround the source of the pattern in script tag whose type attribute is text/x-akiha-circuit.

Writing circuit

Akiha-circuit interprets circuit diagram by ASCII art.

The node of circuit is written by '*'.
How to write element (device) will show chapter "Available elements (devices)".

The constant of element must be specified.
If the element is written horizontally, the constant must be written in left point of element (resistor, inductor, ac voltage source), or left of element (capacitor, battery).
If the element is written vertically, the constant must be written in right side of the element (resistor, inductor), or right upper side of the element (capacitor, battery, ac voltage source).

The label of element can be specify above the constant.
The label is optional.

Polarity of capacitor can also be specified.
Polarity must be written left lower side of the capacitor (horizontally), or left upper side (vertically).

Good example:

    R1
    100k
 *--^v^v---*
 |         |
 |         <R2
 |         >10k
 |         <
 |         >
 |         |
 *---------*
   C1
   100p| |
 *-----| |---*
 |    +| |   |C2
 |          +|0.1u
 |          ---
 |
 |          ---
 |           |
 *-----------*

Bad example:

      R1
       100k
 *--^v^v---*
 |         |
 |       R2<
 |      10k>
 |         <
 |         >
 |         |
 *---------*
          C1
       | |100p
 *-----| |-----*
 |     | |+    |
 |             |+
 |            ---
 |
 |            ---
 |           C2|
 |         0.1u|
 *-------------*

Available Elements (Devices)

Resistor

    R1
    100k
 *--^v^v---*
 |         |
 |         <R2
 |         >10k
 |         <
 |         >
 |         |
 *---------*
svg

Capacitor

   C1
   100p| |
 *-----| |---*
 |    +| |   |C2
 |          +|0.1u
 |          ---
 |
 |          ---
 |           |
 *-----------*
svg

Inductor

    L1
    0.1m
 *--mmmm-----*
 |           |
 |           cL2
 |           c1m
 |           c
 |           |
 *-----------*
svg

Battery (dc voltage source)

    V1
    3V|
 *----||-----*
 |    |      |
 |V2         <100k
 |1V         <
---          <
 -           |
 |           |
 *-----------*
svg

ac voltage source

    V1
    1V
 *--(~)------*
 |           |
 |V2         <100k
 |1V         >
(~)          <
 |           |
 *-----------*
svg