MCPcopy Index your code
hub / github.com/benfry/processing4 / Gradient

Method Gradient

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

Source from the content-addressed store, hash-verified

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

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