-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathSVG.js
35 lines (26 loc) · 766 Bytes
/
SVG.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
class SVG{
setExportType(type){
this.type = type;
}
setFillColor(color){
this.fill = color;
}
generatePolygon(figures, width, height){
let svgCode = [];
svgCode[0] = `<svg height="`+height+`" width="`+width+`">`;
for(let j = 0; j < figures.length; j++){
let points = figures[j].points;
let translates = figures[j].translate;
svgCode[0] += `
<polygon points="`;
for(let i = 0; i < points.length; i++){
svgCode[0] += "" + (points[i].x + translates[0]) + "," + (points[i].y + translates[1]) +" ";
}
svgCode[0] += `" style="fill:`+figures[j].fill+`; stroke: black; stroke-width:1"/>`
}
svgCode[0] += `
</svg>
`;
saveStrings(svgCode, 'hello', this.type);
}
}