mirror of
https://github.com/typst/typst
synced 2025-05-19 11:35:27 +08:00
Fix color export for SVG (#2610)
This commit is contained in:
parent
cfb767346e
commit
7f1c38548a
@ -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,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user