diff options
| author | frozolotl <44589151+frozolotl@users.noreply.github.com> | 2023-11-08 20:11:02 +1000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-11-08 11:11:02 +0100 |
| commit | 7f1c38548a89e2dd7c88d842532432dfa953c091 (patch) | |
| tree | 0a0ff68789bb1f70c9fbdcf47efbb9ed59c937b1 | |
| parent | cfb767346e7879ea021187856a61eedaa1d46f7c (diff) | |
Fix color export for SVG (#2610)
| -rw-r--r-- | crates/typst/src/export/svg.rs | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/crates/typst/src/export/svg.rs b/crates/typst/src/export/svg.rs index 00fc5c2b..06066428 100644 --- a/crates/typst/src/export/svg.rs +++ b/crates/typst/src/export/svg.rs @@ -1243,7 +1243,7 @@ impl ColorEncode for Color { Color::LinearRgb(rgb) => { if rgb.alpha != 1.0 { eco_format!( - "color(srgb-linear {:.3} {:.3} {:.3} / {:.3})", + "color(srgb-linear {:.5} {:.5} {:.5} / {:.5})", rgb.red, rgb.green, rgb.blue, @@ -1251,7 +1251,7 @@ impl ColorEncode for Color { ) } else { eco_format!( - "color(srgb-linear {:.3} {:.3} {:.3})", + "color(srgb-linear {:.5} {:.5} {:.5})", rgb.red, rgb.green, rgb.blue, @@ -1261,16 +1261,16 @@ impl ColorEncode for Color { Color::Oklab(oklab) => { if oklab.alpha != 1.0 { eco_format!( - "oklab({:?} {:.3} {:.3} / {:.3})", - Ratio::new(oklab.l as f64), + "oklab({:.3}% {:.5} {:.5} / {:.5})", + oklab.l * 100.0, oklab.a, oklab.b, oklab.alpha ) } else { eco_format!( - "oklab({:?} {:.3} {:.3})", - Ratio::new(oklab.l as f64), + "oklab({:.3}% {:.5} {:.5})", + oklab.l * 100.0, oklab.a, oklab.b, ) @@ -1279,18 +1279,18 @@ impl ColorEncode for Color { Color::Hsl(hsl) => { if hsl.alpha != 1.0 { eco_format!( - "hsla({:?} {:?} {:?} / {:.3})", - Angle::deg(hsl.hue.into_degrees() as f64), - Ratio::new(hsl.saturation as f64), - Ratio::new(hsl.lightness as f64), + "hsla({:.3}deg {:.3}% {:.3}% / {:.5})", + hsl.hue.into_degrees(), + hsl.saturation * 100.0, + hsl.lightness * 100.0, hsl.alpha, ) } else { eco_format!( - "hsl({:?} {:?} {:?})", - Angle::deg(hsl.hue.into_degrees() as f64), - Ratio::new(hsl.saturation as f64), - Ratio::new(hsl.lightness as f64), + "hsl({:.3}deg {:.3}% {:.3}%)", + hsl.hue.into_degrees(), + hsl.saturation * 100.0, + hsl.lightness * 100.0, ) } } |
