587 lines
52 KiB
JavaScript
587 lines
52 KiB
JavaScript
const test = require('ava')// require('tape')
|
|
const deserializer = require('./index.js')
|
|
|
|
test('translate svg (rect) to jscad code', function (t) {
|
|
const sourceSvg = `
|
|
<svg xmlns="http://www.w3.org/2000/svg"
|
|
width="467" height="462">
|
|
<rect x="80" y="60" width="250" height="250" rx="20"/>
|
|
<rect x="140" y="120" width="250" height="250" rx="40"/>
|
|
</svg>`
|
|
|
|
// const sourceSvg = fs.readFileSync('PATH/TO/file.svg')
|
|
|
|
const expected = `function main(params) {
|
|
var cag0 = new CAG();
|
|
var cag00 = CAG.roundedRectangle({center: [57.8556,-52.2111], radius: [35.277775,35.277775], roundradius: 5.644443999999999});
|
|
cag0 = cag0.union(cag00);
|
|
var cag01 = CAG.roundedRectangle({center: [74.7889,-69.1444], radius: [35.277775,35.277775], roundradius: 11.288887999999998});
|
|
cag0 = cag0.union(cag01);
|
|
return cag0;
|
|
}
|
|
`
|
|
const observed = deserializer.deserialize(sourceSvg, undefined, {output: 'jscad', addMetaData: false})
|
|
t.deepEqual(observed, expected)
|
|
})
|
|
|
|
test('translate svg (circle) to jscad code', function (t) {
|
|
const sourceSvg = `<svg height="100" width="100">
|
|
<circle cx="50" cy="50" r="40" stroke="black" stroke-width="3" fill="red" />
|
|
</svg>
|
|
`
|
|
const expected = `function main(params) {
|
|
var cag0 = new CAG();
|
|
var cag00 = CAG.circle({center: [14.111109999999998,-14.111109999999998], radius: 11.288887999999998});
|
|
cag0 = cag0.union(cag00);
|
|
return cag0;
|
|
}
|
|
`
|
|
const observed = deserializer.deserialize(sourceSvg, undefined, {output: 'jscad', addMetaData: false})
|
|
t.deepEqual(observed, expected)
|
|
})
|
|
|
|
test('translate svg (ellipse) to jscad code', function (t) {
|
|
const sourceSvg = `<svg width="120" height="120" viewBox="0 0 120 120"
|
|
xmlns="http://www.w3.org/2000/svg">
|
|
|
|
<ellipse cx="60" cy="60" rx="50" ry="25"/>
|
|
</svg>
|
|
`
|
|
const expected = `function main(params) {
|
|
var cag0 = new CAG();
|
|
var cag00 = CAG.ellipse({center: [16.933331999999996,-16.933331999999996], radius: [14.111109999999996,7.055554999999998]});
|
|
cag0 = cag0.union(cag00);
|
|
return cag0;
|
|
}
|
|
`
|
|
const observed = deserializer.deserialize(sourceSvg, undefined, {output: 'jscad', addMetaData: false})
|
|
t.deepEqual(observed, expected)
|
|
})
|
|
|
|
test('translate svg (polyline) to jscad code', function (t) {
|
|
const sourceSvg = `
|
|
<svg width="120" height="120" xmlns="http://www.w3.org/2000/svg">
|
|
<polyline fill="none" stroke="black"
|
|
points="20,100 40,60 70,80 100,20"/>
|
|
</svg>`
|
|
|
|
const expected = `function main(params) {
|
|
var cag0 = new CAG();
|
|
var cag00 = new CSG.Path2D([
|
|
[5.644443999999999,-28.222219999999997],
|
|
[11.288887999999998,-16.933331999999996],
|
|
[19.755553999999997,-22.577775999999997],
|
|
[28.222219999999997,-5.644443999999999],
|
|
],false);
|
|
cag00 = cag00.expandToCAG(0.1411111,CSG.defaultResolution2D);
|
|
cag0 = cag0.union(cag00);
|
|
return cag0;
|
|
}
|
|
`
|
|
const observed = deserializer.deserialize(sourceSvg, undefined, {output: 'jscad', addMetaData: false})
|
|
t.deepEqual(observed, expected)
|
|
})
|
|
|
|
test('translate svg (polygon) to jscad code', function (t) {
|
|
const sourceSvg = `<svg width="120" height="120" viewBox="0 0 120 120"
|
|
xmlns="http://www.w3.org/2000/svg">
|
|
|
|
<polygon points="60,20 100,40 100,80 60,100 20,80 20,40"/>
|
|
</svg>`
|
|
|
|
const expected = `function main(params) {
|
|
var cag0 = new CAG();
|
|
var cag00 = new CSG.Path2D([
|
|
[16.933331999999996,-5.644443999999999],
|
|
[28.222219999999993,-11.288887999999998],
|
|
[28.222219999999993,-22.577775999999997],
|
|
[16.933331999999996,-28.222219999999993],
|
|
[5.644443999999999,-22.577775999999997],
|
|
[5.644443999999999,-11.288887999999998],
|
|
],true);
|
|
cag00 = cag00.innerToCAG();
|
|
cag0 = cag0.union(cag00);
|
|
return cag0;
|
|
}
|
|
`
|
|
const observed = deserializer.deserialize(sourceSvg, undefined, {output: 'jscad', addMetaData: false})
|
|
t.deepEqual(observed, expected)
|
|
})
|
|
|
|
test('translate svg (line) to jscad code', function (t) {
|
|
const sourceSvg = `<svg width="120" height="120" viewBox="0 0 120 120"
|
|
xmlns="http://www.w3.org/2000/svg">
|
|
|
|
<line x1="20" y1="100" x2="100" y2="20"
|
|
stroke-width="2" stroke="black"/>
|
|
</svg>
|
|
`
|
|
|
|
const expected = `function main(params) {
|
|
var cag0 = new CAG();
|
|
var cag00 = new CSG.Path2D([[5.644443999999999,-28.222219999999993],[28.222219999999993,-5.644443999999999]],false);
|
|
cag00 = cag00.expandToCAG(0.2822221999999999,CSG.defaultResolution2D);
|
|
cag0 = cag0.union(cag00);
|
|
return cag0;
|
|
}
|
|
`
|
|
const observed = deserializer.deserialize(sourceSvg, undefined, {output: 'jscad', addMetaData: false})
|
|
t.deepEqual(observed, expected)
|
|
})
|
|
|
|
test('deserialize svg (path: simple) to jscad code', function (t) {
|
|
const sourceSvg = `<svg height="210" width="400">
|
|
<path d="M150 0 L75 200 L225 200 Z" />
|
|
</svg>
|
|
`
|
|
|
|
const expected = `function main(params) {
|
|
var cag0 = new CAG();
|
|
var cag00 = new CAG();
|
|
var cag001 = new CSG.Path2D([[42.33333,0]],false);
|
|
cag001 = cag001.appendPoint([21.166665,-56.44443999999999]);
|
|
cag001 = cag001.appendPoint([63.49999499999999,-56.44443999999999]);
|
|
cag001 = cag001.close();
|
|
cag001 = cag001.innerToCAG();
|
|
cag00 = cag00.union(cag001);
|
|
cag0 = cag0.union(cag00);
|
|
return cag0;
|
|
}
|
|
`
|
|
const observed = deserializer.deserialize(sourceSvg, undefined, {output: 'jscad', addMetaData: false})
|
|
t.deepEqual(observed, expected)
|
|
})
|
|
|
|
test('deserialize svg (path: with bezier) to jscad code', function (t) {
|
|
const sourceSvg = `
|
|
<svg height="210" width="400">
|
|
<path d="M100,100
|
|
L150,100
|
|
a50,25 0 0,0 150,100
|
|
q50,-50 70,-170
|
|
Z"
|
|
style="stroke: #006666; fill: none;"/>
|
|
</svg>
|
|
`
|
|
const expected = `function main(params) {
|
|
var cag0 = new CAG();
|
|
var cag00 = new CAG();
|
|
var cag001 = new CSG.Path2D([[28.222219999999997,-28.222219999999997]],false);
|
|
cag001 = cag001.appendPoint([42.33333,-28.222219999999997]);
|
|
cag001 = cag001.appendArc([84.66666,-56.44443999999999],{xradius: 14.111109999999998,yradius: -7.055554999999999,xaxisrotation: 0,clockwise: false,large: false});
|
|
cag001 = cag001.appendBezier([[98.77776999999999,-42.33333],[98.77776999999999,-42.33333],[104.42221399999998,-8.466665999999998]]);
|
|
cag001 = cag001.close();
|
|
cag001 = cag001.innerToCAG();
|
|
cag00 = cag00.union(cag001);
|
|
cag0 = cag0.union(cag00);
|
|
return cag0;
|
|
}
|
|
`
|
|
const observed = deserializer.deserialize(sourceSvg, undefined, {output: 'jscad', addMetaData: false})
|
|
t.deepEqual(observed, expected)
|
|
})
|
|
|
|
test('deserialize svg (complex example : baby panda) to jscad code', function (t) {
|
|
const sourceSvg = `
|
|
<svg viewBox="0 0 800 600" height="600" width="800" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" id="svg-canvas" version="1.1">
|
|
<g transform="scale(0.1)">
|
|
<path fill="#000000" stroke="#ff4500" class="odd" d="M 67.5 29.06 C 65.3 29.11 62.37 29.69 61 30.33 C 59.62 30.97 57.01 32.63 55.2 34 C 53.38 35.38 50.71 38.3 49.25 40.5 C 47.8 42.7 45.57 46.53 44.31 49 C 43.04 51.48 42.01 55.19 42 57.25 C 42 59.31 41.66 61.18 41.25 61.39 C 40.84 61.61 40.2 65.1 39.83 69.14 C 39.36 74.27 39.59 78.09 40.58 81.75 C 41.36 84.64 41.99 87.79 41.97 88.75 C 41.95 89.71 43.53 92.64 45.47 95.25 C 48.31 99.07 49.52 99.95 51.65 99.75 C 53.73 99.55 54.84 98.4 56.9 94.32 C 58.33 91.47 61.86 86.74 64.74 83.82 C 67.62 80.89 69.98 77.94 69.99 77.25 C 70 76.56 73.1 72.74 76.88 68.75 C 80.67 64.76 84.65 59.7 85.74 57.5 C 86.82 55.3 89.01 52.52 90.61 51.32 L 93.5 49.15 L 91 48.19 C 89.63 47.67 86.85 44.82 84.84 41.87 C 82.82 38.92 79 34.8 76.34 32.72 C 72.47 29.71 70.7 28.97 67.5 29.06 Z ">
|
|
</path>
|
|
<path fill="#000000" stroke="#ff4500" class="odd" d="M 235.5 33.16 C 232.75 33.22 229.6 33.43 228.5 33.61 C 227.4 33.8 224.14 35.99 221.25 38.48 C 217.87 41.39 215.99 43.8 215.96 45.25 C 215.94 46.81 219.7 51.32 228.27 60 L 240.61 72.5 L 246.74 85 C 250.12 91.88 253.6 98.18 254.48 99 C 255.37 99.83 256.06 101.18 256.03 102 C 255.99 102.83 256.54 104.07 257.23 104.77 C 257.93 105.46 259.96 106.03 261.75 106.02 L 265 106 L 268 99.5 C 270.41 94.29 271 91.66 270.98 86.25 C 270.97 82.54 269.92 75 268.64 69.5 C 267.36 64 265.73 58.38 265 57 C 264.27 55.63 262.01 52.25 259.97 49.5 C 257.92 46.75 254.51 42.73 252.38 40.57 C 250.24 38.41 246.7 35.83 244.5 34.84 C 242.18 33.8 238.4 33.09 235.5 33.16 Z ">
|
|
</path>
|
|
<path fill="#000000" stroke="#ff4500" class="odd" d="M 124 118.01 C 123.18 118.05 120.7 118.96 118.5 120.02 C 116.3 121.09 112.58 124.11 110.24 126.74 C 107.9 129.36 105.99 132.06 105.99 132.75 C 106 133.44 104.88 135.69 103.51 137.75 C 102.15 139.81 100.57 141.95 100.01 142.5 C 99.45 143.05 97.53 144.77 95.75 146.33 C 93.96 147.89 90.7 150.49 88.5 152.11 C 86.3 153.74 84.28 155.04 84 155.01 C 83.73 154.98 82.43 157.56 81.12 160.73 C 79.55 164.53 78.97 167.35 79.42 169 C 79.79 170.38 80.35 172.63 80.67 174 C 80.98 175.38 82.21 177.4 83.4 178.5 C 84.59 179.6 85.78 180.95 86.03 181.5 C 86.29 182.05 88.3 184.01 90.5 185.86 C 93.99 188.79 94.95 189.13 98 188.5 C 99.93 188.1 103.08 186.76 105 185.53 C 106.93 184.3 109.99 181.54 111.81 179.4 C 113.64 177.25 118.25 171.79 122.06 167.25 C 125.88 162.71 129 158.55 129 158 C 129 157.45 130.57 155.43 132.5 153.5 C 135.4 150.6 136 149.27 136.01 145.75 C 136.02 143.41 136.58 138.71 137.26 135.3 L 138.5 129.1 L 136 126.41 C 134.63 124.94 131.7 122.43 129.5 120.84 C 127.3 119.24 124.83 117.97 124 118.01 Z ">
|
|
</path>
|
|
<path fill="#000000" stroke="#ff4500" class="odd" d="M 197 121.01 C 196.18 121.05 193.57 122.97 191.22 125.29 L 186.94 129.5 L 187.39 135 C 187.64 138.03 188.26 142.98 188.78 146 C 189.29 149.03 190.29 152.63 191 154 C 191.7 155.38 195.52 161.45 199.49 167.5 C 203.45 173.55 208.42 181.2 210.53 184.5 C 212.64 187.8 215.52 191.55 216.93 192.83 C 219.09 194.79 219.9 194.99 222 194.1 C 223.38 193.51 225.49 192.01 226.69 190.77 C 227.9 189.52 230.52 185.35 232.52 181.5 C 234.98 176.78 236 173.69 235.64 172 C 235.35 170.63 235.5 168.83 235.97 168 C 236.53 167.03 236.14 165.26 234.88 163 C 233.8 161.07 232.3 158.82 231.53 158 C 230.77 157.18 229.02 155.38 227.65 154 C 226.28 152.63 223.88 150.55 222.33 149.38 C 220.77 148.22 217.73 143.72 215.57 139.38 C 213.4 135.05 210.25 129.77 208.57 127.66 C 206.88 125.54 203.93 123.17 202 122.38 C 200.08 121.59 197.83 120.98 197 121.01 Z ">
|
|
</path>
|
|
<path fill="#000000" stroke="#ff4500" class="odd" d="M 33.25 170.98 C 32.84 170.98 31.92 175.14 31.2 180.23 C 30.49 185.33 29.48 194 28.95 199.5 C 28.43 205 27.35 216.93 26.56 226 C 25.77 235.08 24.64 243.74 24.06 245.25 C 23.48 246.76 23.2 248.56 23.44 249.25 C 23.69 249.94 24.13 256.58 24.43 264 C 24.73 271.43 25.43 277.95 25.99 278.5 C 26.67 279.17 26.69 281.67 26.06 286 C 25.54 289.58 25.26 298.35 25.45 305.5 C 25.64 312.65 26.11 322.33 26.49 327 C 26.88 331.68 28.21 338.65 29.46 342.5 C 30.7 346.35 32.3 350.63 33.01 352 C 33.73 353.38 35.33 358.55 36.57 363.5 C 37.81 368.45 39.55 374.53 40.44 377 C 41.32 379.48 42.03 384.2 42.03 387.5 C 42.02 390.8 42.46 395.19 43.01 397.25 L 44 401 L 95 401 L 146 401 L 145.43 392.75 C 145.11 388.21 144.25 381.8 143.52 378.5 C 142.78 375.2 141.9 367.55 141.55 361.5 C 141.21 355.45 140.07 346 139.03 340.5 C 137.98 335 136.86 327.8 136.53 324.5 C 136.19 321.2 135.43 316.48 134.82 314 C 134.22 311.52 134.01 307.36 134.36 304.75 C 134.83 301.28 135.93 298.99 138.42 296.25 L 141.85 292.5 L 155.67 292.65 C 163.28 292.73 169.63 293.18 169.78 293.65 C 169.94 294.12 168.85 296.3 167.37 298.5 C 165.89 300.7 164.34 304.08 163.94 306 C 163.53 307.93 162.7 311.98 162.09 315 C 161.48 318.02 160.99 322.3 161 324.5 C 161.02 326.7 161.66 330.3 162.43 332.5 C 163.2 334.7 165.14 338.98 166.74 342 C 168.34 345.03 170.78 349.3 172.17 351.5 C 173.56 353.7 175.33 356.01 176.1 356.63 C 176.87 357.25 178.63 358.1 180 358.53 C 181.38 358.95 183.63 360.12 185 361.12 C 186.38 362.12 189.98 363.57 193 364.33 C 196.03 365.09 200.75 365.62 203.5 365.5 C 206.25 365.38 212.33 364.96 217 364.55 C 221.68 364.15 228.65 362.91 232.5 361.8 C 236.35 360.69 240.85 359.39 242.5 358.92 C 244.15 358.45 247.3 356.88 249.5 355.41 C 251.7 353.95 254.85 352.07 256.5 351.23 C 258.15 350.4 262.2 347.93 265.5 345.76 L 271.5 341.8 L 280 344.01 L 288.5 346.22 L 292.87 344.86 C 295.28 344.11 297.6 343.05 298.02 342.5 C 298.45 341.95 299.68 338.8 300.75 335.5 C 301.82 332.2 303.28 328.38 303.98 327 C 304.8 325.42 305.41 319.01 305.67 309.5 C 305.91 300.46 305.62 292.51 304.94 289.5 C 304.32 286.75 302.32 281.13 300.51 277 C 298.69 272.88 296.45 267.02 295.53 264 C 294.61 260.98 293.05 257.38 292.07 256 C 291.01 254.52 288.5 253.02 285.89 252.32 C 283.48 251.68 280.54 250.33 279.36 249.32 C 277.9 248.08 276.55 244.63 275.11 238.5 C 273.95 233.55 273 228.26 273 226.75 C 273 225.24 272.55 223.78 272 223.5 C 271.45 223.23 270.99 222.21 270.99 221.25 C 270.98 220.29 270.08 217.59 268.99 215.25 C 267.89 212.91 266.55 211 266 211 C 265.45 211 265.02 212.01 265.04 213.25 C 265.07 214.49 264.37 216.18 263.5 217 C 262.63 217.83 261.95 219.63 261.99 221 C 262.03 222.38 261.26 224.28 260.28 225.24 C 259.3 226.19 257.15 227.35 255.5 227.81 C 253.36 228.41 252.5 229.27 252.5 230.8 C 252.5 231.98 251.49 233.64 250.25 234.48 C 249.01 235.31 247.44 235.83 246.75 235.63 C 246.06 235.43 244.83 235.89 244 236.66 C 243.18 237.43 240.56 238.16 238.2 238.28 C 234.85 238.45 233.07 239.27 230.2 241.94 C 228.16 243.84 225.38 245.67 224 246.02 C 222.45 246.42 221.29 247.57 220.96 249.08 C 220.51 251.04 219.64 251.59 216.3 252 C 214.04 252.28 211.14 253.44 209.85 254.6 C 208.56 255.75 205.59 257.44 203.25 258.35 C 200.91 259.26 198.21 259.99 197.25 259.99 C 196.29 259.98 193.03 261.16 190 262.61 C 185.79 264.63 182.15 265.43 174.5 266.02 C 169 266.44 162.7 266.55 160.5 266.26 C 158.3 265.97 155.82 265.12 155 264.37 C 153.73 263.21 152.85 263.23 149.25 264.5 C 145.45 265.84 144.55 265.83 140.75 264.45 C 138.41 263.6 133.13 261.1 129 258.89 L 121.5 254.88 L 116.75 256.44 C 114.14 257.3 110.99 258 109.75 258 C 108.51 258 104.8 256.2 101.5 254 C 98.2 251.8 94.6 250.01 93.5 250.01 C 92.4 250.01 89.93 248.98 88 247.73 C 86.08 246.47 82.7 244.84 80.5 244.1 C 78.3 243.36 75.83 242.19 75 241.49 C 74.18 240.8 71.03 239.09 68 237.7 C 64.97 236.3 61.94 234.56 61.25 233.83 C 60.57 233.1 59.73 229.8 59.39 226.5 C 59.04 223.2 58.14 219.49 57.38 218.25 C 56.28 216.45 55.35 216.1 52.75 216.49 C 50.29 216.87 48.95 216.44 47.22 214.74 C 45.97 213.51 44.96 211.49 44.97 210.25 C 44.99 209.01 44.55 207.78 44 207.5 C 43.45 207.23 43 205.65 43 204 C 43 202.35 42.55 200.78 42 200.5 C 41.45 200.23 41.02 198.99 41.03 197.75 C 41.05 196.51 40.19 194.38 39.11 193 C 37.83 191.36 37.44 189.98 37.99 189 C 38.47 188.14 38.38 186.43 37.79 185 C 37.21 183.63 36.8 180.93 36.88 179 C 36.95 177.08 36.34 174.49 35.51 173.25 C 34.68 172.01 33.66 170.99 33.25 170.98 Z ">
|
|
</path>
|
|
<path fill="#000000" stroke="#ff4500" class="odd" d="M 148 213.19 C 144.43 213.27 139.93 213.48 138 213.66 C 136.07 213.83 133.94 214.66 133.25 215.49 C 132.27 216.68 132.25 217.8 133.19 220.75 C 133.85 222.81 136.21 226.21 138.44 228.29 C 140.67 230.38 142.84 232.07 143.25 232.04 C 143.66 232.02 146.81 233.74 150.25 235.86 C 153.72 238 156.9 240.78 157.4 242.11 C 157.9 243.42 158.01 245.29 157.65 246.25 C 157.21 247.43 155.46 248.2 152.25 248.63 C 149.64 248.98 144.57 248.9 141 248.47 C 137.43 248.03 132.93 247.63 131 247.58 C 128.16 247.52 127.5 247.87 127.5 249.46 C 127.5 250.93 128.49 251.62 131.5 252.26 C 133.7 252.73 136.13 253.65 136.9 254.3 C 137.92 255.17 145.8 255.5 165.22 255.5 L 192.14 255.5 L 193.82 253.69 C 195.13 252.28 195.25 251.5 194.38 250.19 C 193.44 248.77 191.45 248.5 181.88 248.5 C 175.62 248.5 169.94 248.16 169.25 247.75 C 168.56 247.34 168 246.55 168 246 C 168 245.45 169.46 243.37 171.25 241.38 C 173.04 239.39 177.2 236.28 180.5 234.47 C 183.8 232.66 187.96 229.79 189.75 228.09 C 192.54 225.44 192.96 224.4 192.75 220.79 L 192.5 216.57 L 189 215.62 C 187.08 215.1 182.35 214.69 178.5 214.71 C 174.65 214.73 169.48 214.84 167 214.96 C 164.53 215.08 160.7 214.69 158.5 214.11 C 156.3 213.53 151.57 213.11 148 213.19 Z ">
|
|
</path>
|
|
</g>
|
|
</svg>
|
|
`
|
|
|
|
const expected = `function main(params) {
|
|
var cag0 = new CAG();
|
|
var cag1 = new CAG();
|
|
var cag10 = new CAG();
|
|
var cag101 = new CSG.Path2D([[19.049998499999997,-8.201377132]],false);
|
|
cag101 = cag101.appendBezier([[18.429109659999998,-8.215488242],[17.602198614,-8.379177118],[17.2155542,-8.559799325999998]]);
|
|
cag101 = cag101.appendBezier([[16.826087563999998,-8.740421534],[16.089487621999996,-9.208910386],[15.57866544,-9.595554799999999]]);
|
|
cag101 = cag101.appendBezier([[15.065021036,-9.985021436],[14.311487761999999,-10.809110259999999],[13.899443349999999,-11.429999099999998]]);
|
|
cag101 = cag101.appendBezier([[13.490221159999997,-12.050887939999999],[12.860865654,-13.131798965999998],[12.505265682,-13.828887799999999]]);
|
|
cag101 = cag101.appendBezier([[12.146843487999998,-14.528798855999998],[11.856154621999998,-15.575843217999997],[11.8533324,-16.15722095]]);
|
|
cag101 = cag101.appendBezier([[11.8533324,-16.738598682],[11.757376851999998,-17.266354195999998],[11.64166575,-17.325620857999997]]);
|
|
cag101 = cag101.appendBezier([[11.525954647999999,-17.387709742],[11.34533244,-18.37266522],[11.240910225999999,-19.512842908]]);
|
|
cag101 = cag101.appendBezier([[11.108265792,-20.960642793999998],[11.173176898,-22.038731598],[11.452576875999998,-23.071664849999998]]);
|
|
cag101 = cag101.appendBezier([[11.672710191999998,-23.887287007999998],[11.850510177999999,-24.776286938],[11.844865733999999,-25.04722025]]);
|
|
cag101 = cag101.appendBezier([[11.83922129,-25.318153561999996],[12.285132366,-26.145064608],[12.832643433999998,-26.881664549999996]]);
|
|
cag101 = cag101.appendBezier([[13.634154482,-27.959753353999997],[13.975643344,-28.20810889],[14.576776629999998,-28.15166445]]);
|
|
cag101 = cag101.appendBezier([[15.163798805999997,-28.095220009999995],[15.477065448,-27.770664479999997],[16.058443179999998,-26.619197903999996]]);
|
|
cag101 = cag101.appendBezier([[16.462020925999997,-25.814864633999996],[17.458265291999997,-24.479953627999997],[18.271065227999998,-23.655864803999997]]);
|
|
cag101 = cag101.appendBezier([[19.083865164,-22.828953757999997],[19.749909556,-21.996398267999997],[19.752731777999998,-21.80166495]]);
|
|
cag101 = cag101.appendBezier([[19.755553999999997,-21.606931632],[20.630442819999995,-20.528842827999995],[21.697242735999996,-19.40277625]]);
|
|
cag101 = cag101.appendBezier([[22.766864874,-18.276709672],[23.89010923,-16.84866534],[24.197731427999997,-16.227776499999997]]);
|
|
cag101 = cag101.appendBezier([[24.502531403999996,-15.606887659999998],[25.120598022,-14.822309943999999],[25.572153542,-14.483643304]]);
|
|
cag101 = cag101.appendPoint([26.3877757,-13.871221129999999]);
|
|
cag101 = cag101.appendPoint([25.682220199999996,-13.600287817999998]);
|
|
cag101 = cag101.appendBezier([[25.295575785999997,-13.453532273999999],[24.510998069999996,-12.649199003999998],[23.943731447999998,-11.816643513999997]]);
|
|
cag101 = cag101.appendBezier([[23.373642603999997,-10.984088024],[22.295553799999997,-9.821332559999998],[21.544842747999997,-9.234310383999999]]);
|
|
cag101 = cag101.appendBezier([[20.452642834,-8.384821561999999],[19.95310954,-8.175977133999998],[19.049998499999997,-8.201377132]]);
|
|
cag101 = cag101.close();
|
|
cag101 = cag101.innerToCAG();
|
|
cag10 = cag10.union(cag101);
|
|
cag1 = cag1.union(cag10);
|
|
var cag11 = new CAG();
|
|
var cag111 = new CSG.Path2D([[66.4633281,-9.358488151999998]],false);
|
|
cag111 = cag111.appendBezier([[65.68721704999999,-9.375421483999999],[64.79821711999999,-9.434688146],[64.4877727,-9.485488142]]);
|
|
cag111 = cag111.appendBezier([[64.17732828,-9.539110359999999],[63.25728390799999,-10.157176977999999],[62.441661749999994,-10.859910255999997]]);
|
|
cag111 = cag111.appendBezier([[61.48775071399999,-11.681176857999999],[60.957172977999996,-12.361332359999999],[60.948706312,-12.770554549999998]]);
|
|
cag111 = cag111.appendBezier([[60.943061867999994,-13.210821182],[62.00421733999999,-14.483643304],[64.422861594,-16.933331999999996]]);
|
|
cag111 = cag111.appendPoint([67.905483542,-20.4611095]);
|
|
cag111 = cag111.appendPoint([69.63550562799999,-23.988887]);
|
|
cag111 = cag111.appendBezier([[70.589416664,-25.930575735999994],[71.57154992,-27.708575596],[71.81990545599999,-27.939997799999997]]);
|
|
cag111 = cag111.appendBezier([[72.071083214,-28.174242225999997],[72.26581653199999,-28.555242196],[72.25734986599998,-28.786664399999996]]);
|
|
cag111 = cag111.appendBezier([[72.24606097799999,-29.020908825999996],[72.401283188,-29.370864353999995],[72.596016506,-29.568419893999994]]);
|
|
cag111 = cag111.appendBezier([[72.793572046,-29.763153211999995],[73.36648311199998,-29.924019866],[73.87166085,-29.921197643999996]]);
|
|
cag111 = cag111.appendPoint([74.788883,-29.915553199999998]);
|
|
cag111 = cag111.appendPoint([75.63554959999999,-28.081108899999997]);
|
|
cag111 = cag111.appendBezier([[76.315705102,-26.610731238],[76.4822162,-25.868486851999997],[76.476571756,-24.341664749999996]]);
|
|
cag111 = cag111.appendBezier([[76.473749534,-23.294620388],[76.177416224,-21.166665],[75.81617180799999,-19.614442899999997]]);
|
|
cag111 = cag111.appendBezier([[75.454927392,-18.0622208],[74.994905206,-16.476132036],[74.788883,-16.086665399999998]]);
|
|
cag111 = cag111.appendBezier([[74.58286079399998,-15.700020985999998],[73.94503862199998,-14.74610995],[73.369305334,-13.969998899999998]]);
|
|
cag111 = cag111.appendBezier([[72.790749824,-13.19388785],[71.82837212199999,-12.059354605999998],[71.227238836,-11.449754654]]);
|
|
cag111 = cag111.appendBezier([[70.623283328,-10.840154701999998],[69.62421674,-10.112021425999998],[69.00332789999999,-9.832621448]]);
|
|
cag111 = cag111.appendBezier([[68.348572396,-9.539110359999999],[67.28177248,-9.338732598],[66.4633281,-9.358488151999998]]);
|
|
cag111 = cag111.close();
|
|
cag111 = cag111.innerToCAG();
|
|
cag11 = cag11.union(cag111);
|
|
cag1 = cag1.union(cag11);
|
|
var cag12 = new CAG();
|
|
var cag121 = new CSG.Path2D([[34.9955528,-33.305041822]],false);
|
|
cag121 = cag121.appendBezier([[34.764130596,-33.316330709999995],[34.064219539999996,-33.573152912],[33.4433307,-33.872308444]]);
|
|
cag121 = cag121.appendBezier([[32.82244186,-34.174286198],[31.772575275999998,-35.026597241999994],[31.112175327999996,-35.768841628]]);
|
|
cag121 = cag121.appendBezier([[30.451775379999997,-36.508263792],[29.912730977999995,-37.270263732],[29.912730977999995,-37.464997049999994]]);
|
|
cag121 = cag121.appendBezier([[29.915553199999998,-37.659730368],[29.599464335999997,-38.29473031799999],[29.212819921999998,-38.87610805]]);
|
|
cag121 = cag121.appendBezier([[28.828997729999998,-39.457485782],[28.383086653999996,-40.06144128999999],[28.225042222,-40.216663499999996]]);
|
|
cag121 = cag121.appendBezier([[28.06699779,-40.37188571],[27.525131165999998,-40.857307894],[27.022775649999996,-41.297574526]]);
|
|
cag121 = cag121.appendBezier([[26.517597911999996,-41.737841157999995],[25.59755354,-42.471618878],[24.976664699999997,-42.928818842]]);
|
|
cag121 = cag121.appendBezier([[24.355775859999998,-43.388841027999995],[23.785687015999997,-43.75572988799999],[23.7066648,-43.747263221999994]]);
|
|
cag121 = cag121.appendBezier([[23.630464806,-43.73879655599999],[23.263575946,-44.466929832],[22.893864863999998,-45.36157420599999]]);
|
|
cag121 = cag121.appendBezier([[22.45077601,-46.434018566],[22.287087133999997,-47.229885169999996],[22.414087123999998,-47.6955518]]);
|
|
cag121 = cag121.appendBezier([[22.518509337999998,-48.08501843599999],[22.676553769999995,-48.72001838599999],[22.766864874,-49.106662799999995]]);
|
|
cag121 = cag121.appendBezier([[22.854353756,-49.496129436],[23.201487061999995,-50.066218279999994],[23.53733148,-50.3766627]]);
|
|
cag121 = cag121.appendBezier([[23.873175898,-50.68710711999999],[24.209020315999997,-51.06810708999999],[24.279575866,-51.223329299999996]]);
|
|
cag121 = cag121.appendBezier([[24.352953638,-51.37855151],[24.920220259999997,-51.93170702199999],[25.541109099999996,-52.453818092]]);
|
|
cag121 = cag121.appendBezier([[26.526064577999996,-53.28072913799999],[26.796997889999997,-53.37668468599999],[27.657775599999997,-53.198884699999994]]);
|
|
cag121 = cag121.appendBezier([[28.202464446,-53.085995819999994],[29.091464375999998,-52.707818071999995],[29.633331,-52.36068476599999]]);
|
|
cag121 = cag121.appendBezier([[30.178019845999998,-52.013551459999995],[31.041619777999994,-51.23461818799999],[31.555264182,-50.63066267999999]]);
|
|
cag121 = cag121.appendBezier([[32.071730808,-50.023884949999996],[33.372775149999995,-48.48295173799999],[34.448041732,-47.20166294999999]]);
|
|
cag121 = cag121.appendBezier([[35.526130536,-45.920374161999995],[36.4066638,-44.74632981],[36.4066638,-44.591107599999994]]);
|
|
cag121 = cag121.appendBezier([[36.4066638,-44.43588538999999],[36.84975265399999,-43.865796546],[37.3944415,-43.3211077]]);
|
|
cag121 = cag121.appendBezier([[38.212885879999995,-42.502663319999996],[38.382219199999994,-42.127307794],[38.38504142199999,-41.133885649999996]]);
|
|
cag121 = cag121.appendBezier([[38.387863644,-40.473485702],[38.545908075999996,-39.147041361999996],[38.737819171999995,-38.18466366]]);
|
|
cag121 = cag121.appendPoint([39.0877747,-36.43488601999999]);
|
|
cag121 = cag121.appendPoint([38.382219199999994,-35.675708302]);
|
|
cag121 = cag121.appendBezier([[37.99557478599999,-35.260841668],[37.16866373999999,-34.552463945999996],[36.54777489999999,-34.103730647999996]]);
|
|
cag121 = cag121.appendBezier([[35.926886059999994,-33.652175127999996],[35.229797225999995,-33.293752934],[34.9955528,-33.305041822]]);
|
|
cag121 = cag121.close();
|
|
cag121 = cag121.innerToCAG();
|
|
cag12 = cag12.union(cag121);
|
|
cag1 = cag1.union(cag12);
|
|
var cag13 = new CAG();
|
|
var cag131 = new CSG.Path2D([[55.597773399999994,-34.151708422]],false);
|
|
cag131 = cag131.appendBezier([[55.366351196,-34.162997309999994],[54.62975125399999,-34.704863933999995],[53.966529083999994,-35.359619437999996]]);
|
|
cag131 = cag131.appendPoint([52.758618068,-36.54777489999999]);
|
|
cag131 = cag131.appendPoint([52.88561805799999,-38.099996999999995]);
|
|
cag131 = cag131.appendBezier([[52.95617360799999,-38.955130266],[53.13115137199999,-40.352130155999994],[53.27790691599999,-41.2044412]]);
|
|
cag131 = cag131.appendBezier([[53.421840237999994,-42.059574465999994],[53.704062437999994,-43.07557438599999],[53.904440199999996,-43.462218799999995]]);
|
|
cag131 = cag131.appendBezier([[54.10199573999999,-43.851685436],[55.180084543999996,-45.564774189999994],[56.300506678,-47.272218499999994]]);
|
|
cag131 = cag131.appendBezier([[57.418106589999994,-48.97966281],[58.82075092399999,-51.13866263999999],[59.416239766,-52.069995899999995]]);
|
|
cag131 = cag131.appendBezier([[60.01172860799999,-53.00132916],[60.824528543999996,-54.059662409999994],[61.222461845999995,-54.420906826]]);
|
|
cag131 = cag131.appendBezier([[61.832061798,-54.97406233799999],[62.06066178,-55.030506777999996],[62.65332839999999,-54.77932901999999]]);
|
|
cag131 = cag131.appendBezier([[63.042795035999994,-54.61281792199999],[63.638283877999996,-54.189484621999995],[63.976950517999995,-53.839529094]]);
|
|
cag131 = cag131.appendBezier([[64.31843938,-53.486751344],[65.05786154399999,-52.30988477],[65.62230594399999,-51.223329299999996]]);
|
|
cag131 = cag131.appendBezier([[66.316572556,-49.891240515999996],[66.60443919999999,-49.01917391799999],[66.50283920799998,-48.542218399999996]]);
|
|
cag131 = cag131.appendBezier([[66.42099477,-48.15557398599999],[66.4633281,-47.647574026],[66.595972534,-47.4133296]]);
|
|
cag131 = cag131.appendBezier([[66.754016966,-47.139574065999994],[66.64395030799999,-46.64004077199999],[66.288350336,-46.00221859999999]]);
|
|
cag131 = cag131.appendBezier([[65.98355036,-45.45752975399999],[65.56021706,-44.82252980399999],[65.34290596599999,-44.591107599999994]]);
|
|
cag131 = cag131.appendBezier([[65.128417094,-44.359685395999996],[64.634528244,-43.851685436],[64.24788382999999,-43.462218799999995]]);
|
|
cag131 = cag131.appendBezier([[63.861239416,-43.07557438599999],[63.18390613599999,-42.48855221],[62.746461726,-42.15835223599999]]);
|
|
cag131 = cag131.appendBezier([[62.306195093999996,-41.830974483999995],[61.448239605999994,-40.56097458399999],[60.83863965399999,-39.336130235999995]]);
|
|
cag131 = cag131.appendBezier([[60.226217479999995,-38.11410811],[59.33721754999999,-36.623974894],[58.86308425399999,-36.028486052]]);
|
|
cag131 = cag131.appendBezier([[58.38612873599999,-35.430174988],[57.553573246,-34.761308373999995],[57.00888439999999,-34.538352835999994]]);
|
|
cag131 = cag131.appendBezier([[56.467017776,-34.315397298],[55.832017826,-34.143241755999995],[55.597773399999994,-34.151708422]]);
|
|
cag131 = cag131.close();
|
|
cag131 = cag131.innerToCAG();
|
|
cag13 = cag13.union(cag131);
|
|
cag1 = cag1.union(cag13);
|
|
var cag14 = new CAG();
|
|
var cag141 = new CSG.Path2D([[9.383888149999999,-48.25435175599999]],false);
|
|
cag141 = cag141.appendBezier([[9.268177048,-48.25435175599999],[9.008532623999999,-49.428396107999994],[8.80533264,-50.86490710599999]]);
|
|
cag141 = cag141.appendBezier([[8.604954878,-52.304240326],[8.319910455999999,-54.751106799999995],[8.170332689999999,-56.3033289]]);
|
|
cag141 = cag141.appendBezier([[8.023577146,-57.85555099999999],[7.718777169999999,-61.222461845999995],[7.495821631999999,-63.78221719999999]]);
|
|
cag141 = cag141.appendBezier([[7.272866093999999,-66.344794776],[6.953955007999999,-68.788839028],[6.790266131999999,-69.21499454999999]]);
|
|
cag141 = cag141.appendBezier([[6.626577255999999,-69.64115007199999],[6.547555039999999,-70.149150032],[6.615288368,-70.34388335]]);
|
|
cag141 = cag141.appendBezier([[6.685843918,-70.53861666799999],[6.810021685999999,-72.41257207599999],[6.894688345999999,-74.50666079999999]]);
|
|
cag141 = cag141.appendBezier([[6.979355006,-76.603571746],[7.176910545999999,-78.44366048999998],[7.334954977999999,-78.59888269999999]]);
|
|
cag141 = cag141.appendBezier([[7.526866074,-78.787971574],[7.532510518,-79.493527074],[7.354710531999999,-80.7155492]]);
|
|
cag141 = cag141.appendBezier([[7.207954987999999,-81.72590467599998],[7.128932772,-84.20099336999999],[7.182554989999999,-86.21888209999999]]);
|
|
cag141 = cag141.appendBezier([[7.236177207999999,-88.23677082999998],[7.3688216419999994,-90.96868172599999],[7.476066077999999,-92.28665939999999]]);
|
|
cag141 = cag141.appendBezier([[7.586132735999999,-93.60745929599999],[7.961488262,-95.57454802999999],[8.314266012,-96.6611035]]);
|
|
cag141 = cag141.appendBezier([[8.66422154,-97.74765896999999],[9.115777059999997,-98.95556998599999],[9.316154821999998,-99.34221439999999]]);
|
|
cag141 = cag141.appendBezier([[9.519354805999997,-99.73168103599998],[9.970910325999998,-101.19076980999999],[10.320865854,-102.5877697]]);
|
|
cag141 = cag141.appendBezier([[10.670821382,-103.98476958999998],[11.161888009999998,-105.70068056599997],[11.413065767999997,-106.39776939999999]]);
|
|
cag141 = cag141.appendBezier([[11.661421304,-107.09768045599999],[11.861799066,-108.42976923999998],[11.861799066,-109.36110249999999]]);
|
|
cag141 = cag141.appendBezier([[11.858976843999999,-110.29243575999999],[11.983154612,-111.53139121799998],[12.138376821999998,-112.11276894999999]]);
|
|
cag141 = cag141.appendPoint([12.417776799999999,-113.17110219999999]);
|
|
cag141 = cag141.appendPoint([26.811109,-113.17110219999999]);
|
|
cag141 = cag141.appendPoint([41.2044412,-113.17110219999999]);
|
|
cag141 = cag141.appendPoint([41.043574545999995,-110.84276904999999]);
|
|
cag141 = cag141.appendBezier([[40.953263442,-109.56148026199999],[40.71055234999999,-107.75243595999999],[40.504530144,-106.82110269999998]]);
|
|
cag141 = cag141.appendBezier([[40.295685715999994,-105.88976943999998],[40.047330179999996,-103.73076961],[39.94855241,-102.0233253]]);
|
|
cag141 = cag141.appendBezier([[39.852596862,-100.31588098999998],[39.53086355399999,-97.64888119999999],[39.237352466,-96.0966591]]);
|
|
cag141 = cag141.appendBezier([[38.941019155999996,-94.54443699999999],[38.624930292,-92.51243715999999],[38.531796965999995,-91.58110389999999]]);
|
|
cag141 = cag141.appendBezier([[38.435841417999995,-90.64977063999999],[38.221352546,-89.317681856],[38.04919700399999,-88.61777079999999]]);
|
|
cag141 = cag141.appendBezier([[37.87986368399999,-87.91785974399998],[37.820597021999994,-86.74381539199999],[37.919374792,-86.00721544999999]]);
|
|
cag141 = cag141.appendBezier([[38.052019226,-85.02790441599998],[38.362463645999995,-84.381615578],[39.06519692399999,-83.60832674999999]]);
|
|
cag141 = cag141.appendPoint([40.033219069999994,-82.54999349999999]);
|
|
cag141 = cag141.appendPoint([43.933529873999994,-82.59232682999999]);
|
|
cag141 = cag141.appendBezier([[46.081240816,-82.614904606],[47.87335178599999,-82.741904596],[47.915685116,-82.87454902999998]]);
|
|
cag141 = cag141.appendBezier([[47.960840667999996,-83.007193464],[47.65321846999999,-83.62243785999999],[47.235529613999994,-84.2433267]]);
|
|
cag141 = cag141.appendBezier([[46.81784075799999,-84.86421553999999],[46.380396348,-85.81812657599998],[46.267507468,-86.35999319999999]]);
|
|
cag141 = cag141.appendBezier([[46.15179636599999,-86.90468204599999],[45.91755193999999,-88.04768195599999],[45.745396398,-88.899993]]);
|
|
cag141 = cag141.appendBezier([[45.57324085599999,-89.75230404399998],[45.434951978,-90.96021506],[45.43777419999999,-91.58110389999999]]);
|
|
cag141 = cag141.appendBezier([[45.443418644,-92.20199273999998],[45.62404085199999,-93.21799266],[45.841351945999996,-93.83888149999999]]);
|
|
cag141 = cag141.appendBezier([[46.05866303999999,-94.45977033999999],[46.60617410799999,-95.66768135599999],[47.057729628,-96.51999239999999]]);
|
|
cag141 = cag141.appendBezier([[47.509285148,-97.37512566599999],[48.197907316,-98.58021446],[48.59019617399999,-99.20110329999999]]);
|
|
cag141 = cag141.appendBezier([[48.98248503199999,-99.82199213999999],[49.482018325999995,-100.473925422],[49.69932941999999,-100.64890318599998]]);
|
|
cag141 = cag141.appendBezier([[49.916640513999994,-100.82388094999999],[50.41335158599999,-101.06376981999999],[50.79999599999999,-101.18512536599998]]);
|
|
cag141 = cag141.appendBezier([[51.189462635999995,-101.30365868999999],[51.824462585999996,-101.63385866399999],[52.21110699999999,-101.916080864]]);
|
|
cag141 = cag141.appendBezier([[52.60057363599999,-102.19830306399999],[53.61657355599999,-102.60752525399998],[54.468884599999996,-102.82201412599998]]);
|
|
cag141 = cag141.appendBezier([[55.32401786599999,-103.03650299799999],[56.65610664999999,-103.186080764],[57.432217699999995,-103.1522141]]);
|
|
cag141 = cag141.appendBezier([[58.20832874999999,-103.118347436],[59.924239725999996,-102.99981411199998],[61.242217399999994,-102.88410300999999]]);
|
|
cag141 = cag141.appendBezier([[62.563017296,-102.77121412999999],[64.53010603,-102.421258602],[65.61666149999999,-102.10799195999999]]);
|
|
cag141 = cag141.appendBezier([[66.70321696999999,-101.79472531799999],[67.97321686999999,-101.42783645799999],[68.43888349999999,-101.29519202399999]]);
|
|
cag141 = cag141.appendBezier([[68.90455012999999,-101.16254758999999],[69.79355006,-100.71945873599999],[70.4144389,-100.304592102]]);
|
|
cag141 = cag141.appendBezier([[71.03532773999999,-99.89254768999999],[71.92432767,-99.36196995399999],[72.3899943,-99.124903306]]);
|
|
cag141 = cag141.appendBezier([[72.85566092999998,-98.89065887999999],[73.99866083999999,-98.19357004599999],[74.92999409999999,-97.58114787199999]]);
|
|
cag141 = cag141.appendPoint([76.62332729999999,-96.46354796]);
|
|
cag141 = cag141.appendPoint([79.02221599999999,-97.08725902199998]);
|
|
cag141 = cag141.appendPoint([81.42110469999999,-97.710970084]);
|
|
cag141 = cag141.appendPoint([82.654415714,-97.327147892]);
|
|
cag141 = cag141.appendBezier([[83.33457121599999,-97.11548124199999],[83.98932672,-96.81632570999999],[84.10786004399999,-96.6611035]]);
|
|
cag141 = cag141.appendBezier([[84.22921558999998,-96.50588128999999],[84.576348896,-95.61688136],[84.87832664999999,-94.68554809999999]]);
|
|
cag141 = cag141.appendBezier([[85.18030440399998,-93.75421483999999],[85.59234881599998,-92.67612603599999],[85.789904356,-92.28665939999999]]);
|
|
cag141 = cag141.appendBezier([[86.02132655999999,-91.84074832399999],[86.193482102,-90.03170402199999],[86.26685987399999,-87.34777089999999]]);
|
|
cag141 = cag141.appendBezier([[86.334593202,-84.79648221199999],[86.25274876399999,-82.55281572199999],[86.06083766799999,-81.7033269]]);
|
|
cag141 = cag141.appendBezier([[85.88585990399999,-80.92721585],[85.32141550399999,-79.34112708599999],[84.81059332199999,-78.1755494]]);
|
|
cag141 = cag141.appendBezier([[84.29694891799998,-77.012793936],[83.66477118999998,-75.35897184399998],[83.40512676599998,-74.50666079999999]]);
|
|
cag141 = cag141.appendBezier([[83.145482342,-73.654349756],[82.70521570999999,-72.63834983599999],[82.428637954,-72.2488832]]);
|
|
cag141 = cag141.appendBezier([[82.129482422,-71.831194344],[81.42110469999999,-71.407861044],[80.68450475799999,-71.21030550399999]]);
|
|
cag141 = cag141.appendBezier([[80.004349256,-71.02968329599999],[79.174615988,-70.648683326],[78.841593792,-70.36363890399998]]);
|
|
cag141 = cag141.appendBezier([[78.42954937999998,-70.013683376],[78.04854940999999,-69.040016786],[77.64214944199999,-67.30999469999999]]);
|
|
cag141 = cag141.appendBezier([[77.31477168999999,-65.91299481],[77.0466606,-64.42003937199999],[77.0466606,-63.993883849999996]]);
|
|
cag141 = cag141.appendBezier([[77.0466606,-63.567728327999994],[76.91966061,-63.155683915999994],[76.76443839999999,-63.076661699999995]]);
|
|
cag141 = cag141.appendBezier([[76.60921618999998,-63.00046170599999],[76.47939397799999,-62.712595062],[76.47939397799999,-62.441661749999994]]);
|
|
cag141 = cag141.appendBezier([[76.476571756,-62.17072843799999],[76.22257177599998,-61.408728497999995],[75.91494957799999,-60.74832855]]);
|
|
cag141 = cag141.appendBezier([[75.604505158,-60.08792860199999],[75.22632741,-59.548884199999996],[75.07110519999999,-59.548884199999996]]);
|
|
cag141 = cag141.appendBezier([[74.91588298999999,-59.548884199999996],[74.79452744399998,-59.83392862199999],[74.800171888,-60.18388415]]);
|
|
cag141 = cag141.appendBezier([[74.80863855399998,-60.533839678],[74.61108301399999,-61.010795196],[74.36554969999999,-61.242217399999994]]);
|
|
cag141 = cag141.appendBezier([[74.12001638599999,-61.476461826],[73.92810528999999,-61.98446178599999],[73.939394178,-62.37110619999999]]);
|
|
cag141 = cag141.appendBezier([[73.95068306599998,-62.760572835999994],[73.73337197199999,-63.296795016],[73.45679421599999,-63.567728327999994]]);
|
|
cag141 = cag141.appendBezier([[73.18021646,-63.83583941799999],[72.57343872999999,-64.16321717],[72.10777209999999,-64.29303938199999]]);
|
|
cag141 = cag141.appendBezier([[71.50381659199999,-64.462372702],[71.2611055,-64.70508379399999],[71.2611055,-65.13688376]]);
|
|
cag141 = cag141.appendBezier([[71.2611055,-65.46990595599999],[70.976061078,-65.93839480799998],[70.62610554999999,-66.175461456]]);
|
|
cag141 = cag141.appendBezier([[70.276150022,-66.409705882],[69.83306116799999,-66.556461426],[69.63832785,-66.50001698599999]]);
|
|
cag141 = cag141.appendBezier([[69.44359453199999,-66.443572546],[69.096461226,-66.57339475799999],[68.8622168,-66.79070585199999]]);
|
|
cag141 = cag141.appendBezier([[68.630794596,-67.008016946],[67.891372432,-67.214039152],[67.22532804,-67.247905816]]);
|
|
cag141 = cag141.appendBezier([[66.27988366999999,-67.29588358999999],[65.777528154,-67.527305794],[64.96755044,-68.28083906799999]]);
|
|
cag141 = cag141.appendBezier([[64.39181715199999,-68.81706124799999],[63.60723943599999,-69.33352787399998],[63.21777279999999,-69.432305644]]);
|
|
cag141 = cag141.appendBezier([[62.78032838999999,-69.545194524],[62.45295063799999,-69.869750054],[62.359817312,-70.295905576]]);
|
|
cag141 = cag141.appendBezier([[62.23281732199999,-70.84906108799998],[61.98728400799999,-71.00428329799999],[61.04466186,-71.1199944]]);
|
|
cag141 = cag141.appendBezier([[60.40683968799999,-71.199016616],[59.58839530799999,-71.526394368],[59.22432866999999,-71.85377211999999]]);
|
|
cag141 = cag141.appendBezier([[58.860262031999994,-72.17832764999999],[58.02206209799999,-72.655283168],[57.361662149999994,-72.91210536999999]]);
|
|
cag141 = cag141.appendBezier([[56.701262201999995,-73.16892757199999],[55.939262262,-73.374949778],[55.668328949999996,-73.374949778]]);
|
|
cag141 = cag141.appendBezier([[55.39739563799999,-73.372127556],[54.47735126599999,-73.705149752],[53.622218,-74.11437194199999]]);
|
|
cag141 = cag141.appendBezier([[52.43406253799999,-74.68446078599999],[51.40677373,-74.91023854599999],[49.24777389999999,-75.07674964399999]]);
|
|
cag141 = cag141.appendBezier([[47.6955518,-75.19528296799999],[45.91755193999999,-75.22632741],[45.296663099999996,-75.14448297199999]]);
|
|
cag141 = cag141.appendBezier([[44.67577426,-75.062638534],[43.97586320399999,-74.822749664],[43.744440999999995,-74.61108301399999]]);
|
|
cag141 = cag141.appendBezier([[43.386018805999996,-74.28370526199998],[43.13766327,-74.289349706],[42.12166335,-74.6477719]]);
|
|
cag141 = cag141.appendBezier([[41.04921898999999,-75.02594964799998],[40.79521901,-75.02312742599999],[39.72277465,-74.63366079]]);
|
|
cag141 = cag141.appendBezier([[39.06237470199999,-74.39377191999999],[37.572241485999996,-73.68821642],[36.4066638,-73.06450535799999]]);
|
|
cag141 = cag141.appendPoint([34.289997299999996,-71.93279433599999]);
|
|
cag141 = cag141.appendPoint([32.94944185,-72.37306096799999]);
|
|
cag141 = cag141.appendBezier([[32.212841907999994,-72.61577206],[31.323841977999994,-72.8133276],[30.97388645,-72.8133276]]);
|
|
cag141 = cag141.appendBezier([[30.623930922,-72.8133276],[29.576886559999995,-72.30532763999999],[28.645553299999996,-71.6844388]]);
|
|
cag141 = cag141.appendBezier([[27.714220039999997,-71.06354995999999],[26.698220119999995,-70.55837222199999],[26.3877757,-70.55837222199999]]);
|
|
cag141 = cag141.appendBezier([[26.07733128,-70.55837222199999],[25.380242446,-70.26768335599999],[24.835553599999997,-69.91490560599999]]);
|
|
cag141 = cag141.appendBezier([[24.293686975999996,-69.559305634],[23.33977594,-69.099283448],[22.718887099999996,-68.89043901999999]]);
|
|
cag141 = cag141.appendBezier([[22.097998259999997,-68.681594592],[21.400909426,-68.35139461799999],[21.166665,-68.15383907799999]]);
|
|
cag141 = cag141.appendBezier([[20.935242796,-67.95910576],[20.046242865999996,-67.47650579799999],[19.191109599999997,-67.08421693999999]]);
|
|
cag141 = cag141.appendBezier([[18.335976333999998,-66.68910586],[17.480843068,-66.198039232],[17.286109749999998,-65.992017026]]);
|
|
cag141 = cag141.appendBezier([[17.094198654,-65.78599481999998],[16.857132005999997,-64.85466156],[16.761176457999998,-63.923328299999994]]);
|
|
cag141 = cag141.appendBezier([[16.662398688,-62.99199503999999],[16.408398708,-61.944950678],[16.193909836,-61.594995149999995]]);
|
|
cag141 = cag141.appendBezier([[15.883465415999998,-61.08699518999999],[15.620998769999998,-60.98821741999999],[14.887221049999999,-61.098284078]]);
|
|
cag141 = cag141.appendBezier([[14.192954437999997,-61.205528513999994],[13.814776689999999,-61.08417296799999],[13.326532283999999,-60.604395227999994]]);
|
|
cag141 = cag141.appendBezier([[12.973754533999998,-60.25726192199999],[12.688710111999999,-59.687173077999994],[12.691532333999998,-59.33721754999999]]);
|
|
cag141 = cag141.appendBezier([[12.697176778,-58.98726202199999],[12.572999009999998,-58.64012871599999],[12.417776799999999,-58.561106499999994]]);
|
|
cag141 = cag141.appendBezier([[12.262554589999999,-58.484906505999994],[12.135554599999999,-58.03899542999999],[12.135554599999999,-57.57332879999999]]);
|
|
cag141 = cag141.appendBezier([[12.135554599999999,-57.10766216999999],[12.008554609999997,-56.664573315999995],[11.8533324,-56.585551099999996]]);
|
|
cag141 = cag141.appendBezier([[11.69811019,-56.50935110599999],[11.576754644,-56.159395577999994],[11.579576865999998,-55.80944004999999]]);
|
|
cag141 = cag141.appendBezier([[11.585221309999998,-55.45948452199999],[11.342510217999997,-54.85835123599999],[11.037710242,-54.468884599999996]]);
|
|
cag141 = cag141.appendBezier([[10.676465825999998,-54.006040192],[10.566399167999998,-53.61657355599999],[10.721621378,-53.3399958]]);
|
|
cag141 = cag141.appendBezier([[10.857088033999998,-53.09728470799999],[10.831688036,-52.614684745999995],[10.665176937999998,-52.21110699999999]]);
|
|
cag141 = cag141.appendBezier([[10.501488062,-51.824462585999996],[10.385776959999998,-51.06246264599999],[10.408354736,-50.51777379999999]]);
|
|
cag141 = cag141.appendBezier([[10.42811029,-49.975907176],[10.255954748,-49.244951678],[10.021710321999999,-48.89499615]]);
|
|
cag141 = cag141.appendBezier([[9.787465895999999,-48.545040621999995],[9.499599251999998,-48.257173978],[9.383888149999999,-48.25435175599999]]);
|
|
cag141 = cag141.close();
|
|
cag141 = cag141.innerToCAG();
|
|
cag14 = cag14.union(cag141);
|
|
cag1 = cag1.union(cag14);
|
|
var cag15 = new CAG();
|
|
var cag151 = new CSG.Path2D([[41.7688856,-60.166950818]],false);
|
|
cag151 = cag151.appendBezier([[40.761352345999995,-60.189528593999995],[39.491352446,-60.248795255999994],[38.946663599999994,-60.299595251999996]]);
|
|
cag151 = cag151.appendBezier([[38.401974753999994,-60.347573026],[37.800841467999994,-60.581817451999996],[37.60610815,-60.816061878]]);
|
|
cag151 = cag151.appendBezier([[37.329530394,-61.15190629599999],[37.32388595,-61.467995159999994],[37.589174818,-62.30055064999999]]);
|
|
cag151 = cag151.appendBezier([[37.77544147,-62.88192838199999],[38.441485862,-63.841483862],[39.070841367999996,-64.428506038]]);
|
|
cag151 = cag151.appendBezier([[39.70019687399999,-65.01835043599999],[40.312619047999995,-65.49530595399999],[40.428330149999994,-65.48683928799998]]);
|
|
cag151 = cag151.appendBezier([[40.54404125199999,-65.481194844],[41.433041182,-65.966617028],[42.40388555,-66.564928092]]);
|
|
cag151 = cag151.appendBezier([[43.383196584,-67.16888359999999],[44.28066318,-67.95346131599999],[44.421774279999994,-68.328816842]]);
|
|
cag151 = cag151.appendBezier([[44.56288538,-68.69852792399999],[44.59392982199999,-69.226283438],[44.492329829999996,-69.49721674999999]]);
|
|
cag151 = cag151.appendBezier([[44.368152062,-69.830238946],[43.874263211999995,-70.04755003999999],[42.96832995,-70.168905586]]);
|
|
cag151 = cag151.appendBezier([[42.23173000799999,-70.26768335599999],[40.800863453999995,-70.24510558],[39.79333019999999,-70.123750034]]);
|
|
cag151 = cag151.appendBezier([[38.785796946,-69.99957226599999],[37.515797045999996,-69.88668338599999],[36.971108199999996,-69.872572276]]);
|
|
cag151 = cag151.appendBezier([[36.169597151999994,-69.85563894399999],[35.983330499999994,-69.95441671399999],[35.983330499999994,-70.403150012]]);
|
|
cag151 = cag151.appendBezier([[35.983330499999994,-70.81801664599999],[36.262730478,-71.012749964],[37.1122193,-71.193372172]]);
|
|
cag151 = cag151.appendBezier([[37.73310813999999,-71.326016606],[38.418908085999995,-71.58566103],[38.63621918,-71.76910545999999]]);
|
|
cag151 = cag151.appendBezier([[38.924085823999995,-72.01463877399999],[41.14799676,-72.10777209999999],[46.628751883999996,-72.10777209999999]]);
|
|
cag151 = cag151.appendPoint([54.22617350799999,-72.10777209999999]);
|
|
cag151 = cag151.appendPoint([54.70030680399999,-71.59694991799999]);
|
|
cag151 = cag151.appendBezier([[55.070017885999995,-71.199016616],[55.10388455,-70.97888329999999],[54.85835123599999,-70.609172218]]);
|
|
cag151 = cag151.appendBezier([[54.59306236799999,-70.208416694],[54.03144018999999,-70.13221669999999],[51.33057373599999,-70.13221669999999]]);
|
|
cag151 = cag151.appendBezier([[49.563862764,-70.13221669999999],[47.960840667999996,-70.036261152],[47.76610734999999,-69.92055004999999]]);
|
|
cag151 = cag151.appendBezier([[47.571374031999994,-69.804838948],[47.4133296,-69.58188340999999],[47.4133296,-69.4266612]]);
|
|
cag151 = cag151.appendBezier([[47.4133296,-69.27143899],[47.825374012,-68.68441681399999],[48.33055175,-68.122794636]]);
|
|
cag151 = cag151.appendBezier([[48.83572948799999,-67.56117245799999],[50.009773839999994,-66.683461416],[50.941107099999996,-66.17263923399999]]);
|
|
cag151 = cag151.appendBezier([[51.87244036,-65.66181705199999],[53.046484711999994,-64.85183933799999],[53.551662449999995,-64.37206159799999]]);
|
|
cag151 = cag151.appendBezier([[54.339062387999995,-63.624172767999994],[54.457595712,-63.33066167999999],[54.398329049999994,-62.311839537999994]]);
|
|
cag151 = cag151.appendPoint([54.32777349999999,-61.12086185399999]);
|
|
cag151 = cag151.appendPoint([53.3399958,-60.85275076399999]);
|
|
cag151 = cag151.appendBezier([[52.798129175999996,-60.70599521999999],[51.46321816999999,-60.59028411799999],[50.3766627,-60.595928562]]);
|
|
cag151 = cag151.appendBezier([[49.29010723,-60.60157300599999],[47.831018455999995,-60.632617448],[47.1311074,-60.666484112]]);
|
|
cag151 = cag151.appendBezier([[46.434018566,-60.700350776],[45.35310753999999,-60.59028411799999],[44.7322187,-60.426595242]]);
|
|
cag151 = cag151.appendBezier([[44.11132986,-60.262906365999996],[42.77641885399999,-60.144373042],[41.7688856,-60.166950818]]);
|
|
cag151 = cag151.close();
|
|
cag151 = cag151.innerToCAG();
|
|
cag15 = cag15.union(cag151);
|
|
cag1 = cag1.union(cag15);
|
|
var cag00 = cag1;
|
|
cag00 = cag00.scale([0.1,0.1]);
|
|
cag0 = cag0.union(cag00);
|
|
return cag0;
|
|
}
|
|
`
|
|
const observed = deserializer.deserialize(sourceSvg, undefined, {output: 'jscad', addMetaData: false})
|
|
|
|
t.deepEqual(observed, expected)
|
|
})
|
|
|
|
// deserializer
|
|
|
|
test('deserialize svg (rect) to cag/csg objects', function (t) {
|
|
const sourceSvg = `
|
|
<svg xmlns="http://www.w3.org/2000/svg"
|
|
width="467" height="462">
|
|
<rect x="80" y="60" width="250" height="250" rx="20"/>
|
|
<rect x="140" y="120" width="250" height="250" rx="40"/>
|
|
</svg>`
|
|
|
|
// const sourceSvg = fs.readFileSync('PATH/TO/file.svg')
|
|
const observed = deserializer.deserialize(sourceSvg, undefined, {output: 'csg', addMetaData: false})
|
|
t.deepEqual(observed.sides.length, 56)
|
|
})
|
|
|
|
test('deserialize svg (circle) to cag/csg objects', function (t) {
|
|
const sourceSvg = `<svg height="100" width="100">
|
|
<circle cx="50" cy="50" r="40" stroke="black" stroke-width="3" fill="red" />
|
|
</svg>
|
|
`
|
|
|
|
const observed = deserializer.deserialize(sourceSvg, undefined, {output: 'csg', addMetaData: false})
|
|
t.deepEqual(observed.sides.length, 32)
|
|
})
|
|
|
|
test('deserialize svg (ellipse) to cag/csg objects', function (t) {
|
|
const sourceSvg = `<svg width="120" height="120" viewBox="0 0 120 120"
|
|
xmlns="http://www.w3.org/2000/svg">
|
|
|
|
<ellipse cx="60" cy="60" rx="50" ry="25"/>
|
|
</svg>
|
|
`
|
|
|
|
const observed = deserializer.deserialize(sourceSvg, undefined, {output: 'csg', addMetaData: false})
|
|
t.deepEqual(observed.sides.length, 34)
|
|
})
|
|
|
|
test('deserialize svg (polyline) to cag/csg objects', function (t) {
|
|
const sourceSvg = `
|
|
<svg width="120" height="120" xmlns="http://www.w3.org/2000/svg">
|
|
<polyline fill="none" stroke="black"
|
|
points="20,100 40,60 70,80 100,20"/>
|
|
</svg>`
|
|
|
|
const observed = deserializer.deserialize(sourceSvg, undefined, {output: 'csg', addMetaData: false})
|
|
t.deepEqual(observed.sides.length, 62)
|
|
})
|
|
|
|
test('deserialize svg (polygon) to cag/csg objects', function (t) {
|
|
const sourceSvg = `<svg width="120" height="120" viewBox="0 0 120 120"
|
|
xmlns="http://www.w3.org/2000/svg">
|
|
|
|
<polygon points="60,20 100,40 100,80 60,100 20,80 20,40"/>
|
|
</svg>`
|
|
|
|
const observed = deserializer.deserialize(sourceSvg, undefined, {output: 'csg', addMetaData: false})
|
|
t.deepEqual(observed.sides.length, 6)
|
|
})
|
|
|
|
test('deserialize svg (line) to cag/csg objects', function (t) {
|
|
const sourceSvg = `<svg width="120" height="120" viewBox="0 0 120 120"
|
|
xmlns="http://www.w3.org/2000/svg">
|
|
|
|
<line x1="20" y1="100" x2="100" y2="20"
|
|
stroke-width="2" stroke="black"/>
|
|
</svg>
|
|
`
|
|
|
|
const observed = deserializer.deserialize(sourceSvg, undefined, {output: 'csg', addMetaData: false})
|
|
t.deepEqual(observed.sides.length, 34)
|
|
})
|
|
|
|
test('deserialize svg (path: simple) to cag/csg objects', function (t) {
|
|
const sourceSvg = `<svg height="210" width="400">
|
|
<path d="M150 0 L75 200 L225 200 Z" />
|
|
</svg>
|
|
`
|
|
|
|
const observed = deserializer.deserialize(sourceSvg, undefined, {output: 'csg', addMetaData: false})
|
|
t.deepEqual(observed.sides.length, 3)
|
|
})
|
|
|
|
test('deserialize svg (path: with bezier) to cag/csg objects', function (t) {
|
|
const sourceSvg = `
|
|
<svg height="210" width="400">
|
|
<path d="M100,100
|
|
L150,100
|
|
a50,25 0 0,0 150,100
|
|
q50,-50 70,-170
|
|
Z"
|
|
style="stroke: #006666; fill: none;"/>
|
|
</svg>
|
|
`
|
|
|
|
const observed = deserializer.deserialize(sourceSvg, undefined, {output: 'csg', addMetaData: false})
|
|
t.deepEqual(observed.sides.length, 16)
|
|
})
|