import SVG from "../Geometry/SVG.js"; import { dataService } from "./DataService.js"; import { mathUtil } from "../Util/MathUtil.js"; import { uiService } from "./UIService.js"; export default class SVGService { constructor() {} create(position, type, svgId) { let svg = new SVG(position, type, svgId); dataService.addSVG(svg); return svg; } copy(vectorId) { let SVG = dataService.getSVG(vectorId); let newCenter = uiService.getNewPositionForPop(SVG.center); let newSVG = this.create(newCenter, SVG.type); newSVG.setScale(SVG.scale); for (let i = 0; i < SVG.points.length; ++i) { let dx = SVG.points[i].x - SVG.center.x; let dy = SVG.points[i].y - SVG.center.y; newSVG.points[i].x = newSVG.center.x + dx; newSVG.points[i].y = newSVG.center.y + dy; } return newSVG; } } const svgService = new SVGService(); export { svgService };