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

Method parseSimpleColor

core/src/processing/core/PShapeSVG.java:1317–1335  ·  view source on GitHub ↗

Parses the "color" datatype only, and prints an error if it is not of this form. http://www.w3.org/TR/SVG/types.html#DataTypeColor @return 0xRRGGBB (no alpha). Zero on error.

(String colorText)

Source from the content-addressed store, hash-verified

1315 * @return 0xRRGGBB (no alpha). Zero on error.
1316 */
1317 static protected int parseSimpleColor(String colorText) {
1318 colorText = colorText.toLowerCase().trim();
1319 //if (colorNames.containsKey(colorText)) {
1320 if (colorNames.hasKey(colorText)) {
1321 return colorNames.get(colorText);
1322 } else if (colorText.startsWith("#")) {
1323 if (colorText.length() == 4) {
1324 // Short form: #ABC, transform to long form #AABBCC
1325 colorText = colorText.replaceAll("^#(.)(.)(.)$", "#$1$1$2$2$3$3");
1326 }
1327 return (Integer.parseInt(colorText.substring(1), 16)) & 0xFFFFFF;
1328 //System.out.println("hex for fill is " + PApplet.hex(fillColor));
1329 } else if (colorText.startsWith("rgb")) {
1330 return parseRGB(colorText);
1331 } else {
1332 System.err.println("Cannot parse \"" + colorText + "\".");
1333 return 0;
1334 }
1335 }
1336
1337
1338 /**

Callers 2

setColorMethod · 0.95
GradientMethod · 0.80

Calls 8

parseRGBMethod · 0.95
startsWithMethod · 0.80
parseIntMethod · 0.80
getMethod · 0.65
trimMethod · 0.45
hasKeyMethod · 0.45
replaceAllMethod · 0.45
printlnMethod · 0.45

Tested by

no test coverage detected