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

Method Gradient

core/src/processing/core/PShapeSVG.java:1499–1536  ·  view source on GitHub ↗
(PShapeSVG parent, XML properties)

Source from the content-addressed store, hash-verified

1497 public int count;
1498
1499 public Gradient(PShapeSVG parent, XML properties) {
1500 super(parent, properties, true);
1501
1502 XML elements[] = properties.getChildren();
1503 offset = new float[elements.length];
1504 color = new int[elements.length];
1505
1506 // <stop offset="0" style="stop-color:#967348"/>
1507 for (int i = 0; i < elements.length; i++) {
1508 XML elem = elements[i];
1509 String name = elem.getName();
1510 if (name.equals("stop")) {
1511 String offsetAttr = elem.getString("offset");
1512 offset[count] = parseFloatOrPercent(offsetAttr);
1513
1514 String style = elem.getString("style");
1515 //Map<String, String> styles = parseStyleAttributes(style);
1516 StringDict styles = parseStyleAttributes(style);
1517
1518 String colorStr = styles.get("stop-color");
1519 if (colorStr == null) {
1520 colorStr = elem.getString("stop-color");
1521 if (colorStr == null) colorStr = "#000000";
1522 }
1523 String opacityStr = styles.get("stop-opacity");
1524 if (opacityStr == null) {
1525 opacityStr = elem.getString("stop-opacity");
1526 if (opacityStr == null) opacityStr = "1";
1527 }
1528 int tupacity = PApplet.constrain(
1529 (int)(PApplet.parseFloat(opacityStr) * 255), 0, 255);
1530 color[count] = (tupacity << 24) | parseSimpleColor(colorStr);
1531 count++;
1532 }
1533 }
1534 offset = PApplet.subset(offset, 0, count);
1535 color = PApplet.subset(color, 0, count);
1536 }
1537 }
1538
1539

Callers

nothing calls this directly

Calls 11

getNameMethod · 0.95
getStringMethod · 0.95
getMethod · 0.95
constrainMethod · 0.95
parseFloatMethod · 0.95
subsetMethod · 0.95
parseFloatOrPercentMethod · 0.80
parseStyleAttributesMethod · 0.80
parseSimpleColorMethod · 0.80
getChildrenMethod · 0.45
equalsMethod · 0.45

Tested by

no test coverage detected