()
| 504 | |
| 505 | |
| 506 | protected void parsePath() { |
| 507 | family = PATH; |
| 508 | kind = 0; |
| 509 | |
| 510 | String pathData = element.getString("d"); |
| 511 | if (pathData == null || PApplet.trim(pathData).length() == 0) { |
| 512 | return; |
| 513 | } |
| 514 | char[] pathDataChars = pathData.toCharArray(); |
| 515 | |
| 516 | StringBuilder pathBuffer = new StringBuilder(); |
| 517 | boolean lastSeparate = false; |
| 518 | boolean isOnDecimal = false; |
| 519 | |
| 520 | for (int i = 0; i < pathDataChars.length; i++) { |
| 521 | char c = pathDataChars[i]; |
| 522 | boolean separate = false; |
| 523 | |
| 524 | if (c == 'M' || c == 'm' || |
| 525 | c == 'L' || c == 'l' || |
| 526 | c == 'H' || c == 'h' || |
| 527 | c == 'V' || c == 'v' || |
| 528 | c == 'C' || c == 'c' || // beziers |
| 529 | c == 'S' || c == 's' || |
| 530 | c == 'Q' || c == 'q' || // quadratic beziers |
| 531 | c == 'T' || c == 't' || |
| 532 | c == 'A' || c == 'a' || // elliptical arc |
| 533 | c == 'Z' || c == 'z' || // closepath |
| 534 | c == ',') { |
| 535 | separate = true; |
| 536 | if (i != 0) { |
| 537 | pathBuffer.append("|"); |
| 538 | } |
| 539 | } |
| 540 | if (c == 'Z' || c == 'z') { |
| 541 | separate = false; |
| 542 | } |
| 543 | if (c == '.' && !isOnDecimal) { |
| 544 | isOnDecimal = true; |
| 545 | } |
| 546 | else if (isOnDecimal && (c < '0' || c > '9')) { |
| 547 | pathBuffer.append("|"); |
| 548 | isOnDecimal = c == '.'; |
| 549 | } |
| 550 | if (c == '-' && !lastSeparate) { |
| 551 | // allow for 'e' notation in numbers, e.g. 2.10e-9 |
| 552 | // https://download.processing.org/bugzilla/1408.html |
| 553 | if (i == 0 || pathDataChars[i-1] != 'e') { |
| 554 | pathBuffer.append("|"); |
| 555 | } |
| 556 | } |
| 557 | if (c != ',') { |
| 558 | pathBuffer.append(c); //"" + pathDataBuffer.charAt(i)); |
| 559 | } |
| 560 | if (separate && c != ',' && c != '-') { |
| 561 | pathBuffer.append("|"); |
| 562 | } |
| 563 | lastSeparate = separate; |
no test coverage detected