schematic-symbols 0.0.11 → 0.0.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/dist/index.cjs +2129 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +17 -1
- package/drawing/getSvg.ts +16 -10
- package/index.ts +3 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
@@ -1,8 +1,13 @@
|
|
1
1
|
"use strict";
|
2
|
+
var __create = Object.create;
|
2
3
|
var __defProp = Object.defineProperty;
|
3
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
4
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
5
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
8
|
+
var __commonJS = (cb, mod) => function __require() {
|
9
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
10
|
+
};
|
6
11
|
var __export = (target, all) => {
|
7
12
|
for (var name in all)
|
8
13
|
__defProp(target, name, { get: all[name], enumerable: true });
|
@@ -15,12 +20,1945 @@ var __copyProps = (to, from, except, desc) => {
|
|
15
20
|
}
|
16
21
|
return to;
|
17
22
|
};
|
23
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
24
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
25
|
+
// file that has been converted to a CommonJS file using a Babel-
|
26
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
27
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
28
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
29
|
+
mod
|
30
|
+
));
|
18
31
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
19
32
|
|
33
|
+
// node_modules/svg-path-parser/parser.js
|
34
|
+
var require_parser = __commonJS({
|
35
|
+
"node_modules/svg-path-parser/parser.js"(exports2, module2) {
|
36
|
+
"use strict";
|
37
|
+
function peg$subclass2(child, parent) {
|
38
|
+
function ctor() {
|
39
|
+
this.constructor = child;
|
40
|
+
}
|
41
|
+
ctor.prototype = parent.prototype;
|
42
|
+
child.prototype = new ctor();
|
43
|
+
}
|
44
|
+
function peg$SyntaxError2(message, expected, found, location) {
|
45
|
+
this.message = message;
|
46
|
+
this.expected = expected;
|
47
|
+
this.found = found;
|
48
|
+
this.location = location;
|
49
|
+
this.name = "SyntaxError";
|
50
|
+
if (typeof Error.captureStackTrace === "function") {
|
51
|
+
Error.captureStackTrace(this, peg$SyntaxError2);
|
52
|
+
}
|
53
|
+
}
|
54
|
+
peg$subclass2(peg$SyntaxError2, Error);
|
55
|
+
peg$SyntaxError2.buildMessage = function(expected, found) {
|
56
|
+
var DESCRIBE_EXPECTATION_FNS = {
|
57
|
+
literal: function(expectation) {
|
58
|
+
return '"' + literalEscape(expectation.text) + '"';
|
59
|
+
},
|
60
|
+
"class": function(expectation) {
|
61
|
+
var escapedParts = "", i;
|
62
|
+
for (i = 0; i < expectation.parts.length; i++) {
|
63
|
+
escapedParts += expectation.parts[i] instanceof Array ? classEscape(expectation.parts[i][0]) + "-" + classEscape(expectation.parts[i][1]) : classEscape(expectation.parts[i]);
|
64
|
+
}
|
65
|
+
return "[" + (expectation.inverted ? "^" : "") + escapedParts + "]";
|
66
|
+
},
|
67
|
+
any: function(expectation) {
|
68
|
+
return "any character";
|
69
|
+
},
|
70
|
+
end: function(expectation) {
|
71
|
+
return "end of input";
|
72
|
+
},
|
73
|
+
other: function(expectation) {
|
74
|
+
return expectation.description;
|
75
|
+
}
|
76
|
+
};
|
77
|
+
function hex(ch) {
|
78
|
+
return ch.charCodeAt(0).toString(16).toUpperCase();
|
79
|
+
}
|
80
|
+
function literalEscape(s) {
|
81
|
+
return s.replace(/\\/g, "\\\\").replace(/"/g, '\\"').replace(/\0/g, "\\0").replace(/\t/g, "\\t").replace(/\n/g, "\\n").replace(/\r/g, "\\r").replace(/[\x00-\x0F]/g, function(ch) {
|
82
|
+
return "\\x0" + hex(ch);
|
83
|
+
}).replace(/[\x10-\x1F\x7F-\x9F]/g, function(ch) {
|
84
|
+
return "\\x" + hex(ch);
|
85
|
+
});
|
86
|
+
}
|
87
|
+
function classEscape(s) {
|
88
|
+
return s.replace(/\\/g, "\\\\").replace(/\]/g, "\\]").replace(/\^/g, "\\^").replace(/-/g, "\\-").replace(/\0/g, "\\0").replace(/\t/g, "\\t").replace(/\n/g, "\\n").replace(/\r/g, "\\r").replace(/[\x00-\x0F]/g, function(ch) {
|
89
|
+
return "\\x0" + hex(ch);
|
90
|
+
}).replace(/[\x10-\x1F\x7F-\x9F]/g, function(ch) {
|
91
|
+
return "\\x" + hex(ch);
|
92
|
+
});
|
93
|
+
}
|
94
|
+
function describeExpectation(expectation) {
|
95
|
+
return DESCRIBE_EXPECTATION_FNS[expectation.type](expectation);
|
96
|
+
}
|
97
|
+
function describeExpected(expected2) {
|
98
|
+
var descriptions = new Array(expected2.length), i, j;
|
99
|
+
for (i = 0; i < expected2.length; i++) {
|
100
|
+
descriptions[i] = describeExpectation(expected2[i]);
|
101
|
+
}
|
102
|
+
descriptions.sort();
|
103
|
+
if (descriptions.length > 0) {
|
104
|
+
for (i = 1, j = 1; i < descriptions.length; i++) {
|
105
|
+
if (descriptions[i - 1] !== descriptions[i]) {
|
106
|
+
descriptions[j] = descriptions[i];
|
107
|
+
j++;
|
108
|
+
}
|
109
|
+
}
|
110
|
+
descriptions.length = j;
|
111
|
+
}
|
112
|
+
switch (descriptions.length) {
|
113
|
+
case 1:
|
114
|
+
return descriptions[0];
|
115
|
+
case 2:
|
116
|
+
return descriptions[0] + " or " + descriptions[1];
|
117
|
+
default:
|
118
|
+
return descriptions.slice(0, -1).join(", ") + ", or " + descriptions[descriptions.length - 1];
|
119
|
+
}
|
120
|
+
}
|
121
|
+
function describeFound(found2) {
|
122
|
+
return found2 ? '"' + literalEscape(found2) + '"' : "end of input";
|
123
|
+
}
|
124
|
+
return "Expected " + describeExpected(expected) + " but " + describeFound(found) + " found.";
|
125
|
+
};
|
126
|
+
function peg$parse2(input, options) {
|
127
|
+
options = options !== void 0 ? options : {};
|
128
|
+
var peg$FAILED = {}, peg$startRuleFunctions = { svg_path: peg$parsesvg_path }, peg$startRuleFunction = peg$parsesvg_path, peg$c0 = function(data) {
|
129
|
+
if (!data) return [];
|
130
|
+
for (var cmds2 = [], i = 0; i < data.length; i++) cmds2 = cmds2.concat.apply(cmds2, data[i]);
|
131
|
+
var first = cmds2[0];
|
132
|
+
if (first && first.code == "m") {
|
133
|
+
delete first.relative;
|
134
|
+
first.code = "M";
|
135
|
+
}
|
136
|
+
return cmds2;
|
137
|
+
}, peg$c1 = function(first, more) {
|
138
|
+
return merge(first, more);
|
139
|
+
}, peg$c2 = /^[Mm]/, peg$c3 = peg$classExpectation(["M", "m"], false, false), peg$c4 = function(c, first, more) {
|
140
|
+
var move = commands(c, [first]);
|
141
|
+
if (more) move = move.concat(commands(c == "M" ? "L" : "l", more[1]));
|
142
|
+
return move;
|
143
|
+
}, peg$c5 = /^[Zz]/, peg$c6 = peg$classExpectation(["Z", "z"], false, false), peg$c7 = function() {
|
144
|
+
return commands("Z");
|
145
|
+
}, peg$c8 = /^[Ll]/, peg$c9 = peg$classExpectation(["L", "l"], false, false), peg$c10 = function(c, args) {
|
146
|
+
return commands(c, args);
|
147
|
+
}, peg$c11 = /^[Hh]/, peg$c12 = peg$classExpectation(["H", "h"], false, false), peg$c13 = function(c, args) {
|
148
|
+
return commands(c, args.map(function(x) {
|
149
|
+
return { x };
|
150
|
+
}));
|
151
|
+
}, peg$c14 = /^[Vv]/, peg$c15 = peg$classExpectation(["V", "v"], false, false), peg$c16 = function(c, args) {
|
152
|
+
return commands(c, args.map(function(y) {
|
153
|
+
return { y };
|
154
|
+
}));
|
155
|
+
}, peg$c17 = /^[Cc]/, peg$c18 = peg$classExpectation(["C", "c"], false, false), peg$c19 = function(a, b, c) {
|
156
|
+
return { x1: a.x, y1: a.y, x2: b.x, y2: b.y, x: c.x, y: c.y };
|
157
|
+
}, peg$c20 = /^[Ss]/, peg$c21 = peg$classExpectation(["S", "s"], false, false), peg$c22 = function(b, c) {
|
158
|
+
return { x2: b.x, y2: b.y, x: c.x, y: c.y };
|
159
|
+
}, peg$c23 = /^[Qq]/, peg$c24 = peg$classExpectation(["Q", "q"], false, false), peg$c25 = function(a, b) {
|
160
|
+
return { x1: a.x, y1: a.y, x: b.x, y: b.y };
|
161
|
+
}, peg$c26 = /^[Tt]/, peg$c27 = peg$classExpectation(["T", "t"], false, false), peg$c28 = /^[Aa]/, peg$c29 = peg$classExpectation(["A", "a"], false, false), peg$c30 = function(rx, ry, xrot, large, sweep, xy) {
|
162
|
+
return { rx, ry, xAxisRotation: xrot, largeArc: large, sweep, x: xy.x, y: xy.y };
|
163
|
+
}, peg$c31 = function(x, y) {
|
164
|
+
return { x, y };
|
165
|
+
}, peg$c32 = function(n) {
|
166
|
+
return n * 1;
|
167
|
+
}, peg$c33 = function(parts) {
|
168
|
+
return parts.join("") * 1;
|
169
|
+
}, peg$c34 = /^[01]/, peg$c35 = peg$classExpectation(["0", "1"], false, false), peg$c36 = function(bit) {
|
170
|
+
return bit == "1";
|
171
|
+
}, peg$c37 = function() {
|
172
|
+
return "";
|
173
|
+
}, peg$c38 = ",", peg$c39 = peg$literalExpectation(",", false), peg$c40 = function(parts) {
|
174
|
+
return parts.join("");
|
175
|
+
}, peg$c41 = ".", peg$c42 = peg$literalExpectation(".", false), peg$c43 = /^[eE]/, peg$c44 = peg$classExpectation(["e", "E"], false, false), peg$c45 = /^[+\-]/, peg$c46 = peg$classExpectation(["+", "-"], false, false), peg$c47 = /^[0-9]/, peg$c48 = peg$classExpectation([["0", "9"]], false, false), peg$c49 = function(digits) {
|
176
|
+
return digits.join("");
|
177
|
+
}, peg$c50 = /^[ \t\n\r]/, peg$c51 = peg$classExpectation([" ", " ", "\n", "\r"], false, false), peg$currPos = 0, peg$savedPos = 0, peg$posDetailsCache = [{ line: 1, column: 1 }], peg$maxFailPos = 0, peg$maxFailExpected = [], peg$silentFails = 0, peg$result;
|
178
|
+
if ("startRule" in options) {
|
179
|
+
if (!(options.startRule in peg$startRuleFunctions)) {
|
180
|
+
throw new Error(`Can't start parsing from rule "` + options.startRule + '".');
|
181
|
+
}
|
182
|
+
peg$startRuleFunction = peg$startRuleFunctions[options.startRule];
|
183
|
+
}
|
184
|
+
function text2() {
|
185
|
+
return input.substring(peg$savedPos, peg$currPos);
|
186
|
+
}
|
187
|
+
function location() {
|
188
|
+
return peg$computeLocation(peg$savedPos, peg$currPos);
|
189
|
+
}
|
190
|
+
function expected(description, location2) {
|
191
|
+
location2 = location2 !== void 0 ? location2 : peg$computeLocation(peg$savedPos, peg$currPos);
|
192
|
+
throw peg$buildStructuredError(
|
193
|
+
[peg$otherExpectation(description)],
|
194
|
+
input.substring(peg$savedPos, peg$currPos),
|
195
|
+
location2
|
196
|
+
);
|
197
|
+
}
|
198
|
+
function error(message, location2) {
|
199
|
+
location2 = location2 !== void 0 ? location2 : peg$computeLocation(peg$savedPos, peg$currPos);
|
200
|
+
throw peg$buildSimpleError(message, location2);
|
201
|
+
}
|
202
|
+
function peg$literalExpectation(text3, ignoreCase) {
|
203
|
+
return { type: "literal", text: text3, ignoreCase };
|
204
|
+
}
|
205
|
+
function peg$classExpectation(parts, inverted, ignoreCase) {
|
206
|
+
return { type: "class", parts, inverted, ignoreCase };
|
207
|
+
}
|
208
|
+
function peg$anyExpectation() {
|
209
|
+
return { type: "any" };
|
210
|
+
}
|
211
|
+
function peg$endExpectation() {
|
212
|
+
return { type: "end" };
|
213
|
+
}
|
214
|
+
function peg$otherExpectation(description) {
|
215
|
+
return { type: "other", description };
|
216
|
+
}
|
217
|
+
function peg$computePosDetails(pos) {
|
218
|
+
var details = peg$posDetailsCache[pos], p;
|
219
|
+
if (details) {
|
220
|
+
return details;
|
221
|
+
} else {
|
222
|
+
p = pos - 1;
|
223
|
+
while (!peg$posDetailsCache[p]) {
|
224
|
+
p--;
|
225
|
+
}
|
226
|
+
details = peg$posDetailsCache[p];
|
227
|
+
details = {
|
228
|
+
line: details.line,
|
229
|
+
column: details.column
|
230
|
+
};
|
231
|
+
while (p < pos) {
|
232
|
+
if (input.charCodeAt(p) === 10) {
|
233
|
+
details.line++;
|
234
|
+
details.column = 1;
|
235
|
+
} else {
|
236
|
+
details.column++;
|
237
|
+
}
|
238
|
+
p++;
|
239
|
+
}
|
240
|
+
peg$posDetailsCache[pos] = details;
|
241
|
+
return details;
|
242
|
+
}
|
243
|
+
}
|
244
|
+
function peg$computeLocation(startPos, endPos) {
|
245
|
+
var startPosDetails = peg$computePosDetails(startPos), endPosDetails = peg$computePosDetails(endPos);
|
246
|
+
return {
|
247
|
+
start: {
|
248
|
+
offset: startPos,
|
249
|
+
line: startPosDetails.line,
|
250
|
+
column: startPosDetails.column
|
251
|
+
},
|
252
|
+
end: {
|
253
|
+
offset: endPos,
|
254
|
+
line: endPosDetails.line,
|
255
|
+
column: endPosDetails.column
|
256
|
+
}
|
257
|
+
};
|
258
|
+
}
|
259
|
+
function peg$fail(expected2) {
|
260
|
+
if (peg$currPos < peg$maxFailPos) {
|
261
|
+
return;
|
262
|
+
}
|
263
|
+
if (peg$currPos > peg$maxFailPos) {
|
264
|
+
peg$maxFailPos = peg$currPos;
|
265
|
+
peg$maxFailExpected = [];
|
266
|
+
}
|
267
|
+
peg$maxFailExpected.push(expected2);
|
268
|
+
}
|
269
|
+
function peg$buildSimpleError(message, location2) {
|
270
|
+
return new peg$SyntaxError2(message, null, null, location2);
|
271
|
+
}
|
272
|
+
function peg$buildStructuredError(expected2, found, location2) {
|
273
|
+
return new peg$SyntaxError2(
|
274
|
+
peg$SyntaxError2.buildMessage(expected2, found),
|
275
|
+
expected2,
|
276
|
+
found,
|
277
|
+
location2
|
278
|
+
);
|
279
|
+
}
|
280
|
+
function peg$parsesvg_path() {
|
281
|
+
var s0, s1, s2, s3, s4;
|
282
|
+
s0 = peg$currPos;
|
283
|
+
s1 = [];
|
284
|
+
s2 = peg$parsewsp();
|
285
|
+
while (s2 !== peg$FAILED) {
|
286
|
+
s1.push(s2);
|
287
|
+
s2 = peg$parsewsp();
|
288
|
+
}
|
289
|
+
if (s1 !== peg$FAILED) {
|
290
|
+
s2 = peg$parsemoveTo_drawTo_commandGroups();
|
291
|
+
if (s2 === peg$FAILED) {
|
292
|
+
s2 = null;
|
293
|
+
}
|
294
|
+
if (s2 !== peg$FAILED) {
|
295
|
+
s3 = [];
|
296
|
+
s4 = peg$parsewsp();
|
297
|
+
while (s4 !== peg$FAILED) {
|
298
|
+
s3.push(s4);
|
299
|
+
s4 = peg$parsewsp();
|
300
|
+
}
|
301
|
+
if (s3 !== peg$FAILED) {
|
302
|
+
peg$savedPos = s0;
|
303
|
+
s1 = peg$c0(s2);
|
304
|
+
s0 = s1;
|
305
|
+
} else {
|
306
|
+
peg$currPos = s0;
|
307
|
+
s0 = peg$FAILED;
|
308
|
+
}
|
309
|
+
} else {
|
310
|
+
peg$currPos = s0;
|
311
|
+
s0 = peg$FAILED;
|
312
|
+
}
|
313
|
+
} else {
|
314
|
+
peg$currPos = s0;
|
315
|
+
s0 = peg$FAILED;
|
316
|
+
}
|
317
|
+
return s0;
|
318
|
+
}
|
319
|
+
function peg$parsemoveTo_drawTo_commandGroups() {
|
320
|
+
var s0, s1, s2, s3, s4, s5;
|
321
|
+
s0 = peg$currPos;
|
322
|
+
s1 = peg$parsemoveTo_drawTo_commandGroup();
|
323
|
+
if (s1 !== peg$FAILED) {
|
324
|
+
s2 = [];
|
325
|
+
s3 = peg$currPos;
|
326
|
+
s4 = [];
|
327
|
+
s5 = peg$parsewsp();
|
328
|
+
while (s5 !== peg$FAILED) {
|
329
|
+
s4.push(s5);
|
330
|
+
s5 = peg$parsewsp();
|
331
|
+
}
|
332
|
+
if (s4 !== peg$FAILED) {
|
333
|
+
s5 = peg$parsemoveTo_drawTo_commandGroup();
|
334
|
+
if (s5 !== peg$FAILED) {
|
335
|
+
s4 = [s4, s5];
|
336
|
+
s3 = s4;
|
337
|
+
} else {
|
338
|
+
peg$currPos = s3;
|
339
|
+
s3 = peg$FAILED;
|
340
|
+
}
|
341
|
+
} else {
|
342
|
+
peg$currPos = s3;
|
343
|
+
s3 = peg$FAILED;
|
344
|
+
}
|
345
|
+
while (s3 !== peg$FAILED) {
|
346
|
+
s2.push(s3);
|
347
|
+
s3 = peg$currPos;
|
348
|
+
s4 = [];
|
349
|
+
s5 = peg$parsewsp();
|
350
|
+
while (s5 !== peg$FAILED) {
|
351
|
+
s4.push(s5);
|
352
|
+
s5 = peg$parsewsp();
|
353
|
+
}
|
354
|
+
if (s4 !== peg$FAILED) {
|
355
|
+
s5 = peg$parsemoveTo_drawTo_commandGroup();
|
356
|
+
if (s5 !== peg$FAILED) {
|
357
|
+
s4 = [s4, s5];
|
358
|
+
s3 = s4;
|
359
|
+
} else {
|
360
|
+
peg$currPos = s3;
|
361
|
+
s3 = peg$FAILED;
|
362
|
+
}
|
363
|
+
} else {
|
364
|
+
peg$currPos = s3;
|
365
|
+
s3 = peg$FAILED;
|
366
|
+
}
|
367
|
+
}
|
368
|
+
if (s2 !== peg$FAILED) {
|
369
|
+
peg$savedPos = s0;
|
370
|
+
s1 = peg$c1(s1, s2);
|
371
|
+
s0 = s1;
|
372
|
+
} else {
|
373
|
+
peg$currPos = s0;
|
374
|
+
s0 = peg$FAILED;
|
375
|
+
}
|
376
|
+
} else {
|
377
|
+
peg$currPos = s0;
|
378
|
+
s0 = peg$FAILED;
|
379
|
+
}
|
380
|
+
return s0;
|
381
|
+
}
|
382
|
+
function peg$parsemoveTo_drawTo_commandGroup() {
|
383
|
+
var s0, s1, s2, s3, s4, s5;
|
384
|
+
s0 = peg$currPos;
|
385
|
+
s1 = peg$parsemoveto();
|
386
|
+
if (s1 !== peg$FAILED) {
|
387
|
+
s2 = [];
|
388
|
+
s3 = peg$currPos;
|
389
|
+
s4 = [];
|
390
|
+
s5 = peg$parsewsp();
|
391
|
+
while (s5 !== peg$FAILED) {
|
392
|
+
s4.push(s5);
|
393
|
+
s5 = peg$parsewsp();
|
394
|
+
}
|
395
|
+
if (s4 !== peg$FAILED) {
|
396
|
+
s5 = peg$parsedrawto_command();
|
397
|
+
if (s5 !== peg$FAILED) {
|
398
|
+
s4 = [s4, s5];
|
399
|
+
s3 = s4;
|
400
|
+
} else {
|
401
|
+
peg$currPos = s3;
|
402
|
+
s3 = peg$FAILED;
|
403
|
+
}
|
404
|
+
} else {
|
405
|
+
peg$currPos = s3;
|
406
|
+
s3 = peg$FAILED;
|
407
|
+
}
|
408
|
+
while (s3 !== peg$FAILED) {
|
409
|
+
s2.push(s3);
|
410
|
+
s3 = peg$currPos;
|
411
|
+
s4 = [];
|
412
|
+
s5 = peg$parsewsp();
|
413
|
+
while (s5 !== peg$FAILED) {
|
414
|
+
s4.push(s5);
|
415
|
+
s5 = peg$parsewsp();
|
416
|
+
}
|
417
|
+
if (s4 !== peg$FAILED) {
|
418
|
+
s5 = peg$parsedrawto_command();
|
419
|
+
if (s5 !== peg$FAILED) {
|
420
|
+
s4 = [s4, s5];
|
421
|
+
s3 = s4;
|
422
|
+
} else {
|
423
|
+
peg$currPos = s3;
|
424
|
+
s3 = peg$FAILED;
|
425
|
+
}
|
426
|
+
} else {
|
427
|
+
peg$currPos = s3;
|
428
|
+
s3 = peg$FAILED;
|
429
|
+
}
|
430
|
+
}
|
431
|
+
if (s2 !== peg$FAILED) {
|
432
|
+
peg$savedPos = s0;
|
433
|
+
s1 = peg$c1(s1, s2);
|
434
|
+
s0 = s1;
|
435
|
+
} else {
|
436
|
+
peg$currPos = s0;
|
437
|
+
s0 = peg$FAILED;
|
438
|
+
}
|
439
|
+
} else {
|
440
|
+
peg$currPos = s0;
|
441
|
+
s0 = peg$FAILED;
|
442
|
+
}
|
443
|
+
return s0;
|
444
|
+
}
|
445
|
+
function peg$parsedrawto_command() {
|
446
|
+
var s0;
|
447
|
+
s0 = peg$parseclosepath();
|
448
|
+
if (s0 === peg$FAILED) {
|
449
|
+
s0 = peg$parselineto();
|
450
|
+
if (s0 === peg$FAILED) {
|
451
|
+
s0 = peg$parsehorizontal_lineto();
|
452
|
+
if (s0 === peg$FAILED) {
|
453
|
+
s0 = peg$parsevertical_lineto();
|
454
|
+
if (s0 === peg$FAILED) {
|
455
|
+
s0 = peg$parsecurveto();
|
456
|
+
if (s0 === peg$FAILED) {
|
457
|
+
s0 = peg$parsesmooth_curveto();
|
458
|
+
if (s0 === peg$FAILED) {
|
459
|
+
s0 = peg$parsequadratic_bezier_curveto();
|
460
|
+
if (s0 === peg$FAILED) {
|
461
|
+
s0 = peg$parsesmooth_quadratic_bezier_curveto();
|
462
|
+
if (s0 === peg$FAILED) {
|
463
|
+
s0 = peg$parseelliptical_arc();
|
464
|
+
}
|
465
|
+
}
|
466
|
+
}
|
467
|
+
}
|
468
|
+
}
|
469
|
+
}
|
470
|
+
}
|
471
|
+
}
|
472
|
+
return s0;
|
473
|
+
}
|
474
|
+
function peg$parsemoveto() {
|
475
|
+
var s0, s1, s2, s3, s4, s5, s6;
|
476
|
+
s0 = peg$currPos;
|
477
|
+
if (peg$c2.test(input.charAt(peg$currPos))) {
|
478
|
+
s1 = input.charAt(peg$currPos);
|
479
|
+
peg$currPos++;
|
480
|
+
} else {
|
481
|
+
s1 = peg$FAILED;
|
482
|
+
if (peg$silentFails === 0) {
|
483
|
+
peg$fail(peg$c3);
|
484
|
+
}
|
485
|
+
}
|
486
|
+
if (s1 !== peg$FAILED) {
|
487
|
+
s2 = [];
|
488
|
+
s3 = peg$parsewsp();
|
489
|
+
while (s3 !== peg$FAILED) {
|
490
|
+
s2.push(s3);
|
491
|
+
s3 = peg$parsewsp();
|
492
|
+
}
|
493
|
+
if (s2 !== peg$FAILED) {
|
494
|
+
s3 = peg$parsecoordinate_pair();
|
495
|
+
if (s3 !== peg$FAILED) {
|
496
|
+
s4 = peg$currPos;
|
497
|
+
s5 = peg$parsecomma_wsp();
|
498
|
+
if (s5 === peg$FAILED) {
|
499
|
+
s5 = null;
|
500
|
+
}
|
501
|
+
if (s5 !== peg$FAILED) {
|
502
|
+
s6 = peg$parselineto_argument_sequence();
|
503
|
+
if (s6 !== peg$FAILED) {
|
504
|
+
s5 = [s5, s6];
|
505
|
+
s4 = s5;
|
506
|
+
} else {
|
507
|
+
peg$currPos = s4;
|
508
|
+
s4 = peg$FAILED;
|
509
|
+
}
|
510
|
+
} else {
|
511
|
+
peg$currPos = s4;
|
512
|
+
s4 = peg$FAILED;
|
513
|
+
}
|
514
|
+
if (s4 === peg$FAILED) {
|
515
|
+
s4 = null;
|
516
|
+
}
|
517
|
+
if (s4 !== peg$FAILED) {
|
518
|
+
peg$savedPos = s0;
|
519
|
+
s1 = peg$c4(s1, s3, s4);
|
520
|
+
s0 = s1;
|
521
|
+
} else {
|
522
|
+
peg$currPos = s0;
|
523
|
+
s0 = peg$FAILED;
|
524
|
+
}
|
525
|
+
} else {
|
526
|
+
peg$currPos = s0;
|
527
|
+
s0 = peg$FAILED;
|
528
|
+
}
|
529
|
+
} else {
|
530
|
+
peg$currPos = s0;
|
531
|
+
s0 = peg$FAILED;
|
532
|
+
}
|
533
|
+
} else {
|
534
|
+
peg$currPos = s0;
|
535
|
+
s0 = peg$FAILED;
|
536
|
+
}
|
537
|
+
return s0;
|
538
|
+
}
|
539
|
+
function peg$parseclosepath() {
|
540
|
+
var s0, s1;
|
541
|
+
s0 = peg$currPos;
|
542
|
+
if (peg$c5.test(input.charAt(peg$currPos))) {
|
543
|
+
s1 = input.charAt(peg$currPos);
|
544
|
+
peg$currPos++;
|
545
|
+
} else {
|
546
|
+
s1 = peg$FAILED;
|
547
|
+
if (peg$silentFails === 0) {
|
548
|
+
peg$fail(peg$c6);
|
549
|
+
}
|
550
|
+
}
|
551
|
+
if (s1 !== peg$FAILED) {
|
552
|
+
peg$savedPos = s0;
|
553
|
+
s1 = peg$c7();
|
554
|
+
}
|
555
|
+
s0 = s1;
|
556
|
+
return s0;
|
557
|
+
}
|
558
|
+
function peg$parselineto() {
|
559
|
+
var s0, s1, s2, s3;
|
560
|
+
s0 = peg$currPos;
|
561
|
+
if (peg$c8.test(input.charAt(peg$currPos))) {
|
562
|
+
s1 = input.charAt(peg$currPos);
|
563
|
+
peg$currPos++;
|
564
|
+
} else {
|
565
|
+
s1 = peg$FAILED;
|
566
|
+
if (peg$silentFails === 0) {
|
567
|
+
peg$fail(peg$c9);
|
568
|
+
}
|
569
|
+
}
|
570
|
+
if (s1 !== peg$FAILED) {
|
571
|
+
s2 = [];
|
572
|
+
s3 = peg$parsewsp();
|
573
|
+
while (s3 !== peg$FAILED) {
|
574
|
+
s2.push(s3);
|
575
|
+
s3 = peg$parsewsp();
|
576
|
+
}
|
577
|
+
if (s2 !== peg$FAILED) {
|
578
|
+
s3 = peg$parselineto_argument_sequence();
|
579
|
+
if (s3 !== peg$FAILED) {
|
580
|
+
peg$savedPos = s0;
|
581
|
+
s1 = peg$c10(s1, s3);
|
582
|
+
s0 = s1;
|
583
|
+
} else {
|
584
|
+
peg$currPos = s0;
|
585
|
+
s0 = peg$FAILED;
|
586
|
+
}
|
587
|
+
} else {
|
588
|
+
peg$currPos = s0;
|
589
|
+
s0 = peg$FAILED;
|
590
|
+
}
|
591
|
+
} else {
|
592
|
+
peg$currPos = s0;
|
593
|
+
s0 = peg$FAILED;
|
594
|
+
}
|
595
|
+
return s0;
|
596
|
+
}
|
597
|
+
function peg$parselineto_argument_sequence() {
|
598
|
+
var s0, s1, s2, s3, s4, s5;
|
599
|
+
s0 = peg$currPos;
|
600
|
+
s1 = peg$parsecoordinate_pair();
|
601
|
+
if (s1 !== peg$FAILED) {
|
602
|
+
s2 = [];
|
603
|
+
s3 = peg$currPos;
|
604
|
+
s4 = peg$parsecomma_wsp();
|
605
|
+
if (s4 === peg$FAILED) {
|
606
|
+
s4 = null;
|
607
|
+
}
|
608
|
+
if (s4 !== peg$FAILED) {
|
609
|
+
s5 = peg$parsecoordinate_pair();
|
610
|
+
if (s5 !== peg$FAILED) {
|
611
|
+
s4 = [s4, s5];
|
612
|
+
s3 = s4;
|
613
|
+
} else {
|
614
|
+
peg$currPos = s3;
|
615
|
+
s3 = peg$FAILED;
|
616
|
+
}
|
617
|
+
} else {
|
618
|
+
peg$currPos = s3;
|
619
|
+
s3 = peg$FAILED;
|
620
|
+
}
|
621
|
+
while (s3 !== peg$FAILED) {
|
622
|
+
s2.push(s3);
|
623
|
+
s3 = peg$currPos;
|
624
|
+
s4 = peg$parsecomma_wsp();
|
625
|
+
if (s4 === peg$FAILED) {
|
626
|
+
s4 = null;
|
627
|
+
}
|
628
|
+
if (s4 !== peg$FAILED) {
|
629
|
+
s5 = peg$parsecoordinate_pair();
|
630
|
+
if (s5 !== peg$FAILED) {
|
631
|
+
s4 = [s4, s5];
|
632
|
+
s3 = s4;
|
633
|
+
} else {
|
634
|
+
peg$currPos = s3;
|
635
|
+
s3 = peg$FAILED;
|
636
|
+
}
|
637
|
+
} else {
|
638
|
+
peg$currPos = s3;
|
639
|
+
s3 = peg$FAILED;
|
640
|
+
}
|
641
|
+
}
|
642
|
+
if (s2 !== peg$FAILED) {
|
643
|
+
peg$savedPos = s0;
|
644
|
+
s1 = peg$c1(s1, s2);
|
645
|
+
s0 = s1;
|
646
|
+
} else {
|
647
|
+
peg$currPos = s0;
|
648
|
+
s0 = peg$FAILED;
|
649
|
+
}
|
650
|
+
} else {
|
651
|
+
peg$currPos = s0;
|
652
|
+
s0 = peg$FAILED;
|
653
|
+
}
|
654
|
+
return s0;
|
655
|
+
}
|
656
|
+
function peg$parsehorizontal_lineto() {
|
657
|
+
var s0, s1, s2, s3;
|
658
|
+
s0 = peg$currPos;
|
659
|
+
if (peg$c11.test(input.charAt(peg$currPos))) {
|
660
|
+
s1 = input.charAt(peg$currPos);
|
661
|
+
peg$currPos++;
|
662
|
+
} else {
|
663
|
+
s1 = peg$FAILED;
|
664
|
+
if (peg$silentFails === 0) {
|
665
|
+
peg$fail(peg$c12);
|
666
|
+
}
|
667
|
+
}
|
668
|
+
if (s1 !== peg$FAILED) {
|
669
|
+
s2 = [];
|
670
|
+
s3 = peg$parsewsp();
|
671
|
+
while (s3 !== peg$FAILED) {
|
672
|
+
s2.push(s3);
|
673
|
+
s3 = peg$parsewsp();
|
674
|
+
}
|
675
|
+
if (s2 !== peg$FAILED) {
|
676
|
+
s3 = peg$parsecoordinate_sequence();
|
677
|
+
if (s3 !== peg$FAILED) {
|
678
|
+
peg$savedPos = s0;
|
679
|
+
s1 = peg$c13(s1, s3);
|
680
|
+
s0 = s1;
|
681
|
+
} else {
|
682
|
+
peg$currPos = s0;
|
683
|
+
s0 = peg$FAILED;
|
684
|
+
}
|
685
|
+
} else {
|
686
|
+
peg$currPos = s0;
|
687
|
+
s0 = peg$FAILED;
|
688
|
+
}
|
689
|
+
} else {
|
690
|
+
peg$currPos = s0;
|
691
|
+
s0 = peg$FAILED;
|
692
|
+
}
|
693
|
+
return s0;
|
694
|
+
}
|
695
|
+
function peg$parsecoordinate_sequence() {
|
696
|
+
var s0, s1, s2, s3, s4, s5;
|
697
|
+
s0 = peg$currPos;
|
698
|
+
s1 = peg$parsenumber();
|
699
|
+
if (s1 !== peg$FAILED) {
|
700
|
+
s2 = [];
|
701
|
+
s3 = peg$currPos;
|
702
|
+
s4 = peg$parsecomma_wsp();
|
703
|
+
if (s4 === peg$FAILED) {
|
704
|
+
s4 = null;
|
705
|
+
}
|
706
|
+
if (s4 !== peg$FAILED) {
|
707
|
+
s5 = peg$parsenumber();
|
708
|
+
if (s5 !== peg$FAILED) {
|
709
|
+
s4 = [s4, s5];
|
710
|
+
s3 = s4;
|
711
|
+
} else {
|
712
|
+
peg$currPos = s3;
|
713
|
+
s3 = peg$FAILED;
|
714
|
+
}
|
715
|
+
} else {
|
716
|
+
peg$currPos = s3;
|
717
|
+
s3 = peg$FAILED;
|
718
|
+
}
|
719
|
+
while (s3 !== peg$FAILED) {
|
720
|
+
s2.push(s3);
|
721
|
+
s3 = peg$currPos;
|
722
|
+
s4 = peg$parsecomma_wsp();
|
723
|
+
if (s4 === peg$FAILED) {
|
724
|
+
s4 = null;
|
725
|
+
}
|
726
|
+
if (s4 !== peg$FAILED) {
|
727
|
+
s5 = peg$parsenumber();
|
728
|
+
if (s5 !== peg$FAILED) {
|
729
|
+
s4 = [s4, s5];
|
730
|
+
s3 = s4;
|
731
|
+
} else {
|
732
|
+
peg$currPos = s3;
|
733
|
+
s3 = peg$FAILED;
|
734
|
+
}
|
735
|
+
} else {
|
736
|
+
peg$currPos = s3;
|
737
|
+
s3 = peg$FAILED;
|
738
|
+
}
|
739
|
+
}
|
740
|
+
if (s2 !== peg$FAILED) {
|
741
|
+
peg$savedPos = s0;
|
742
|
+
s1 = peg$c1(s1, s2);
|
743
|
+
s0 = s1;
|
744
|
+
} else {
|
745
|
+
peg$currPos = s0;
|
746
|
+
s0 = peg$FAILED;
|
747
|
+
}
|
748
|
+
} else {
|
749
|
+
peg$currPos = s0;
|
750
|
+
s0 = peg$FAILED;
|
751
|
+
}
|
752
|
+
return s0;
|
753
|
+
}
|
754
|
+
function peg$parsevertical_lineto() {
|
755
|
+
var s0, s1, s2, s3;
|
756
|
+
s0 = peg$currPos;
|
757
|
+
if (peg$c14.test(input.charAt(peg$currPos))) {
|
758
|
+
s1 = input.charAt(peg$currPos);
|
759
|
+
peg$currPos++;
|
760
|
+
} else {
|
761
|
+
s1 = peg$FAILED;
|
762
|
+
if (peg$silentFails === 0) {
|
763
|
+
peg$fail(peg$c15);
|
764
|
+
}
|
765
|
+
}
|
766
|
+
if (s1 !== peg$FAILED) {
|
767
|
+
s2 = [];
|
768
|
+
s3 = peg$parsewsp();
|
769
|
+
while (s3 !== peg$FAILED) {
|
770
|
+
s2.push(s3);
|
771
|
+
s3 = peg$parsewsp();
|
772
|
+
}
|
773
|
+
if (s2 !== peg$FAILED) {
|
774
|
+
s3 = peg$parsecoordinate_sequence();
|
775
|
+
if (s3 !== peg$FAILED) {
|
776
|
+
peg$savedPos = s0;
|
777
|
+
s1 = peg$c16(s1, s3);
|
778
|
+
s0 = s1;
|
779
|
+
} else {
|
780
|
+
peg$currPos = s0;
|
781
|
+
s0 = peg$FAILED;
|
782
|
+
}
|
783
|
+
} else {
|
784
|
+
peg$currPos = s0;
|
785
|
+
s0 = peg$FAILED;
|
786
|
+
}
|
787
|
+
} else {
|
788
|
+
peg$currPos = s0;
|
789
|
+
s0 = peg$FAILED;
|
790
|
+
}
|
791
|
+
return s0;
|
792
|
+
}
|
793
|
+
function peg$parsecurveto() {
|
794
|
+
var s0, s1, s2, s3;
|
795
|
+
s0 = peg$currPos;
|
796
|
+
if (peg$c17.test(input.charAt(peg$currPos))) {
|
797
|
+
s1 = input.charAt(peg$currPos);
|
798
|
+
peg$currPos++;
|
799
|
+
} else {
|
800
|
+
s1 = peg$FAILED;
|
801
|
+
if (peg$silentFails === 0) {
|
802
|
+
peg$fail(peg$c18);
|
803
|
+
}
|
804
|
+
}
|
805
|
+
if (s1 !== peg$FAILED) {
|
806
|
+
s2 = [];
|
807
|
+
s3 = peg$parsewsp();
|
808
|
+
while (s3 !== peg$FAILED) {
|
809
|
+
s2.push(s3);
|
810
|
+
s3 = peg$parsewsp();
|
811
|
+
}
|
812
|
+
if (s2 !== peg$FAILED) {
|
813
|
+
s3 = peg$parsecurveto_argument_sequence();
|
814
|
+
if (s3 !== peg$FAILED) {
|
815
|
+
peg$savedPos = s0;
|
816
|
+
s1 = peg$c10(s1, s3);
|
817
|
+
s0 = s1;
|
818
|
+
} else {
|
819
|
+
peg$currPos = s0;
|
820
|
+
s0 = peg$FAILED;
|
821
|
+
}
|
822
|
+
} else {
|
823
|
+
peg$currPos = s0;
|
824
|
+
s0 = peg$FAILED;
|
825
|
+
}
|
826
|
+
} else {
|
827
|
+
peg$currPos = s0;
|
828
|
+
s0 = peg$FAILED;
|
829
|
+
}
|
830
|
+
return s0;
|
831
|
+
}
|
832
|
+
function peg$parsecurveto_argument_sequence() {
|
833
|
+
var s0, s1, s2, s3, s4, s5;
|
834
|
+
s0 = peg$currPos;
|
835
|
+
s1 = peg$parsecurveto_argument();
|
836
|
+
if (s1 !== peg$FAILED) {
|
837
|
+
s2 = [];
|
838
|
+
s3 = peg$currPos;
|
839
|
+
s4 = peg$parsecomma_wsp();
|
840
|
+
if (s4 === peg$FAILED) {
|
841
|
+
s4 = null;
|
842
|
+
}
|
843
|
+
if (s4 !== peg$FAILED) {
|
844
|
+
s5 = peg$parsecurveto_argument();
|
845
|
+
if (s5 !== peg$FAILED) {
|
846
|
+
s4 = [s4, s5];
|
847
|
+
s3 = s4;
|
848
|
+
} else {
|
849
|
+
peg$currPos = s3;
|
850
|
+
s3 = peg$FAILED;
|
851
|
+
}
|
852
|
+
} else {
|
853
|
+
peg$currPos = s3;
|
854
|
+
s3 = peg$FAILED;
|
855
|
+
}
|
856
|
+
while (s3 !== peg$FAILED) {
|
857
|
+
s2.push(s3);
|
858
|
+
s3 = peg$currPos;
|
859
|
+
s4 = peg$parsecomma_wsp();
|
860
|
+
if (s4 === peg$FAILED) {
|
861
|
+
s4 = null;
|
862
|
+
}
|
863
|
+
if (s4 !== peg$FAILED) {
|
864
|
+
s5 = peg$parsecurveto_argument();
|
865
|
+
if (s5 !== peg$FAILED) {
|
866
|
+
s4 = [s4, s5];
|
867
|
+
s3 = s4;
|
868
|
+
} else {
|
869
|
+
peg$currPos = s3;
|
870
|
+
s3 = peg$FAILED;
|
871
|
+
}
|
872
|
+
} else {
|
873
|
+
peg$currPos = s3;
|
874
|
+
s3 = peg$FAILED;
|
875
|
+
}
|
876
|
+
}
|
877
|
+
if (s2 !== peg$FAILED) {
|
878
|
+
peg$savedPos = s0;
|
879
|
+
s1 = peg$c1(s1, s2);
|
880
|
+
s0 = s1;
|
881
|
+
} else {
|
882
|
+
peg$currPos = s0;
|
883
|
+
s0 = peg$FAILED;
|
884
|
+
}
|
885
|
+
} else {
|
886
|
+
peg$currPos = s0;
|
887
|
+
s0 = peg$FAILED;
|
888
|
+
}
|
889
|
+
return s0;
|
890
|
+
}
|
891
|
+
function peg$parsecurveto_argument() {
|
892
|
+
var s0, s1, s2, s3, s4, s5;
|
893
|
+
s0 = peg$currPos;
|
894
|
+
s1 = peg$parsecoordinate_pair();
|
895
|
+
if (s1 !== peg$FAILED) {
|
896
|
+
s2 = peg$parsecomma_wsp();
|
897
|
+
if (s2 === peg$FAILED) {
|
898
|
+
s2 = null;
|
899
|
+
}
|
900
|
+
if (s2 !== peg$FAILED) {
|
901
|
+
s3 = peg$parsecoordinate_pair();
|
902
|
+
if (s3 !== peg$FAILED) {
|
903
|
+
s4 = peg$parsecomma_wsp();
|
904
|
+
if (s4 === peg$FAILED) {
|
905
|
+
s4 = null;
|
906
|
+
}
|
907
|
+
if (s4 !== peg$FAILED) {
|
908
|
+
s5 = peg$parsecoordinate_pair();
|
909
|
+
if (s5 !== peg$FAILED) {
|
910
|
+
peg$savedPos = s0;
|
911
|
+
s1 = peg$c19(s1, s3, s5);
|
912
|
+
s0 = s1;
|
913
|
+
} else {
|
914
|
+
peg$currPos = s0;
|
915
|
+
s0 = peg$FAILED;
|
916
|
+
}
|
917
|
+
} else {
|
918
|
+
peg$currPos = s0;
|
919
|
+
s0 = peg$FAILED;
|
920
|
+
}
|
921
|
+
} else {
|
922
|
+
peg$currPos = s0;
|
923
|
+
s0 = peg$FAILED;
|
924
|
+
}
|
925
|
+
} else {
|
926
|
+
peg$currPos = s0;
|
927
|
+
s0 = peg$FAILED;
|
928
|
+
}
|
929
|
+
} else {
|
930
|
+
peg$currPos = s0;
|
931
|
+
s0 = peg$FAILED;
|
932
|
+
}
|
933
|
+
return s0;
|
934
|
+
}
|
935
|
+
function peg$parsesmooth_curveto() {
|
936
|
+
var s0, s1, s2, s3;
|
937
|
+
s0 = peg$currPos;
|
938
|
+
if (peg$c20.test(input.charAt(peg$currPos))) {
|
939
|
+
s1 = input.charAt(peg$currPos);
|
940
|
+
peg$currPos++;
|
941
|
+
} else {
|
942
|
+
s1 = peg$FAILED;
|
943
|
+
if (peg$silentFails === 0) {
|
944
|
+
peg$fail(peg$c21);
|
945
|
+
}
|
946
|
+
}
|
947
|
+
if (s1 !== peg$FAILED) {
|
948
|
+
s2 = [];
|
949
|
+
s3 = peg$parsewsp();
|
950
|
+
while (s3 !== peg$FAILED) {
|
951
|
+
s2.push(s3);
|
952
|
+
s3 = peg$parsewsp();
|
953
|
+
}
|
954
|
+
if (s2 !== peg$FAILED) {
|
955
|
+
s3 = peg$parsesmooth_curveto_argument_sequence();
|
956
|
+
if (s3 !== peg$FAILED) {
|
957
|
+
peg$savedPos = s0;
|
958
|
+
s1 = peg$c10(s1, s3);
|
959
|
+
s0 = s1;
|
960
|
+
} else {
|
961
|
+
peg$currPos = s0;
|
962
|
+
s0 = peg$FAILED;
|
963
|
+
}
|
964
|
+
} else {
|
965
|
+
peg$currPos = s0;
|
966
|
+
s0 = peg$FAILED;
|
967
|
+
}
|
968
|
+
} else {
|
969
|
+
peg$currPos = s0;
|
970
|
+
s0 = peg$FAILED;
|
971
|
+
}
|
972
|
+
return s0;
|
973
|
+
}
|
974
|
+
function peg$parsesmooth_curveto_argument_sequence() {
|
975
|
+
var s0, s1, s2, s3, s4, s5;
|
976
|
+
s0 = peg$currPos;
|
977
|
+
s1 = peg$parsesmooth_curveto_argument();
|
978
|
+
if (s1 !== peg$FAILED) {
|
979
|
+
s2 = [];
|
980
|
+
s3 = peg$currPos;
|
981
|
+
s4 = peg$parsecomma_wsp();
|
982
|
+
if (s4 === peg$FAILED) {
|
983
|
+
s4 = null;
|
984
|
+
}
|
985
|
+
if (s4 !== peg$FAILED) {
|
986
|
+
s5 = peg$parsesmooth_curveto_argument();
|
987
|
+
if (s5 !== peg$FAILED) {
|
988
|
+
s4 = [s4, s5];
|
989
|
+
s3 = s4;
|
990
|
+
} else {
|
991
|
+
peg$currPos = s3;
|
992
|
+
s3 = peg$FAILED;
|
993
|
+
}
|
994
|
+
} else {
|
995
|
+
peg$currPos = s3;
|
996
|
+
s3 = peg$FAILED;
|
997
|
+
}
|
998
|
+
while (s3 !== peg$FAILED) {
|
999
|
+
s2.push(s3);
|
1000
|
+
s3 = peg$currPos;
|
1001
|
+
s4 = peg$parsecomma_wsp();
|
1002
|
+
if (s4 === peg$FAILED) {
|
1003
|
+
s4 = null;
|
1004
|
+
}
|
1005
|
+
if (s4 !== peg$FAILED) {
|
1006
|
+
s5 = peg$parsesmooth_curveto_argument();
|
1007
|
+
if (s5 !== peg$FAILED) {
|
1008
|
+
s4 = [s4, s5];
|
1009
|
+
s3 = s4;
|
1010
|
+
} else {
|
1011
|
+
peg$currPos = s3;
|
1012
|
+
s3 = peg$FAILED;
|
1013
|
+
}
|
1014
|
+
} else {
|
1015
|
+
peg$currPos = s3;
|
1016
|
+
s3 = peg$FAILED;
|
1017
|
+
}
|
1018
|
+
}
|
1019
|
+
if (s2 !== peg$FAILED) {
|
1020
|
+
peg$savedPos = s0;
|
1021
|
+
s1 = peg$c1(s1, s2);
|
1022
|
+
s0 = s1;
|
1023
|
+
} else {
|
1024
|
+
peg$currPos = s0;
|
1025
|
+
s0 = peg$FAILED;
|
1026
|
+
}
|
1027
|
+
} else {
|
1028
|
+
peg$currPos = s0;
|
1029
|
+
s0 = peg$FAILED;
|
1030
|
+
}
|
1031
|
+
return s0;
|
1032
|
+
}
|
1033
|
+
function peg$parsesmooth_curveto_argument() {
|
1034
|
+
var s0, s1, s2, s3;
|
1035
|
+
s0 = peg$currPos;
|
1036
|
+
s1 = peg$parsecoordinate_pair();
|
1037
|
+
if (s1 !== peg$FAILED) {
|
1038
|
+
s2 = peg$parsecomma_wsp();
|
1039
|
+
if (s2 === peg$FAILED) {
|
1040
|
+
s2 = null;
|
1041
|
+
}
|
1042
|
+
if (s2 !== peg$FAILED) {
|
1043
|
+
s3 = peg$parsecoordinate_pair();
|
1044
|
+
if (s3 !== peg$FAILED) {
|
1045
|
+
peg$savedPos = s0;
|
1046
|
+
s1 = peg$c22(s1, s3);
|
1047
|
+
s0 = s1;
|
1048
|
+
} else {
|
1049
|
+
peg$currPos = s0;
|
1050
|
+
s0 = peg$FAILED;
|
1051
|
+
}
|
1052
|
+
} else {
|
1053
|
+
peg$currPos = s0;
|
1054
|
+
s0 = peg$FAILED;
|
1055
|
+
}
|
1056
|
+
} else {
|
1057
|
+
peg$currPos = s0;
|
1058
|
+
s0 = peg$FAILED;
|
1059
|
+
}
|
1060
|
+
return s0;
|
1061
|
+
}
|
1062
|
+
function peg$parsequadratic_bezier_curveto() {
|
1063
|
+
var s0, s1, s2, s3;
|
1064
|
+
s0 = peg$currPos;
|
1065
|
+
if (peg$c23.test(input.charAt(peg$currPos))) {
|
1066
|
+
s1 = input.charAt(peg$currPos);
|
1067
|
+
peg$currPos++;
|
1068
|
+
} else {
|
1069
|
+
s1 = peg$FAILED;
|
1070
|
+
if (peg$silentFails === 0) {
|
1071
|
+
peg$fail(peg$c24);
|
1072
|
+
}
|
1073
|
+
}
|
1074
|
+
if (s1 !== peg$FAILED) {
|
1075
|
+
s2 = [];
|
1076
|
+
s3 = peg$parsewsp();
|
1077
|
+
while (s3 !== peg$FAILED) {
|
1078
|
+
s2.push(s3);
|
1079
|
+
s3 = peg$parsewsp();
|
1080
|
+
}
|
1081
|
+
if (s2 !== peg$FAILED) {
|
1082
|
+
s3 = peg$parsequadratic_bezier_curveto_argument_sequence();
|
1083
|
+
if (s3 !== peg$FAILED) {
|
1084
|
+
peg$savedPos = s0;
|
1085
|
+
s1 = peg$c10(s1, s3);
|
1086
|
+
s0 = s1;
|
1087
|
+
} else {
|
1088
|
+
peg$currPos = s0;
|
1089
|
+
s0 = peg$FAILED;
|
1090
|
+
}
|
1091
|
+
} else {
|
1092
|
+
peg$currPos = s0;
|
1093
|
+
s0 = peg$FAILED;
|
1094
|
+
}
|
1095
|
+
} else {
|
1096
|
+
peg$currPos = s0;
|
1097
|
+
s0 = peg$FAILED;
|
1098
|
+
}
|
1099
|
+
return s0;
|
1100
|
+
}
|
1101
|
+
function peg$parsequadratic_bezier_curveto_argument_sequence() {
|
1102
|
+
var s0, s1, s2, s3, s4, s5;
|
1103
|
+
s0 = peg$currPos;
|
1104
|
+
s1 = peg$parsequadratic_bezier_curveto_argument();
|
1105
|
+
if (s1 !== peg$FAILED) {
|
1106
|
+
s2 = [];
|
1107
|
+
s3 = peg$currPos;
|
1108
|
+
s4 = peg$parsecomma_wsp();
|
1109
|
+
if (s4 === peg$FAILED) {
|
1110
|
+
s4 = null;
|
1111
|
+
}
|
1112
|
+
if (s4 !== peg$FAILED) {
|
1113
|
+
s5 = peg$parsequadratic_bezier_curveto_argument();
|
1114
|
+
if (s5 !== peg$FAILED) {
|
1115
|
+
s4 = [s4, s5];
|
1116
|
+
s3 = s4;
|
1117
|
+
} else {
|
1118
|
+
peg$currPos = s3;
|
1119
|
+
s3 = peg$FAILED;
|
1120
|
+
}
|
1121
|
+
} else {
|
1122
|
+
peg$currPos = s3;
|
1123
|
+
s3 = peg$FAILED;
|
1124
|
+
}
|
1125
|
+
while (s3 !== peg$FAILED) {
|
1126
|
+
s2.push(s3);
|
1127
|
+
s3 = peg$currPos;
|
1128
|
+
s4 = peg$parsecomma_wsp();
|
1129
|
+
if (s4 === peg$FAILED) {
|
1130
|
+
s4 = null;
|
1131
|
+
}
|
1132
|
+
if (s4 !== peg$FAILED) {
|
1133
|
+
s5 = peg$parsequadratic_bezier_curveto_argument();
|
1134
|
+
if (s5 !== peg$FAILED) {
|
1135
|
+
s4 = [s4, s5];
|
1136
|
+
s3 = s4;
|
1137
|
+
} else {
|
1138
|
+
peg$currPos = s3;
|
1139
|
+
s3 = peg$FAILED;
|
1140
|
+
}
|
1141
|
+
} else {
|
1142
|
+
peg$currPos = s3;
|
1143
|
+
s3 = peg$FAILED;
|
1144
|
+
}
|
1145
|
+
}
|
1146
|
+
if (s2 !== peg$FAILED) {
|
1147
|
+
peg$savedPos = s0;
|
1148
|
+
s1 = peg$c1(s1, s2);
|
1149
|
+
s0 = s1;
|
1150
|
+
} else {
|
1151
|
+
peg$currPos = s0;
|
1152
|
+
s0 = peg$FAILED;
|
1153
|
+
}
|
1154
|
+
} else {
|
1155
|
+
peg$currPos = s0;
|
1156
|
+
s0 = peg$FAILED;
|
1157
|
+
}
|
1158
|
+
return s0;
|
1159
|
+
}
|
1160
|
+
function peg$parsequadratic_bezier_curveto_argument() {
|
1161
|
+
var s0, s1, s2, s3;
|
1162
|
+
s0 = peg$currPos;
|
1163
|
+
s1 = peg$parsecoordinate_pair();
|
1164
|
+
if (s1 !== peg$FAILED) {
|
1165
|
+
s2 = peg$parsecomma_wsp();
|
1166
|
+
if (s2 === peg$FAILED) {
|
1167
|
+
s2 = null;
|
1168
|
+
}
|
1169
|
+
if (s2 !== peg$FAILED) {
|
1170
|
+
s3 = peg$parsecoordinate_pair();
|
1171
|
+
if (s3 !== peg$FAILED) {
|
1172
|
+
peg$savedPos = s0;
|
1173
|
+
s1 = peg$c25(s1, s3);
|
1174
|
+
s0 = s1;
|
1175
|
+
} else {
|
1176
|
+
peg$currPos = s0;
|
1177
|
+
s0 = peg$FAILED;
|
1178
|
+
}
|
1179
|
+
} else {
|
1180
|
+
peg$currPos = s0;
|
1181
|
+
s0 = peg$FAILED;
|
1182
|
+
}
|
1183
|
+
} else {
|
1184
|
+
peg$currPos = s0;
|
1185
|
+
s0 = peg$FAILED;
|
1186
|
+
}
|
1187
|
+
return s0;
|
1188
|
+
}
|
1189
|
+
function peg$parsesmooth_quadratic_bezier_curveto() {
|
1190
|
+
var s0, s1, s2, s3;
|
1191
|
+
s0 = peg$currPos;
|
1192
|
+
if (peg$c26.test(input.charAt(peg$currPos))) {
|
1193
|
+
s1 = input.charAt(peg$currPos);
|
1194
|
+
peg$currPos++;
|
1195
|
+
} else {
|
1196
|
+
s1 = peg$FAILED;
|
1197
|
+
if (peg$silentFails === 0) {
|
1198
|
+
peg$fail(peg$c27);
|
1199
|
+
}
|
1200
|
+
}
|
1201
|
+
if (s1 !== peg$FAILED) {
|
1202
|
+
s2 = [];
|
1203
|
+
s3 = peg$parsewsp();
|
1204
|
+
while (s3 !== peg$FAILED) {
|
1205
|
+
s2.push(s3);
|
1206
|
+
s3 = peg$parsewsp();
|
1207
|
+
}
|
1208
|
+
if (s2 !== peg$FAILED) {
|
1209
|
+
s3 = peg$parsesmooth_quadratic_bezier_curveto_argument_sequence();
|
1210
|
+
if (s3 !== peg$FAILED) {
|
1211
|
+
peg$savedPos = s0;
|
1212
|
+
s1 = peg$c10(s1, s3);
|
1213
|
+
s0 = s1;
|
1214
|
+
} else {
|
1215
|
+
peg$currPos = s0;
|
1216
|
+
s0 = peg$FAILED;
|
1217
|
+
}
|
1218
|
+
} else {
|
1219
|
+
peg$currPos = s0;
|
1220
|
+
s0 = peg$FAILED;
|
1221
|
+
}
|
1222
|
+
} else {
|
1223
|
+
peg$currPos = s0;
|
1224
|
+
s0 = peg$FAILED;
|
1225
|
+
}
|
1226
|
+
return s0;
|
1227
|
+
}
|
1228
|
+
function peg$parsesmooth_quadratic_bezier_curveto_argument_sequence() {
|
1229
|
+
var s0, s1, s2, s3, s4, s5;
|
1230
|
+
s0 = peg$currPos;
|
1231
|
+
s1 = peg$parsecoordinate_pair();
|
1232
|
+
if (s1 !== peg$FAILED) {
|
1233
|
+
s2 = [];
|
1234
|
+
s3 = peg$currPos;
|
1235
|
+
s4 = peg$parsecomma_wsp();
|
1236
|
+
if (s4 === peg$FAILED) {
|
1237
|
+
s4 = null;
|
1238
|
+
}
|
1239
|
+
if (s4 !== peg$FAILED) {
|
1240
|
+
s5 = peg$parsecoordinate_pair();
|
1241
|
+
if (s5 !== peg$FAILED) {
|
1242
|
+
s4 = [s4, s5];
|
1243
|
+
s3 = s4;
|
1244
|
+
} else {
|
1245
|
+
peg$currPos = s3;
|
1246
|
+
s3 = peg$FAILED;
|
1247
|
+
}
|
1248
|
+
} else {
|
1249
|
+
peg$currPos = s3;
|
1250
|
+
s3 = peg$FAILED;
|
1251
|
+
}
|
1252
|
+
while (s3 !== peg$FAILED) {
|
1253
|
+
s2.push(s3);
|
1254
|
+
s3 = peg$currPos;
|
1255
|
+
s4 = peg$parsecomma_wsp();
|
1256
|
+
if (s4 === peg$FAILED) {
|
1257
|
+
s4 = null;
|
1258
|
+
}
|
1259
|
+
if (s4 !== peg$FAILED) {
|
1260
|
+
s5 = peg$parsecoordinate_pair();
|
1261
|
+
if (s5 !== peg$FAILED) {
|
1262
|
+
s4 = [s4, s5];
|
1263
|
+
s3 = s4;
|
1264
|
+
} else {
|
1265
|
+
peg$currPos = s3;
|
1266
|
+
s3 = peg$FAILED;
|
1267
|
+
}
|
1268
|
+
} else {
|
1269
|
+
peg$currPos = s3;
|
1270
|
+
s3 = peg$FAILED;
|
1271
|
+
}
|
1272
|
+
}
|
1273
|
+
if (s2 !== peg$FAILED) {
|
1274
|
+
peg$savedPos = s0;
|
1275
|
+
s1 = peg$c1(s1, s2);
|
1276
|
+
s0 = s1;
|
1277
|
+
} else {
|
1278
|
+
peg$currPos = s0;
|
1279
|
+
s0 = peg$FAILED;
|
1280
|
+
}
|
1281
|
+
} else {
|
1282
|
+
peg$currPos = s0;
|
1283
|
+
s0 = peg$FAILED;
|
1284
|
+
}
|
1285
|
+
return s0;
|
1286
|
+
}
|
1287
|
+
function peg$parseelliptical_arc() {
|
1288
|
+
var s0, s1, s2, s3;
|
1289
|
+
s0 = peg$currPos;
|
1290
|
+
if (peg$c28.test(input.charAt(peg$currPos))) {
|
1291
|
+
s1 = input.charAt(peg$currPos);
|
1292
|
+
peg$currPos++;
|
1293
|
+
} else {
|
1294
|
+
s1 = peg$FAILED;
|
1295
|
+
if (peg$silentFails === 0) {
|
1296
|
+
peg$fail(peg$c29);
|
1297
|
+
}
|
1298
|
+
}
|
1299
|
+
if (s1 !== peg$FAILED) {
|
1300
|
+
s2 = [];
|
1301
|
+
s3 = peg$parsewsp();
|
1302
|
+
while (s3 !== peg$FAILED) {
|
1303
|
+
s2.push(s3);
|
1304
|
+
s3 = peg$parsewsp();
|
1305
|
+
}
|
1306
|
+
if (s2 !== peg$FAILED) {
|
1307
|
+
s3 = peg$parseelliptical_arc_argument_sequence();
|
1308
|
+
if (s3 !== peg$FAILED) {
|
1309
|
+
peg$savedPos = s0;
|
1310
|
+
s1 = peg$c10(s1, s3);
|
1311
|
+
s0 = s1;
|
1312
|
+
} else {
|
1313
|
+
peg$currPos = s0;
|
1314
|
+
s0 = peg$FAILED;
|
1315
|
+
}
|
1316
|
+
} else {
|
1317
|
+
peg$currPos = s0;
|
1318
|
+
s0 = peg$FAILED;
|
1319
|
+
}
|
1320
|
+
} else {
|
1321
|
+
peg$currPos = s0;
|
1322
|
+
s0 = peg$FAILED;
|
1323
|
+
}
|
1324
|
+
return s0;
|
1325
|
+
}
|
1326
|
+
function peg$parseelliptical_arc_argument_sequence() {
|
1327
|
+
var s0, s1, s2, s3, s4, s5;
|
1328
|
+
s0 = peg$currPos;
|
1329
|
+
s1 = peg$parseelliptical_arc_argument();
|
1330
|
+
if (s1 !== peg$FAILED) {
|
1331
|
+
s2 = [];
|
1332
|
+
s3 = peg$currPos;
|
1333
|
+
s4 = peg$parsecomma_wsp();
|
1334
|
+
if (s4 === peg$FAILED) {
|
1335
|
+
s4 = null;
|
1336
|
+
}
|
1337
|
+
if (s4 !== peg$FAILED) {
|
1338
|
+
s5 = peg$parseelliptical_arc_argument();
|
1339
|
+
if (s5 !== peg$FAILED) {
|
1340
|
+
s4 = [s4, s5];
|
1341
|
+
s3 = s4;
|
1342
|
+
} else {
|
1343
|
+
peg$currPos = s3;
|
1344
|
+
s3 = peg$FAILED;
|
1345
|
+
}
|
1346
|
+
} else {
|
1347
|
+
peg$currPos = s3;
|
1348
|
+
s3 = peg$FAILED;
|
1349
|
+
}
|
1350
|
+
while (s3 !== peg$FAILED) {
|
1351
|
+
s2.push(s3);
|
1352
|
+
s3 = peg$currPos;
|
1353
|
+
s4 = peg$parsecomma_wsp();
|
1354
|
+
if (s4 === peg$FAILED) {
|
1355
|
+
s4 = null;
|
1356
|
+
}
|
1357
|
+
if (s4 !== peg$FAILED) {
|
1358
|
+
s5 = peg$parseelliptical_arc_argument();
|
1359
|
+
if (s5 !== peg$FAILED) {
|
1360
|
+
s4 = [s4, s5];
|
1361
|
+
s3 = s4;
|
1362
|
+
} else {
|
1363
|
+
peg$currPos = s3;
|
1364
|
+
s3 = peg$FAILED;
|
1365
|
+
}
|
1366
|
+
} else {
|
1367
|
+
peg$currPos = s3;
|
1368
|
+
s3 = peg$FAILED;
|
1369
|
+
}
|
1370
|
+
}
|
1371
|
+
if (s2 !== peg$FAILED) {
|
1372
|
+
peg$savedPos = s0;
|
1373
|
+
s1 = peg$c1(s1, s2);
|
1374
|
+
s0 = s1;
|
1375
|
+
} else {
|
1376
|
+
peg$currPos = s0;
|
1377
|
+
s0 = peg$FAILED;
|
1378
|
+
}
|
1379
|
+
} else {
|
1380
|
+
peg$currPos = s0;
|
1381
|
+
s0 = peg$FAILED;
|
1382
|
+
}
|
1383
|
+
return s0;
|
1384
|
+
}
|
1385
|
+
function peg$parseelliptical_arc_argument() {
|
1386
|
+
var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11;
|
1387
|
+
s0 = peg$currPos;
|
1388
|
+
s1 = peg$parsenonnegative_number();
|
1389
|
+
if (s1 !== peg$FAILED) {
|
1390
|
+
s2 = peg$parsecomma_wsp();
|
1391
|
+
if (s2 === peg$FAILED) {
|
1392
|
+
s2 = null;
|
1393
|
+
}
|
1394
|
+
if (s2 !== peg$FAILED) {
|
1395
|
+
s3 = peg$parsenonnegative_number();
|
1396
|
+
if (s3 !== peg$FAILED) {
|
1397
|
+
s4 = peg$parsecomma_wsp();
|
1398
|
+
if (s4 === peg$FAILED) {
|
1399
|
+
s4 = null;
|
1400
|
+
}
|
1401
|
+
if (s4 !== peg$FAILED) {
|
1402
|
+
s5 = peg$parsenumber();
|
1403
|
+
if (s5 !== peg$FAILED) {
|
1404
|
+
s6 = peg$parsecomma_wsp();
|
1405
|
+
if (s6 !== peg$FAILED) {
|
1406
|
+
s7 = peg$parseflag();
|
1407
|
+
if (s7 !== peg$FAILED) {
|
1408
|
+
s8 = peg$parsecomma_wsp();
|
1409
|
+
if (s8 === peg$FAILED) {
|
1410
|
+
s8 = null;
|
1411
|
+
}
|
1412
|
+
if (s8 !== peg$FAILED) {
|
1413
|
+
s9 = peg$parseflag();
|
1414
|
+
if (s9 !== peg$FAILED) {
|
1415
|
+
s10 = peg$parsecomma_wsp();
|
1416
|
+
if (s10 === peg$FAILED) {
|
1417
|
+
s10 = null;
|
1418
|
+
}
|
1419
|
+
if (s10 !== peg$FAILED) {
|
1420
|
+
s11 = peg$parsecoordinate_pair();
|
1421
|
+
if (s11 !== peg$FAILED) {
|
1422
|
+
peg$savedPos = s0;
|
1423
|
+
s1 = peg$c30(s1, s3, s5, s7, s9, s11);
|
1424
|
+
s0 = s1;
|
1425
|
+
} else {
|
1426
|
+
peg$currPos = s0;
|
1427
|
+
s0 = peg$FAILED;
|
1428
|
+
}
|
1429
|
+
} else {
|
1430
|
+
peg$currPos = s0;
|
1431
|
+
s0 = peg$FAILED;
|
1432
|
+
}
|
1433
|
+
} else {
|
1434
|
+
peg$currPos = s0;
|
1435
|
+
s0 = peg$FAILED;
|
1436
|
+
}
|
1437
|
+
} else {
|
1438
|
+
peg$currPos = s0;
|
1439
|
+
s0 = peg$FAILED;
|
1440
|
+
}
|
1441
|
+
} else {
|
1442
|
+
peg$currPos = s0;
|
1443
|
+
s0 = peg$FAILED;
|
1444
|
+
}
|
1445
|
+
} else {
|
1446
|
+
peg$currPos = s0;
|
1447
|
+
s0 = peg$FAILED;
|
1448
|
+
}
|
1449
|
+
} else {
|
1450
|
+
peg$currPos = s0;
|
1451
|
+
s0 = peg$FAILED;
|
1452
|
+
}
|
1453
|
+
} else {
|
1454
|
+
peg$currPos = s0;
|
1455
|
+
s0 = peg$FAILED;
|
1456
|
+
}
|
1457
|
+
} else {
|
1458
|
+
peg$currPos = s0;
|
1459
|
+
s0 = peg$FAILED;
|
1460
|
+
}
|
1461
|
+
} else {
|
1462
|
+
peg$currPos = s0;
|
1463
|
+
s0 = peg$FAILED;
|
1464
|
+
}
|
1465
|
+
} else {
|
1466
|
+
peg$currPos = s0;
|
1467
|
+
s0 = peg$FAILED;
|
1468
|
+
}
|
1469
|
+
return s0;
|
1470
|
+
}
|
1471
|
+
function peg$parsecoordinate_pair() {
|
1472
|
+
var s0, s1, s2, s3;
|
1473
|
+
s0 = peg$currPos;
|
1474
|
+
s1 = peg$parsenumber();
|
1475
|
+
if (s1 !== peg$FAILED) {
|
1476
|
+
s2 = peg$parsecomma_wsp();
|
1477
|
+
if (s2 === peg$FAILED) {
|
1478
|
+
s2 = null;
|
1479
|
+
}
|
1480
|
+
if (s2 !== peg$FAILED) {
|
1481
|
+
s3 = peg$parsenumber();
|
1482
|
+
if (s3 !== peg$FAILED) {
|
1483
|
+
peg$savedPos = s0;
|
1484
|
+
s1 = peg$c31(s1, s3);
|
1485
|
+
s0 = s1;
|
1486
|
+
} else {
|
1487
|
+
peg$currPos = s0;
|
1488
|
+
s0 = peg$FAILED;
|
1489
|
+
}
|
1490
|
+
} else {
|
1491
|
+
peg$currPos = s0;
|
1492
|
+
s0 = peg$FAILED;
|
1493
|
+
}
|
1494
|
+
} else {
|
1495
|
+
peg$currPos = s0;
|
1496
|
+
s0 = peg$FAILED;
|
1497
|
+
}
|
1498
|
+
return s0;
|
1499
|
+
}
|
1500
|
+
function peg$parsenonnegative_number() {
|
1501
|
+
var s0, s1;
|
1502
|
+
s0 = peg$currPos;
|
1503
|
+
s1 = peg$parsefloating_point_constant();
|
1504
|
+
if (s1 === peg$FAILED) {
|
1505
|
+
s1 = peg$parsedigit_sequence();
|
1506
|
+
}
|
1507
|
+
if (s1 !== peg$FAILED) {
|
1508
|
+
peg$savedPos = s0;
|
1509
|
+
s1 = peg$c32(s1);
|
1510
|
+
}
|
1511
|
+
s0 = s1;
|
1512
|
+
return s0;
|
1513
|
+
}
|
1514
|
+
function peg$parsenumber() {
|
1515
|
+
var s0, s1, s2, s3;
|
1516
|
+
s0 = peg$currPos;
|
1517
|
+
s1 = peg$currPos;
|
1518
|
+
s2 = peg$parsesign();
|
1519
|
+
if (s2 === peg$FAILED) {
|
1520
|
+
s2 = null;
|
1521
|
+
}
|
1522
|
+
if (s2 !== peg$FAILED) {
|
1523
|
+
s3 = peg$parsefloating_point_constant();
|
1524
|
+
if (s3 !== peg$FAILED) {
|
1525
|
+
s2 = [s2, s3];
|
1526
|
+
s1 = s2;
|
1527
|
+
} else {
|
1528
|
+
peg$currPos = s1;
|
1529
|
+
s1 = peg$FAILED;
|
1530
|
+
}
|
1531
|
+
} else {
|
1532
|
+
peg$currPos = s1;
|
1533
|
+
s1 = peg$FAILED;
|
1534
|
+
}
|
1535
|
+
if (s1 === peg$FAILED) {
|
1536
|
+
s1 = peg$currPos;
|
1537
|
+
s2 = peg$parsesign();
|
1538
|
+
if (s2 === peg$FAILED) {
|
1539
|
+
s2 = null;
|
1540
|
+
}
|
1541
|
+
if (s2 !== peg$FAILED) {
|
1542
|
+
s3 = peg$parsedigit_sequence();
|
1543
|
+
if (s3 !== peg$FAILED) {
|
1544
|
+
s2 = [s2, s3];
|
1545
|
+
s1 = s2;
|
1546
|
+
} else {
|
1547
|
+
peg$currPos = s1;
|
1548
|
+
s1 = peg$FAILED;
|
1549
|
+
}
|
1550
|
+
} else {
|
1551
|
+
peg$currPos = s1;
|
1552
|
+
s1 = peg$FAILED;
|
1553
|
+
}
|
1554
|
+
}
|
1555
|
+
if (s1 !== peg$FAILED) {
|
1556
|
+
peg$savedPos = s0;
|
1557
|
+
s1 = peg$c33(s1);
|
1558
|
+
}
|
1559
|
+
s0 = s1;
|
1560
|
+
return s0;
|
1561
|
+
}
|
1562
|
+
function peg$parseflag() {
|
1563
|
+
var s0, s1;
|
1564
|
+
s0 = peg$currPos;
|
1565
|
+
if (peg$c34.test(input.charAt(peg$currPos))) {
|
1566
|
+
s1 = input.charAt(peg$currPos);
|
1567
|
+
peg$currPos++;
|
1568
|
+
} else {
|
1569
|
+
s1 = peg$FAILED;
|
1570
|
+
if (peg$silentFails === 0) {
|
1571
|
+
peg$fail(peg$c35);
|
1572
|
+
}
|
1573
|
+
}
|
1574
|
+
if (s1 !== peg$FAILED) {
|
1575
|
+
peg$savedPos = s0;
|
1576
|
+
s1 = peg$c36(s1);
|
1577
|
+
}
|
1578
|
+
s0 = s1;
|
1579
|
+
return s0;
|
1580
|
+
}
|
1581
|
+
function peg$parsecomma_wsp() {
|
1582
|
+
var s0, s1, s2, s3, s4;
|
1583
|
+
s0 = peg$currPos;
|
1584
|
+
s1 = [];
|
1585
|
+
s2 = peg$parsewsp();
|
1586
|
+
if (s2 !== peg$FAILED) {
|
1587
|
+
while (s2 !== peg$FAILED) {
|
1588
|
+
s1.push(s2);
|
1589
|
+
s2 = peg$parsewsp();
|
1590
|
+
}
|
1591
|
+
} else {
|
1592
|
+
s1 = peg$FAILED;
|
1593
|
+
}
|
1594
|
+
if (s1 !== peg$FAILED) {
|
1595
|
+
s2 = peg$parsecomma();
|
1596
|
+
if (s2 === peg$FAILED) {
|
1597
|
+
s2 = null;
|
1598
|
+
}
|
1599
|
+
if (s2 !== peg$FAILED) {
|
1600
|
+
s3 = [];
|
1601
|
+
s4 = peg$parsewsp();
|
1602
|
+
while (s4 !== peg$FAILED) {
|
1603
|
+
s3.push(s4);
|
1604
|
+
s4 = peg$parsewsp();
|
1605
|
+
}
|
1606
|
+
if (s3 !== peg$FAILED) {
|
1607
|
+
s1 = [s1, s2, s3];
|
1608
|
+
s0 = s1;
|
1609
|
+
} else {
|
1610
|
+
peg$currPos = s0;
|
1611
|
+
s0 = peg$FAILED;
|
1612
|
+
}
|
1613
|
+
} else {
|
1614
|
+
peg$currPos = s0;
|
1615
|
+
s0 = peg$FAILED;
|
1616
|
+
}
|
1617
|
+
} else {
|
1618
|
+
peg$currPos = s0;
|
1619
|
+
s0 = peg$FAILED;
|
1620
|
+
}
|
1621
|
+
if (s0 === peg$FAILED) {
|
1622
|
+
s0 = peg$currPos;
|
1623
|
+
s1 = peg$currPos;
|
1624
|
+
s2 = peg$parsecomma();
|
1625
|
+
if (s2 !== peg$FAILED) {
|
1626
|
+
s3 = [];
|
1627
|
+
s4 = peg$parsewsp();
|
1628
|
+
while (s4 !== peg$FAILED) {
|
1629
|
+
s3.push(s4);
|
1630
|
+
s4 = peg$parsewsp();
|
1631
|
+
}
|
1632
|
+
if (s3 !== peg$FAILED) {
|
1633
|
+
s2 = [s2, s3];
|
1634
|
+
s1 = s2;
|
1635
|
+
} else {
|
1636
|
+
peg$currPos = s1;
|
1637
|
+
s1 = peg$FAILED;
|
1638
|
+
}
|
1639
|
+
} else {
|
1640
|
+
peg$currPos = s1;
|
1641
|
+
s1 = peg$FAILED;
|
1642
|
+
}
|
1643
|
+
if (s1 !== peg$FAILED) {
|
1644
|
+
peg$savedPos = s0;
|
1645
|
+
s1 = peg$c37();
|
1646
|
+
}
|
1647
|
+
s0 = s1;
|
1648
|
+
}
|
1649
|
+
return s0;
|
1650
|
+
}
|
1651
|
+
function peg$parsecomma() {
|
1652
|
+
var s0;
|
1653
|
+
if (input.charCodeAt(peg$currPos) === 44) {
|
1654
|
+
s0 = peg$c38;
|
1655
|
+
peg$currPos++;
|
1656
|
+
} else {
|
1657
|
+
s0 = peg$FAILED;
|
1658
|
+
if (peg$silentFails === 0) {
|
1659
|
+
peg$fail(peg$c39);
|
1660
|
+
}
|
1661
|
+
}
|
1662
|
+
return s0;
|
1663
|
+
}
|
1664
|
+
function peg$parsefloating_point_constant() {
|
1665
|
+
var s0, s1, s2, s3;
|
1666
|
+
s0 = peg$currPos;
|
1667
|
+
s1 = peg$currPos;
|
1668
|
+
s2 = peg$parsefractional_constant();
|
1669
|
+
if (s2 !== peg$FAILED) {
|
1670
|
+
s3 = peg$parseexponent();
|
1671
|
+
if (s3 === peg$FAILED) {
|
1672
|
+
s3 = null;
|
1673
|
+
}
|
1674
|
+
if (s3 !== peg$FAILED) {
|
1675
|
+
s2 = [s2, s3];
|
1676
|
+
s1 = s2;
|
1677
|
+
} else {
|
1678
|
+
peg$currPos = s1;
|
1679
|
+
s1 = peg$FAILED;
|
1680
|
+
}
|
1681
|
+
} else {
|
1682
|
+
peg$currPos = s1;
|
1683
|
+
s1 = peg$FAILED;
|
1684
|
+
}
|
1685
|
+
if (s1 === peg$FAILED) {
|
1686
|
+
s1 = peg$currPos;
|
1687
|
+
s2 = peg$parsedigit_sequence();
|
1688
|
+
if (s2 !== peg$FAILED) {
|
1689
|
+
s3 = peg$parseexponent();
|
1690
|
+
if (s3 !== peg$FAILED) {
|
1691
|
+
s2 = [s2, s3];
|
1692
|
+
s1 = s2;
|
1693
|
+
} else {
|
1694
|
+
peg$currPos = s1;
|
1695
|
+
s1 = peg$FAILED;
|
1696
|
+
}
|
1697
|
+
} else {
|
1698
|
+
peg$currPos = s1;
|
1699
|
+
s1 = peg$FAILED;
|
1700
|
+
}
|
1701
|
+
}
|
1702
|
+
if (s1 !== peg$FAILED) {
|
1703
|
+
peg$savedPos = s0;
|
1704
|
+
s1 = peg$c40(s1);
|
1705
|
+
}
|
1706
|
+
s0 = s1;
|
1707
|
+
return s0;
|
1708
|
+
}
|
1709
|
+
function peg$parsefractional_constant() {
|
1710
|
+
var s0, s1, s2, s3, s4;
|
1711
|
+
s0 = peg$currPos;
|
1712
|
+
s1 = peg$currPos;
|
1713
|
+
s2 = peg$parsedigit_sequence();
|
1714
|
+
if (s2 === peg$FAILED) {
|
1715
|
+
s2 = null;
|
1716
|
+
}
|
1717
|
+
if (s2 !== peg$FAILED) {
|
1718
|
+
if (input.charCodeAt(peg$currPos) === 46) {
|
1719
|
+
s3 = peg$c41;
|
1720
|
+
peg$currPos++;
|
1721
|
+
} else {
|
1722
|
+
s3 = peg$FAILED;
|
1723
|
+
if (peg$silentFails === 0) {
|
1724
|
+
peg$fail(peg$c42);
|
1725
|
+
}
|
1726
|
+
}
|
1727
|
+
if (s3 !== peg$FAILED) {
|
1728
|
+
s4 = peg$parsedigit_sequence();
|
1729
|
+
if (s4 !== peg$FAILED) {
|
1730
|
+
s2 = [s2, s3, s4];
|
1731
|
+
s1 = s2;
|
1732
|
+
} else {
|
1733
|
+
peg$currPos = s1;
|
1734
|
+
s1 = peg$FAILED;
|
1735
|
+
}
|
1736
|
+
} else {
|
1737
|
+
peg$currPos = s1;
|
1738
|
+
s1 = peg$FAILED;
|
1739
|
+
}
|
1740
|
+
} else {
|
1741
|
+
peg$currPos = s1;
|
1742
|
+
s1 = peg$FAILED;
|
1743
|
+
}
|
1744
|
+
if (s1 === peg$FAILED) {
|
1745
|
+
s1 = peg$currPos;
|
1746
|
+
s2 = peg$parsedigit_sequence();
|
1747
|
+
if (s2 !== peg$FAILED) {
|
1748
|
+
if (input.charCodeAt(peg$currPos) === 46) {
|
1749
|
+
s3 = peg$c41;
|
1750
|
+
peg$currPos++;
|
1751
|
+
} else {
|
1752
|
+
s3 = peg$FAILED;
|
1753
|
+
if (peg$silentFails === 0) {
|
1754
|
+
peg$fail(peg$c42);
|
1755
|
+
}
|
1756
|
+
}
|
1757
|
+
if (s3 !== peg$FAILED) {
|
1758
|
+
s2 = [s2, s3];
|
1759
|
+
s1 = s2;
|
1760
|
+
} else {
|
1761
|
+
peg$currPos = s1;
|
1762
|
+
s1 = peg$FAILED;
|
1763
|
+
}
|
1764
|
+
} else {
|
1765
|
+
peg$currPos = s1;
|
1766
|
+
s1 = peg$FAILED;
|
1767
|
+
}
|
1768
|
+
}
|
1769
|
+
if (s1 !== peg$FAILED) {
|
1770
|
+
peg$savedPos = s0;
|
1771
|
+
s1 = peg$c40(s1);
|
1772
|
+
}
|
1773
|
+
s0 = s1;
|
1774
|
+
return s0;
|
1775
|
+
}
|
1776
|
+
function peg$parseexponent() {
|
1777
|
+
var s0, s1, s2, s3, s4;
|
1778
|
+
s0 = peg$currPos;
|
1779
|
+
s1 = peg$currPos;
|
1780
|
+
if (peg$c43.test(input.charAt(peg$currPos))) {
|
1781
|
+
s2 = input.charAt(peg$currPos);
|
1782
|
+
peg$currPos++;
|
1783
|
+
} else {
|
1784
|
+
s2 = peg$FAILED;
|
1785
|
+
if (peg$silentFails === 0) {
|
1786
|
+
peg$fail(peg$c44);
|
1787
|
+
}
|
1788
|
+
}
|
1789
|
+
if (s2 !== peg$FAILED) {
|
1790
|
+
s3 = peg$parsesign();
|
1791
|
+
if (s3 === peg$FAILED) {
|
1792
|
+
s3 = null;
|
1793
|
+
}
|
1794
|
+
if (s3 !== peg$FAILED) {
|
1795
|
+
s4 = peg$parsedigit_sequence();
|
1796
|
+
if (s4 !== peg$FAILED) {
|
1797
|
+
s2 = [s2, s3, s4];
|
1798
|
+
s1 = s2;
|
1799
|
+
} else {
|
1800
|
+
peg$currPos = s1;
|
1801
|
+
s1 = peg$FAILED;
|
1802
|
+
}
|
1803
|
+
} else {
|
1804
|
+
peg$currPos = s1;
|
1805
|
+
s1 = peg$FAILED;
|
1806
|
+
}
|
1807
|
+
} else {
|
1808
|
+
peg$currPos = s1;
|
1809
|
+
s1 = peg$FAILED;
|
1810
|
+
}
|
1811
|
+
if (s1 !== peg$FAILED) {
|
1812
|
+
peg$savedPos = s0;
|
1813
|
+
s1 = peg$c40(s1);
|
1814
|
+
}
|
1815
|
+
s0 = s1;
|
1816
|
+
return s0;
|
1817
|
+
}
|
1818
|
+
function peg$parsesign() {
|
1819
|
+
var s0;
|
1820
|
+
if (peg$c45.test(input.charAt(peg$currPos))) {
|
1821
|
+
s0 = input.charAt(peg$currPos);
|
1822
|
+
peg$currPos++;
|
1823
|
+
} else {
|
1824
|
+
s0 = peg$FAILED;
|
1825
|
+
if (peg$silentFails === 0) {
|
1826
|
+
peg$fail(peg$c46);
|
1827
|
+
}
|
1828
|
+
}
|
1829
|
+
return s0;
|
1830
|
+
}
|
1831
|
+
function peg$parsedigit_sequence() {
|
1832
|
+
var s0, s1, s2;
|
1833
|
+
s0 = peg$currPos;
|
1834
|
+
s1 = [];
|
1835
|
+
if (peg$c47.test(input.charAt(peg$currPos))) {
|
1836
|
+
s2 = input.charAt(peg$currPos);
|
1837
|
+
peg$currPos++;
|
1838
|
+
} else {
|
1839
|
+
s2 = peg$FAILED;
|
1840
|
+
if (peg$silentFails === 0) {
|
1841
|
+
peg$fail(peg$c48);
|
1842
|
+
}
|
1843
|
+
}
|
1844
|
+
if (s2 !== peg$FAILED) {
|
1845
|
+
while (s2 !== peg$FAILED) {
|
1846
|
+
s1.push(s2);
|
1847
|
+
if (peg$c47.test(input.charAt(peg$currPos))) {
|
1848
|
+
s2 = input.charAt(peg$currPos);
|
1849
|
+
peg$currPos++;
|
1850
|
+
} else {
|
1851
|
+
s2 = peg$FAILED;
|
1852
|
+
if (peg$silentFails === 0) {
|
1853
|
+
peg$fail(peg$c48);
|
1854
|
+
}
|
1855
|
+
}
|
1856
|
+
}
|
1857
|
+
} else {
|
1858
|
+
s1 = peg$FAILED;
|
1859
|
+
}
|
1860
|
+
if (s1 !== peg$FAILED) {
|
1861
|
+
peg$savedPos = s0;
|
1862
|
+
s1 = peg$c49(s1);
|
1863
|
+
}
|
1864
|
+
s0 = s1;
|
1865
|
+
return s0;
|
1866
|
+
}
|
1867
|
+
function peg$parsewsp() {
|
1868
|
+
var s0, s1;
|
1869
|
+
s0 = peg$currPos;
|
1870
|
+
if (peg$c50.test(input.charAt(peg$currPos))) {
|
1871
|
+
s1 = input.charAt(peg$currPos);
|
1872
|
+
peg$currPos++;
|
1873
|
+
} else {
|
1874
|
+
s1 = peg$FAILED;
|
1875
|
+
if (peg$silentFails === 0) {
|
1876
|
+
peg$fail(peg$c51);
|
1877
|
+
}
|
1878
|
+
}
|
1879
|
+
if (s1 !== peg$FAILED) {
|
1880
|
+
peg$savedPos = s0;
|
1881
|
+
s1 = peg$c37();
|
1882
|
+
}
|
1883
|
+
s0 = s1;
|
1884
|
+
return s0;
|
1885
|
+
}
|
1886
|
+
function merge(first, more) {
|
1887
|
+
if (!more) return [first];
|
1888
|
+
for (var a = [first], i = 0, l = more.length; i < l; i++) a[i + 1] = more[i][1];
|
1889
|
+
return a;
|
1890
|
+
}
|
1891
|
+
var cmds = { m: "moveto", l: "lineto", h: "horizontal lineto", v: "vertical lineto", c: "curveto", s: "smooth curveto", q: "quadratic curveto", t: "smooth quadratic curveto", a: "elliptical arc", z: "closepath" };
|
1892
|
+
for (var code in cmds) cmds[code.toUpperCase()] = cmds[code];
|
1893
|
+
function commands(code2, args) {
|
1894
|
+
if (!args) args = [{}];
|
1895
|
+
for (var i = args.length; i--; ) {
|
1896
|
+
var cmd = { code: code2, command: cmds[code2] };
|
1897
|
+
if (code2 == code2.toLowerCase()) cmd.relative = true;
|
1898
|
+
for (var k in args[i]) cmd[k] = args[i][k];
|
1899
|
+
args[i] = cmd;
|
1900
|
+
}
|
1901
|
+
return args;
|
1902
|
+
}
|
1903
|
+
peg$result = peg$startRuleFunction();
|
1904
|
+
if (peg$result !== peg$FAILED && peg$currPos === input.length) {
|
1905
|
+
return peg$result;
|
1906
|
+
} else {
|
1907
|
+
if (peg$result !== peg$FAILED && peg$currPos < input.length) {
|
1908
|
+
peg$fail(peg$endExpectation());
|
1909
|
+
}
|
1910
|
+
throw peg$buildStructuredError(
|
1911
|
+
peg$maxFailExpected,
|
1912
|
+
peg$maxFailPos < input.length ? input.charAt(peg$maxFailPos) : null,
|
1913
|
+
peg$maxFailPos < input.length ? peg$computeLocation(peg$maxFailPos, peg$maxFailPos + 1) : peg$computeLocation(peg$maxFailPos, peg$maxFailPos)
|
1914
|
+
);
|
1915
|
+
}
|
1916
|
+
}
|
1917
|
+
module2.exports = {
|
1918
|
+
SyntaxError: peg$SyntaxError2,
|
1919
|
+
parse: peg$parse2
|
1920
|
+
};
|
1921
|
+
}
|
1922
|
+
});
|
1923
|
+
|
1924
|
+
// node_modules/svg-path-parser/index.js
|
1925
|
+
var require_svg_path_parser = __commonJS({
|
1926
|
+
"node_modules/svg-path-parser/index.js"(exports2, module2) {
|
1927
|
+
"use strict";
|
1928
|
+
var parserFunction = require_parser().parse;
|
1929
|
+
parserFunction.parseSVG = parserFunction;
|
1930
|
+
parserFunction.makeAbsolute = makeSVGPathCommandsAbsolute;
|
1931
|
+
module2.exports = parserFunction;
|
1932
|
+
function makeSVGPathCommandsAbsolute(commands) {
|
1933
|
+
var subpathStart, prevCmd = { x: 0, y: 0 };
|
1934
|
+
var attr = { x: "x0", y: "y0", x1: "x0", y1: "y0", x2: "x0", y2: "y0" };
|
1935
|
+
commands.forEach(function(cmd) {
|
1936
|
+
if (cmd.command === "moveto") subpathStart = cmd;
|
1937
|
+
cmd.x0 = prevCmd.x;
|
1938
|
+
cmd.y0 = prevCmd.y;
|
1939
|
+
for (var a in attr) if (a in cmd) cmd[a] += cmd.relative ? cmd[attr[a]] : 0;
|
1940
|
+
if (!("x" in cmd)) cmd.x = prevCmd.x;
|
1941
|
+
if (!("y" in cmd)) cmd.y = prevCmd.y;
|
1942
|
+
cmd.relative = false;
|
1943
|
+
cmd.code = cmd.code.toUpperCase();
|
1944
|
+
if (cmd.command == "closepath") {
|
1945
|
+
cmd.x = subpathStart.x;
|
1946
|
+
cmd.y = subpathStart.y;
|
1947
|
+
}
|
1948
|
+
prevCmd = cmd;
|
1949
|
+
});
|
1950
|
+
return commands;
|
1951
|
+
}
|
1952
|
+
}
|
1953
|
+
});
|
1954
|
+
|
20
1955
|
// index.ts
|
21
1956
|
var schematic_symbols_exports = {};
|
22
1957
|
__export(schematic_symbols_exports, {
|
23
1958
|
BASE_SYMBOLS: () => BASE_SYMBOLS,
|
1959
|
+
getInnerSvg: () => getInnerSvg,
|
1960
|
+
getSvg: () => getSvg,
|
1961
|
+
resizeSymbol: () => resizeSymbol,
|
24
1962
|
symbols: () => symbols_default
|
25
1963
|
});
|
26
1964
|
module.exports = __toCommonJS(schematic_symbols_exports);
|
@@ -1685,11 +3623,202 @@ var symbols_default = {
|
|
1685
3623
|
"varistor_vert": varistor_vert_default
|
1686
3624
|
};
|
1687
3625
|
|
3626
|
+
// drawing/svgPathToPoints.ts
|
3627
|
+
var import_svg_path_parser = __toESM(require_svg_path_parser(), 1);
|
3628
|
+
|
3629
|
+
// drawing/pathToSvgD.ts
|
3630
|
+
function pathToSvgD(points, closed = false) {
|
3631
|
+
const pathCommands = points.map((point, index) => `${index === 0 ? "M" : "L"}${point.x},${point.y}`).join(" ");
|
3632
|
+
return closed ? `${pathCommands} Z` : pathCommands;
|
3633
|
+
}
|
3634
|
+
|
3635
|
+
// drawing/mapColor.ts
|
3636
|
+
var mapColor = (color) => {
|
3637
|
+
switch (color) {
|
3638
|
+
case "primary":
|
3639
|
+
return "black";
|
3640
|
+
case "secondary":
|
3641
|
+
return "gray";
|
3642
|
+
default:
|
3643
|
+
return color;
|
3644
|
+
}
|
3645
|
+
};
|
3646
|
+
|
3647
|
+
// drawing/getSvg.ts
|
3648
|
+
function createDiamondElement(center, size = 0.05) {
|
3649
|
+
const { x, y } = center;
|
3650
|
+
const halfSize = size / 2;
|
3651
|
+
return `<path d="M ${x} ${y - halfSize} L ${x + halfSize} ${y} L ${x} ${y + halfSize} L ${x - halfSize} ${y} Z" fill="green" />`;
|
3652
|
+
}
|
3653
|
+
function createTextElement(primitive) {
|
3654
|
+
const { x, y, text: text2, fontSize = 0.1, anchor } = primitive;
|
3655
|
+
let textAnchor;
|
3656
|
+
let dx = 0;
|
3657
|
+
let dy = 0;
|
3658
|
+
const capHeight = fontSize * 0.75;
|
3659
|
+
switch (anchor) {
|
3660
|
+
case "top_left":
|
3661
|
+
textAnchor = "start";
|
3662
|
+
dy = fontSize;
|
3663
|
+
break;
|
3664
|
+
case "top_right":
|
3665
|
+
textAnchor = "end";
|
3666
|
+
dy = fontSize;
|
3667
|
+
break;
|
3668
|
+
case "bottom_left":
|
3669
|
+
textAnchor = "start";
|
3670
|
+
break;
|
3671
|
+
case "bottom_right":
|
3672
|
+
textAnchor = "end";
|
3673
|
+
break;
|
3674
|
+
case "center":
|
3675
|
+
textAnchor = "middle";
|
3676
|
+
dy = fontSize / 2;
|
3677
|
+
break;
|
3678
|
+
case "middle_top":
|
3679
|
+
textAnchor = "middle";
|
3680
|
+
dy = capHeight;
|
3681
|
+
break;
|
3682
|
+
case "middle_bottom":
|
3683
|
+
textAnchor = "middle";
|
3684
|
+
break;
|
3685
|
+
case "middle_left":
|
3686
|
+
textAnchor = "start";
|
3687
|
+
dy = capHeight / 2;
|
3688
|
+
break;
|
3689
|
+
case "middle_right":
|
3690
|
+
textAnchor = "end";
|
3691
|
+
dy = capHeight / 2;
|
3692
|
+
break;
|
3693
|
+
}
|
3694
|
+
return {
|
3695
|
+
text: `<text x="${x}" y="${y}" dx="${dx}" dy="${dy}" text-anchor="${textAnchor}" style="font: ${fontSize ?? 0.1}px monospace; fill: ${mapColor("primary")}">${text2}</text>`,
|
3696
|
+
anchor: `<rect x="${x - 0.025 / 2}" y="${y - 0.025 / 2}" width="0.025" height="0.025" fill="blue" />`
|
3697
|
+
};
|
3698
|
+
}
|
3699
|
+
function createPortElement(port) {
|
3700
|
+
const { x, y, labels } = port;
|
3701
|
+
const rectSize = 0.05;
|
3702
|
+
const labelFontSize = 0.08;
|
3703
|
+
const label = labels[0] || "";
|
3704
|
+
return `
|
3705
|
+
<rect x="${x - rectSize / 2}" y="${y - rectSize / 2}" width="${rectSize}" height="${rectSize}" fill="red" />
|
3706
|
+
<text x="${x - labelFontSize / 2}" y="${y + rectSize + labelFontSize / 2}" text-anchor="middle" style="font: ${labelFontSize}px monospace; fill: #833;">${label}</text>
|
3707
|
+
`;
|
3708
|
+
}
|
3709
|
+
function getInnerSvg(symbol, options = {}) {
|
3710
|
+
const { debug = false } = options;
|
3711
|
+
const { primitives, size, ports } = symbol;
|
3712
|
+
const svgElements = primitives.map((primitive) => {
|
3713
|
+
switch (primitive.type) {
|
3714
|
+
case "path":
|
3715
|
+
return `<path d="${pathToSvgD(primitive.points, primitive.closed)}" fill="${primitive.fill ? mapColor(primitive.color) : "none"}" stroke="${mapColor(primitive.color)}" stroke-width="0.02" stroke-linecap="round" stroke-linejoin="round" />`;
|
3716
|
+
case "text":
|
3717
|
+
const textElements = createTextElement(primitive);
|
3718
|
+
return textElements.text + (debug ? textElements.anchor : "");
|
3719
|
+
case "circle":
|
3720
|
+
return `<circle cx="${primitive.x}" cy="${primitive.y}" r="${primitive.radius}" fill="${mapColor("primary")}" />`;
|
3721
|
+
case "box":
|
3722
|
+
return `<rect x="${primitive.x}" y="${primitive.y}" width="${primitive.width}" height="${primitive.height}" fill="${mapColor("primary")}" />`;
|
3723
|
+
default:
|
3724
|
+
return "";
|
3725
|
+
}
|
3726
|
+
});
|
3727
|
+
const portElements = ports.map(createPortElement).join("\n ");
|
3728
|
+
const centerDiamond = createDiamondElement(symbol.center);
|
3729
|
+
return [svgElements.join("\n "), portElements, centerDiamond].join("\n");
|
3730
|
+
}
|
3731
|
+
function getSvg(symbol, options = {}) {
|
3732
|
+
const { size } = symbol;
|
3733
|
+
const innerSvg = getInnerSvg(symbol, options);
|
3734
|
+
const bufferMultiple = 1.1;
|
3735
|
+
const w = size.width * bufferMultiple;
|
3736
|
+
const h = size.height * bufferMultiple;
|
3737
|
+
const viewBox = {
|
3738
|
+
x: symbol.center.x - w / 2,
|
3739
|
+
y: symbol.center.y - h / 2,
|
3740
|
+
width: w,
|
3741
|
+
height: h
|
3742
|
+
};
|
3743
|
+
if (options.width && !options.height) {
|
3744
|
+
options.height = options.width * (viewBox.height / viewBox.width);
|
3745
|
+
} else if (!options.width && options.height) {
|
3746
|
+
options.width = options.height * (viewBox.width / viewBox.height);
|
3747
|
+
} else if (!options.width && !options.height) {
|
3748
|
+
options.width = viewBox.width;
|
3749
|
+
options.height = viewBox.height;
|
3750
|
+
}
|
3751
|
+
return `<svg width="${options.width}" height="${options.height}" viewBox="${viewBox.x} ${viewBox.y} ${viewBox.width} ${viewBox.height}" xmlns="http://www.w3.org/2000/svg">${innerSvg}</svg>`;
|
3752
|
+
}
|
3753
|
+
|
3754
|
+
// drawing/resizeSymbol.ts
|
3755
|
+
function resizeSymbol(symbol, newSize) {
|
3756
|
+
const { width: oldWidth, height: oldHeight } = symbol.size;
|
3757
|
+
let scaleX = 1, scaleY = 1;
|
3758
|
+
if (newSize.width && newSize.height) {
|
3759
|
+
scaleX = newSize.width / oldWidth;
|
3760
|
+
scaleY = newSize.height / oldHeight;
|
3761
|
+
} else if (newSize.width) {
|
3762
|
+
scaleX = scaleY = newSize.width / oldWidth;
|
3763
|
+
} else if (newSize.height) {
|
3764
|
+
scaleX = scaleY = newSize.height / oldHeight;
|
3765
|
+
}
|
3766
|
+
const resizedPrimitives = symbol.primitives.map((primitive) => {
|
3767
|
+
switch (primitive.type) {
|
3768
|
+
case "path":
|
3769
|
+
return {
|
3770
|
+
...primitive,
|
3771
|
+
points: primitive.points.map((p) => ({
|
3772
|
+
x: p.x * scaleX,
|
3773
|
+
y: p.y * scaleY
|
3774
|
+
}))
|
3775
|
+
};
|
3776
|
+
case "text":
|
3777
|
+
case "circle":
|
3778
|
+
return {
|
3779
|
+
...primitive,
|
3780
|
+
x: primitive.x * scaleX,
|
3781
|
+
y: primitive.y * scaleY
|
3782
|
+
};
|
3783
|
+
case "box":
|
3784
|
+
return {
|
3785
|
+
...primitive,
|
3786
|
+
x: primitive.x * scaleX,
|
3787
|
+
y: primitive.y * scaleY,
|
3788
|
+
width: primitive.width * scaleX,
|
3789
|
+
height: primitive.height * scaleY
|
3790
|
+
};
|
3791
|
+
default:
|
3792
|
+
return primitive;
|
3793
|
+
}
|
3794
|
+
});
|
3795
|
+
return {
|
3796
|
+
...symbol,
|
3797
|
+
primitives: resizedPrimitives,
|
3798
|
+
center: {
|
3799
|
+
x: symbol.center.x * scaleX,
|
3800
|
+
y: symbol.center.y * scaleY
|
3801
|
+
},
|
3802
|
+
ports: symbol.ports.map((port) => ({
|
3803
|
+
...port,
|
3804
|
+
x: port.x * scaleX,
|
3805
|
+
y: port.y * scaleY
|
3806
|
+
})),
|
3807
|
+
size: {
|
3808
|
+
width: oldWidth * scaleX,
|
3809
|
+
height: oldHeight * scaleY
|
3810
|
+
}
|
3811
|
+
};
|
3812
|
+
}
|
3813
|
+
|
1688
3814
|
// index.ts
|
1689
3815
|
var BASE_SYMBOLS = Object.fromEntries(Object.keys(symbols_default).map((k) => [k, k]));
|
1690
3816
|
// Annotate the CommonJS export names for ESM import in node:
|
1691
3817
|
0 && (module.exports = {
|
1692
3818
|
BASE_SYMBOLS,
|
3819
|
+
getInnerSvg,
|
3820
|
+
getSvg,
|
3821
|
+
resizeSymbol,
|
1693
3822
|
symbols
|
1694
3823
|
});
|
1695
3824
|
//# sourceMappingURL=index.cjs.map
|