1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | exports.scanSegment = void 0;
|
4 | var finalize_segment_1 = require("./finalize-segment");
|
5 | var params_count_1 = require("./params-count");
|
6 | var scan_flag_1 = require("./scan-flag");
|
7 | var scan_param_1 = require("./scan-param");
|
8 | var skip_spaces_1 = require("./skip-spaces");
|
9 | var is_path_command_1 = require("./is-path-command");
|
10 | var is_digit_start_1 = require("./is-digit-start");
|
11 | var is_arc_command_1 = require("./is-arc-command");
|
12 |
|
13 |
|
14 |
|
15 |
|
16 | function scanSegment(path) {
|
17 | var max = path.max, pathValue = path.pathValue, index = path.index;
|
18 | var cmdCode = pathValue.charCodeAt(index);
|
19 | var reqParams = params_count_1.paramsCount[pathValue[index].toLowerCase()];
|
20 | path.segmentStart = index;
|
21 | if (!(0, is_path_command_1.isPathCommand)(cmdCode)) {
|
22 | path.err = "[path-util]: Invalid path value \"" + pathValue[index] + "\" is not a path command";
|
23 | return;
|
24 | }
|
25 | path.index += 1;
|
26 | (0, skip_spaces_1.skipSpaces)(path);
|
27 | path.data = [];
|
28 | if (!reqParams) {
|
29 |
|
30 | (0, finalize_segment_1.finalizeSegment)(path);
|
31 | return;
|
32 | }
|
33 | for (;;) {
|
34 | for (var i = reqParams; i > 0; i -= 1) {
|
35 | if ((0, is_arc_command_1.isArcCommand)(cmdCode) && (i === 3 || i === 4))
|
36 | (0, scan_flag_1.scanFlag)(path);
|
37 | else
|
38 | (0, scan_param_1.scanParam)(path);
|
39 | if (path.err.length) {
|
40 | return;
|
41 | }
|
42 | path.data.push(path.param);
|
43 | (0, skip_spaces_1.skipSpaces)(path);
|
44 |
|
45 | if (path.index < max && pathValue.charCodeAt(path.index) === 0x2c ) {
|
46 | path.index += 1;
|
47 | (0, skip_spaces_1.skipSpaces)(path);
|
48 | }
|
49 | }
|
50 | if (path.index >= path.max) {
|
51 | break;
|
52 | }
|
53 |
|
54 | if (!(0, is_digit_start_1.isDigitStart)(pathValue.charCodeAt(path.index))) {
|
55 | break;
|
56 | }
|
57 | }
|
58 | (0, finalize_segment_1.finalizeSegment)(path);
|
59 | }
|
60 | exports.scanSegment = scanSegment;
|
61 |
|
\ | No newline at end of file |