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