diff options
| author | Sébastien d'Herbais de Thun <sebastien.d.herbais@gmail.com> | 2023-09-19 15:48:33 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-09-19 15:48:33 +0200 |
| commit | 163c2e1aa27169c1eba946204096d3e8fdfd3c18 (patch) | |
| tree | 0f4c58bf41239865a6cdcaac77a6314dbbb5b8c8 /crates/typst-library/src/text | |
| parent | bb59f0e2b21c42a796b5eb8d8882a1d2b2a0c35f (diff) | |
Gradient Part 1 - Color rework (#2171)
Diffstat (limited to 'crates/typst-library/src/text')
| -rw-r--r-- | crates/typst-library/src/text/deco.rs | 2 | ||||
| -rw-r--r-- | crates/typst-library/src/text/raw.rs | 9 |
2 files changed, 6 insertions, 5 deletions
diff --git a/crates/typst-library/src/text/deco.rs b/crates/typst-library/src/text/deco.rs index 4f85abef..6fd56bb6 100644 --- a/crates/typst-library/src/text/deco.rs +++ b/crates/typst-library/src/text/deco.rs @@ -240,7 +240,7 @@ pub struct HighlightElem { /// ```example /// This is #highlight(fill: blue)[with blue]. /// ``` - #[default(Color::Rgba(RgbaColor::new(0xFF, 0xFF, 0x5F, 0xFF)).into())] + #[default(Color::from_u8(0xFF, 0xFF, 0x5F, 0xFF).into())] pub fill: Paint, /// The top end of the background rectangle. diff --git a/crates/typst-library/src/text/raw.rs b/crates/typst-library/src/text/raw.rs index 1f46f94d..688e69d8 100644 --- a/crates/typst-library/src/text/raw.rs +++ b/crates/typst-library/src/text/raw.rs @@ -454,11 +454,12 @@ fn styled(piece: &str, foreground: Paint, style: synt::Style) -> Content { body } -fn to_typst(synt::Color { r, g, b, a }: synt::Color) -> RgbaColor { - RgbaColor { r, g, b, a } +fn to_typst(synt::Color { r, g, b, a }: synt::Color) -> Color { + Color::from_u8(r, g, b, a) } -fn to_syn(RgbaColor { r, g, b, a }: RgbaColor) -> synt::Color { +fn to_syn(color: Color) -> synt::Color { + let [r, g, b, a] = color.to_vec4_u8(); synt::Color { r, g, b, a } } @@ -628,7 +629,7 @@ fn item( synt::ThemeItem { scope: scope.parse().unwrap(), style: synt::StyleModifier { - foreground: color.map(|s| to_syn(s.parse::<RgbaColor>().unwrap())), + foreground: color.map(|s| to_syn(s.parse::<Color>().unwrap())), background: None, font_style, }, |
