Skip to content

Commit

Permalink
feat: add junctions and no-connect
Browse files Browse the repository at this point in the history
  • Loading branch information
karinch committed Feb 19, 2020
1 parent 5122822 commit 4016757
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/schematic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,26 @@ function flatten<T>(arr: T[]) {
return [].concat(...arr);
}

function convertNoConnect(args: string[]) {
const [pinDotX, pinDotY, id, pathStr, color, locked] = args;
const kiUnitX = kiUnits(pinDotX);
const kiUnitY = kiUnits(pinDotY);
const result = [];
result.push(`NoConn ~ ${kiUnitX} ${kiUnitY}`);

return result;
}

function convertJunction(args: string[]) {
const [pinDotX, pinDotY, junctionCircleRadius, fillColor, id, locked] = args;
const kiUnitX = kiUnits(pinDotX);
const kiUnitY = kiUnits(pinDotY);
const result = [];
result.push(`Connection ~ ${kiUnitX} ${kiUnitY}`);

return result;
}

function convertWire(args: string[]) {
const [points, strokeColor, strokeWidth, strokeStyle, fillColor, id, locked] = args;
const coordList = points.split(' ');
Expand All @@ -34,6 +54,10 @@ function convertShape(shape: string) {
switch (type) {
case 'W':
return convertWire(args);
case 'J':
return convertJunction(args);
case 'O':
return convertNoConnect(args);
default:
console.warn(`Warning: unsupported shape ${type}`);
return [];
Expand Down

0 comments on commit 4016757

Please sign in to comment.