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

Method parseRGB

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

Source from the content-addressed store, hash-verified

1384 */
1385
1386 static protected int parseRGB(String what) {
1387 int leftParen = what.indexOf('(') + 1;
1388 int rightParen = what.indexOf(')');
1389 String sub = what.substring(leftParen, rightParen);
1390 String[] values = PApplet.splitTokens(sub, ", ");
1391 int rgbValue = 0;
1392 if (values.length == 3) {
1393 // Color spec allows for rgb values to be percentages.
1394 for (int i = 0; i < 3; i++) {
1395 rgbValue <<= 8;
1396 if (values[i].endsWith("%")) {
1397 rgbValue |= (int)(PApplet.constrain(255*parseFloatOrPercent(values[i]), 0, 255));
1398 } else {
1399 rgbValue |= PApplet.constrain(PApplet.parseInt(values[i]), 0, 255);
1400 }
1401 }
1402 } else System.err.println("Could not read color \"" + what + "\".");
1403
1404 return rgbValue;
1405 }
1406
1407
1408 //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