summaryrefslogtreecommitdiff
path: root/crates/typst-library/src
diff options
context:
space:
mode:
authorSébastien d'Herbais de Thun <sebastien.d.herbais@gmail.com>2023-09-19 15:48:33 +0200
committerGitHub <noreply@github.com>2023-09-19 15:48:33 +0200
commit163c2e1aa27169c1eba946204096d3e8fdfd3c18 (patch)
tree0f4c58bf41239865a6cdcaac77a6314dbbb5b8c8 /crates/typst-library/src
parentbb59f0e2b21c42a796b5eb8d8882a1d2b2a0c35f (diff)
Gradient Part 1 - Color rework (#2171)
Diffstat (limited to 'crates/typst-library/src')
-rw-r--r--crates/typst-library/src/lib.rs1
-rw-r--r--crates/typst-library/src/text/deco.rs2
-rw-r--r--crates/typst-library/src/text/raw.rs9
3 files changed, 7 insertions, 5 deletions
diff --git a/crates/typst-library/src/lib.rs b/crates/typst-library/src/lib.rs
index bdb97f84..03e96441 100644
--- a/crates/typst-library/src/lib.rs
+++ b/crates/typst-library/src/lib.rs
@@ -63,6 +63,7 @@ fn prelude(global: &mut Scope) {
global.define("green", Color::GREEN);
global.define("lime", Color::LIME);
global.define("luma", Color::luma_data());
+ global.define("oklab", Color::oklab_data());
global.define("rgb", Color::rgb_data());
global.define("cmyk", Color::cmyk_data());
global.define("range", Array::range_data());
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,
},