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