(String what)
| 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) { |
no test coverage detected