Post-process SVG to improve line rendering quality: 1. Inject round joins/caps so thick strokes blend smoothly at vertices. 2. Simplify dense polylines (Ramer-Douglas-Peucker) to remove sub-pixel zigzag noise caused by plotters' integer coordinate rounding. No-op for plots without polylines (bar/box/heatmap).
(svg: &mut String)
| 199 | /// |
| 200 | /// No-op for plots without polylines (bar/box/heatmap). |
| 201 | fn smooth_svg_lines(svg: &mut String) { |
| 202 | if !svg.contains("<polyline ") { |
| 203 | return; |
| 204 | } |
| 205 | *svg = svg.replace( |
| 206 | "<polyline fill=\"none\"", |
| 207 | "<polyline stroke-linejoin=\"round\" stroke-linecap=\"round\" fill=\"none\"", |
| 208 | ); |
| 209 | simplify_svg_polylines(svg); |
| 210 | } |
| 211 | |
| 212 | /// Find every `points="..."` attribute in the SVG and, when the polyline has |
| 213 | /// enough vertices, apply Ramer-Douglas-Peucker to remove redundant ones. |
no test coverage detected