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) => {
|
Color::LinearRgb(rgb) => {
|
||||||
if rgb.alpha != 1.0 {
|
if rgb.alpha != 1.0 {
|
||||||
eco_format!(
|
eco_format!(
|
||||||
"color(srgb-linear {:.3} {:.3} {:.3} / {:.3})",
|
"color(srgb-linear {:.5} {:.5} {:.5} / {:.5})",
|
||||||
rgb.red,
|
rgb.red,
|
||||||
rgb.green,
|
rgb.green,
|
||||||
rgb.blue,
|
rgb.blue,
|
||||||
@ -1251,7 +1251,7 @@ impl ColorEncode for Color {
|
|||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
eco_format!(
|
eco_format!(
|
||||||
"color(srgb-linear {:.3} {:.3} {:.3})",
|
"color(srgb-linear {:.5} {:.5} {:.5})",
|
||||||
rgb.red,
|
rgb.red,
|
||||||
rgb.green,
|
rgb.green,
|
||||||
rgb.blue,
|
rgb.blue,
|
||||||
@ -1261,16 +1261,16 @@ impl ColorEncode for Color {
|
|||||||
Color::Oklab(oklab) => {
|
Color::Oklab(oklab) => {
|
||||||
if oklab.alpha != 1.0 {
|
if oklab.alpha != 1.0 {
|
||||||
eco_format!(
|
eco_format!(
|
||||||
"oklab({:?} {:.3} {:.3} / {:.3})",
|
"oklab({:.3}% {:.5} {:.5} / {:.5})",
|
||||||
Ratio::new(oklab.l as f64),
|
oklab.l * 100.0,
|
||||||
oklab.a,
|
oklab.a,
|
||||||
oklab.b,
|
oklab.b,
|
||||||
oklab.alpha
|
oklab.alpha
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
eco_format!(
|
eco_format!(
|
||||||
"oklab({:?} {:.3} {:.3})",
|
"oklab({:.3}% {:.5} {:.5})",
|
||||||
Ratio::new(oklab.l as f64),
|
oklab.l * 100.0,
|
||||||
oklab.a,
|
oklab.a,
|
||||||
oklab.b,
|
oklab.b,
|
||||||
)
|
)
|
||||||
@ -1279,18 +1279,18 @@ impl ColorEncode for Color {
|
|||||||
Color::Hsl(hsl) => {
|
Color::Hsl(hsl) => {
|
||||||
if hsl.alpha != 1.0 {
|
if hsl.alpha != 1.0 {
|
||||||
eco_format!(
|
eco_format!(
|
||||||
"hsla({:?} {:?} {:?} / {:.3})",
|
"hsla({:.3}deg {:.3}% {:.3}% / {:.5})",
|
||||||
Angle::deg(hsl.hue.into_degrees() as f64),
|
hsl.hue.into_degrees(),
|
||||||
Ratio::new(hsl.saturation as f64),
|
hsl.saturation * 100.0,
|
||||||
Ratio::new(hsl.lightness as f64),
|
hsl.lightness * 100.0,
|
||||||
hsl.alpha,
|
hsl.alpha,
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
eco_format!(
|
eco_format!(
|
||||||
"hsl({:?} {:?} {:?})",
|
"hsl({:.3}deg {:.3}% {:.3}%)",
|
||||||
Angle::deg(hsl.hue.into_degrees() as f64),
|
hsl.hue.into_degrees(),
|
||||||
Ratio::new(hsl.saturation as f64),
|
hsl.saturation * 100.0,
|
||||||
Ratio::new(hsl.lightness as f64),
|
hsl.lightness * 100.0,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user