mirror of
https://github.com/ajayyy/SponsorBlock.git
synced 2026-01-28 05:10:50 +03:00
Add svgjs and testing with fake dom
This commit is contained in:
@@ -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.");
|
||||
}
|
||||
Reference in New Issue
Block a user