Add svgjs and testing with fake dom

This commit is contained in:
Ajay Ramachandran
2021-09-26 00:23:49 -04:00
parent 51d9edbbb4
commit 21f54eef67
4 changed files with 3102 additions and 268 deletions

View File

@@ -1,9 +1,29 @@
import { VisualSegmentInfo } from "../types";
import { Svg, SVG } from "@svgdotjs/svg.js";
export function toSVG(visuals: VisualSegmentInfo[]): string {
throw new Error("Method not implemented.");
export function toSVG(visuals: VisualSegmentInfo[]): Svg {
const svg = SVG().size(100, 100);
for (const visual of visuals) {
const path = svg.polygon();
path.fill(visual.color);
// path.stroke({
// width: 1,
// color: visual.color
// });
path.plot(visual.bounds);
}
console.log(svg.svg());
return svg;
}
export function toVisualSegmentInfo(svg: string): VisualSegmentInfo {
export function toVisualSegmentInfo(svgInput: string | Svg): VisualSegmentInfo {
let svg = svgInput as Svg;
if (typeof svgInput === "string") {
svg = SVG().svg(svgInput);
}
throw new Error("Method not implemented.");
}