MCPcopy Index your code
hub / github.com/processing/processing / parsePoly

Method parsePoly

core/src/processing/core/PShapeSVG.java:475–503  ·  view source on GitHub ↗

Parse a polyline or polygon from an SVG file. Syntax defined at http://www.w3.org/TR/SVG/shapes.html#PointsBNF @param close true if shape is closed (polygon), false if not (polyline)

(boolean close)

Source from the content-addressed store, hash-verified

473 * @param close true if shape is closed (polygon), false if not (polyline)
474 */
475 protected void parsePoly(boolean close) {
476 family = PATH;
477 this.close = close;
478
479 String pointsAttr = element.getString("points");
480 if (pointsAttr != null) {
481 Pattern pattern = Pattern.compile("([+-]?[\\d]+(\\.[\\d]+)?([eE][+-][\\d]+)?)(,?\\s*)([+-]?[\\d]+(\\.[\\d]+)?([eE][+-][\\d]+)?)");
482 Matcher matcher = pattern.matcher(pointsAttr);
483 vertexCount = 0;
484 while (matcher.find()) {
485 vertexCount++;
486 }
487 matcher.reset();
488 vertices = new float[vertexCount][2];
489 for (int i = 0; i < vertexCount; i++) {
490 matcher.find();
491 vertices[i][X] = Float.parseFloat(matcher.group(1));
492 vertices[i][Y] = Float.parseFloat(matcher.group(5));
493 }
494// String[] pointsBuffer = PApplet.splitTokens(pointsAttr);
495// vertexCount = pointsBuffer.length;
496// vertices = new float[vertexCount][2];
497// for (int i = 0; i < vertexCount; i++) {
498// String pb[] = PApplet.splitTokens(pointsBuffer[i], ", \t\r\n");
499// vertices[i][X] = Float.parseFloat(pb[0]);
500// vertices[i][Y] = Float.parseFloat(pb[1]);
501// }
502 }
503 }
504
505
506 protected void parsePath() {

Callers 1

parseChildMethod · 0.95

Calls 5

findMethod · 0.80
parseFloatMethod · 0.80
getStringMethod · 0.65
resetMethod · 0.65
compileMethod · 0.45

Tested by

no test coverage detected