# Connections

Connections tell Circuit Diagram where the valid points on your component are for other components to connect to. Connections are defined as lines, along which any point is considered a place where another component can connect.

All connections are placed within the `<connections>` tag.

You may want connections to be available only if certain conditions are met. For this reason, all connections are contained within groups, allowing conditions to be set for each group independently. If the group's conditions are met, all connections within that group will be applied.

Below is an example group within the `<connections>` tag:

``````<connections>
<group conditions="horizontal">
<connection name="a" start="_Start" end="_Middle-21x" edge="start" />
<connection name="b" start="_Middle+21x" end="_End" edge="end" />
</group>
</connections>
``````

The conditions here make the connections only apply when the component is horizontal.

Each connection within the group defines its name (useful for implementations), the start point, end point and where the edges are.

### Name

The name should be an alphanumeric value, starting with a letter.

The name should be unique such that there is only ever one connection in use with a certain name.

For example, the same name could be used inside a group that only applies when the component is vertical, and in a group which only applies when the component is horizontal.

### Start and End

The syntax for the start and end are:

• One of:
• `_Start` means the left-most point if the component is horizontal, and the highest point if the component is vertical
• `_End` means the right-most point if the component is horizontal, and the lowest point if the component is vertical
• `_Middle` means half-way between `_Start` and `_End`
• Note: the start and end locations lie along a horizontal or vertical line, meaning that either their x or y coordinates will always be the same
• Position modifiers placed after the `_Start`, `_Middle` or `_End`:
• `+12x` adds 12 horizontally to the position
• `-8y` subtracts 8 vertically from the position
• If both modifiers are used, the x modifier should be placed before the y modifier

### Edges

The `edge` attribute defines where the "bare" end of the wire is. This is important, because when two components are connected, at least one of the two connections must be an edge.

Choose from the following values for the edge:

• `start` - the edge is at the start of the connection line
• `end` - the edge is at the end of the connection line
• `both` - both ends of the connection line are edges

At least one end must be an edge.

### Example

Below is the `<connections>` section from the Resistor component:

``````<connections>
<group conditions="horizontal">
<connection name="a" start="_Start" end="_Middle-21x" edge="start" />
<connection name="b" start="_Middle+21x" end="_End" edge="end" />
</group>
<group conditions="!horizontal">
<connection name="a" start="_Start" end="_Middle-21y" edge="start" />
<connection name="b" start="_Middle+21y" end="_End" edge="end" />
</group>
</connections>
``````

Next: render