MCPcopy Index your code
hub / github.com/benfry/processing4 / parseRGB

Method parseRGB

core/src/processing/core/PShapeSVG.java:1393–1412  ·  view source on GitHub ↗
(String what)

Source from the content-addressed store, hash-verified

1391 */
1392
1393 static protected int parseRGB(String what) {
1394 int leftParen = what.indexOf('(') + 1;
1395 int rightParen = what.indexOf(')');
1396 String sub = what.substring(leftParen, rightParen);
1397 String[] values = PApplet.splitTokens(sub, ", ");
1398 int rgbValue = 0;
1399 if (values.length == 3) {
1400 // Color spec allows for rgb values to be percentages.
1401 for (int i = 0; i < 3; i++) {
1402 rgbValue <<= 8;
1403 if (values[i].endsWith("%")) {
1404 rgbValue |= (int)(PApplet.constrain(255*parseFloatOrPercent(values[i]), 0, 255));
1405 } else {
1406 rgbValue |= PApplet.constrain(PApplet.parseInt(values[i]), 0, 255);
1407 }
1408 }
1409 } else System.err.println("Could not read color \"" + what + "\".");
1410
1411 return rgbValue;
1412 }
1413
1414
1415 //static protected Map<String, String> parseStyleAttributes(String style) {

Callers 1

parseSimpleColorMethod · 0.95

Calls 5

splitTokensMethod · 0.95
constrainMethod · 0.95
parseFloatOrPercentMethod · 0.95
parseIntMethod · 0.95
printlnMethod · 0.45

Tested by

no test coverage detected