Skip to content

Commit

Permalink
fix: correctly determine arc start/end points #16
Browse files Browse the repository at this point in the history
  • Loading branch information
urish committed Jan 31, 2020
1 parent 926fb58 commit 30a2ae3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
9 changes: 9 additions & 0 deletions src/board.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,15 @@ describe('convertArc', () => {
'(gr_arc (start 0.465 2.978) (end -5.746 6.659) (angle 358.992) (width 0.152) (layer "B.SilkS"))'
);
});

it('should correctly determine the arc start and end point (issue #16)', () => {
const arc = 'ARC~1~1~S$9~M4262.5,3279.5 A33.5596,33.5596 0 0 0 4245.5921,3315.5816~~gge8~0'
.split('~')
.slice(1);
expect(encodeObject(convertArc(arc))).toEqual(
'(gr_arc (start 70.739 78.486) (end 62.38 80.158) (angle 72.836) (width 0.254) (layer "F.Cu"))'
);
});
});

describe('convertCopperArea', () => {
Expand Down
3 changes: 2 additions & 1 deletion src/board.ts
Original file line number Diff line number Diff line change
Expand Up @@ -213,10 +213,11 @@ export function convertArc(args: string[], objName = 'gr_arc', transform?: IPare
end.x,
end.y
);
const endPoint = sweep === '1' ? start : end;
return [
objName,
['start', cx, cy], // actually center
['end', start.x, start.y],
['end', endPoint.x, endPoint.y],
['angle', Math.abs(extent)],
['width', kiUnits(width)],
['layer', getLayerName(layer)]
Expand Down

0 comments on commit 30a2ae3

Please sign in to comment.