Auto merge of #454 - bellwether-softworks:Svg-Fill-Color, r=jdm

Passing actual color in fill attribute

Presently, when serializing to SVG, the `fill` attribute is being populated with a `PaintId` identifier, e.g.:

```svg
<path fill="PaintId(1)" d="M 0 0 L 431.8 0 L 431.8 279.4 L 0 279.4 z" />
```

This PR instead utilizes the base color, which results in the following alternative output:

```svg
<path fill="#ffffff" d="M 0 0 L 431.8 0 L 431.8 279.4 L 0 279.4 z" />
```
This commit is contained in:
bors-servo 2021-05-22 17:10:29 -04:00 committed by GitHub
commit 512087d365
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 1 deletions

View File

@ -57,11 +57,13 @@ fn export_svg<W: Write>(scene: &Scene, writer: &mut W) -> io::Result<()> {
for draw_path_index in 0..scene.draw_path_count() { for draw_path_index in 0..scene.draw_path_count() {
let draw_path_id = DrawPathId(draw_path_index); let draw_path_id = DrawPathId(draw_path_index);
let draw_path = scene.get_draw_path(draw_path_id); let draw_path = scene.get_draw_path(draw_path_id);
let paint = scene.get_paint(draw_path.paint);
write!(writer, " <path")?; write!(writer, " <path")?;
if !draw_path.name.is_empty() { if !draw_path.name.is_empty() {
write!(writer, " id=\"{}\"", draw_path.name)?; write!(writer, " id=\"{}\"", draw_path.name)?;
} }
writeln!(writer, " fill=\"{:?}\" d=\"{:?}\" />", draw_path.paint, draw_path.outline)?; writeln!(writer, " fill=\"{:?}\" d=\"{:?}\" />", paint.base_color(), draw_path.outline)?;
} }
writeln!(writer, "</svg>")?; writeln!(writer, "</svg>")?;
Ok(()) Ok(())