Read a element into a vec4. Returns nullopt when the element is null or "rgba" fails to parse; default {0.7,0.7,0.7,1.0} lives here so both callers share the same fallback.
| 122 | // element is null or "rgba" fails to parse; default {0.7,0.7,0.7,1.0} lives |
| 123 | // here so both callers share the same fallback. |
| 124 | std::optional<glm::vec4> readColorRgba(const QDomElement& color_el) { |
| 125 | if (color_el.isNull()) { |
| 126 | return std::nullopt; |
| 127 | } |
| 128 | std::array<double, 4> rgba{0.7, 0.7, 0.7, 1.0}; |
| 129 | if (!parseDoubles(color_el.attribute(QStringLiteral("rgba")), rgba)) { |
| 130 | return std::nullopt; |
| 131 | } |
| 132 | return glm::vec4{ |
| 133 | static_cast<float>(rgba[0]), static_cast<float>(rgba[1]), static_cast<float>(rgba[2]), |
| 134 | static_cast<float>(rgba[3])}; |
| 135 | } |
| 136 | |
| 137 | // Fills geom.color and sets geom.has_color when an inline or named color is |
| 138 | // found; otherwise leaves the LinkGeom defaults. |
no test coverage detected