(PShapeSVG parent, XML properties)
| 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 |
nothing calls this directly
no test coverage detected