feat: add DXF (R12) and SVG exporters

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
immortaly007andClaude Opus 5.5 committed 2026-10-15 14:39:29 +02:00
1 parent b142c4f766
commit 8d597e856e
4 files changed
+119

No files matched your search

+27
View File
@@ -0,0 +1,27 @@
import { describe, expect, it } from 'vitest';
import { toSvg } from '../src/lib/export-svg';
const shape = {
outer: [{ x: 0, y: 0 }, { x: 100, y: 0 }, { x: 100, y: 50 }, { x: 0, y: 50 }],
holes: [[{ x: 10, y: 10 }, { x: 20, y: 10 }, { x: 20, y: 20.5 }]],
};
describe('toSvg', () => {
it('declares its size in mm with a matching viewBox', () => {
const svg = toSvg(shape);
expect(svg).toContain('width="100mm"');
expect(svg).toContain('height="50mm"');
expect(svg).toContain('viewBox="0 0 100 50"');
});
it('writes one closed subpath per ring in a single evenodd path', () => {
const svg = toSvg(shape);
const d = svg.match(/ d="([^"]+)"/)![1];
expect(d.match(/M/g)).toHaveLength(2);
expect(d.match(/Z/g)).toHaveLength(2);
expect(d).toContain('M0,0 L100,0 L100,50 L0,50 Z');
expect(d).toContain('20,20.5');
expect(svg).toContain('fill-rule="evenodd"');
expect(svg).toContain('fill="none"');
});
});