diff options
| author | Martin Haug <mhaug@live.de> | 2022-02-08 21:12:09 +0100 |
|---|---|---|
| committer | Martin Haug <mhaug@live.de> | 2022-02-08 21:12:09 +0100 |
| commit | fe70db1f4ce078f7b41c163a1c0ead31fd04850a (patch) | |
| tree | 0f85390a89a05dc763cbc2eb6c611c48877c08cd /tests | |
| parent | 62cf2a19d7207118f115c05c8f7c453d6db77a0a (diff) | |
New color stuff
- CMYK function
- More default colors
- Interpret RGB values as sRGB
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/ref/utility/color.png | bin | 0 -> 168 bytes | |||
| -rw-r--r-- | tests/typ/layout/stack-1.typ | 4 | ||||
| -rw-r--r-- | tests/typ/utility/color.typ | 19 | ||||
| -rw-r--r-- | tests/typeset.rs | 4 |
4 files changed, 15 insertions, 12 deletions
diff --git a/tests/ref/utility/color.png b/tests/ref/utility/color.png Binary files differnew file mode 100644 index 00000000..e7d87ba4 --- /dev/null +++ b/tests/ref/utility/color.png diff --git a/tests/typ/layout/stack-1.typ b/tests/typ/layout/stack-1.typ index a4a0d6b8..d8075e9d 100644 --- a/tests/typ/layout/stack-1.typ +++ b/tests/typ/layout/stack-1.typ @@ -8,8 +8,8 @@ ) #let shaded = { - let v = 0 - let next() = { v += 0.1; rgb(v, v, v) } + let v = 0% + let next() = { v += 10%; rgb(v, v, v) } w => rect(width: w, height: 10pt, fill: next()) } diff --git a/tests/typ/utility/color.typ b/tests/typ/utility/color.typ index 759672ff..fa30a4f2 100644 --- a/tests/typ/utility/color.typ +++ b/tests/typ/utility/color.typ @@ -3,20 +3,21 @@ --- // Compare both ways. -#test(rgb(0.0, 0.3, 0.7), rgb("004db3")) +#test(rgb(0%, 30%, 70%), rgb("004db3")) // Alpha channel. -#test(rgb(1.0, 0.0, 0.0, 0.5), rgb("ff000080")) +#test(rgb(255, 0, 0, 50%), rgb("ff000080")) --- -// Error for values that are out of range. -// Error: 11-14 value must be between 0.0 and 1.0 -#test(rgb(-30, 15.5, 0.5)) +// Test CMYK color conversion. +// Ref: true +#rect(fill: cmyk(69%, 11%, 69%, 41%)) +#rect(fill: cmyk(50%, 64%, 16%, 17%)) --- // Error for values that are out of range. -// Error: 26-30 value must be between 0.0 and 1.0 -#test(rgb(0.1, 0.2, 0.3, -0.1)) +// Error: 11-14 must be between 0 and 255 +#test(rgb(-30, 15, 50)) --- // Error: 6-11 invalid hex string @@ -31,5 +32,5 @@ #rgb(0, 1) --- -// Error: 21-26 expected float, found boolean -#rgb(0.1, 0.2, 0.3, false) +// Error: 21-26 expected integer or relative, found boolean +#rgb(10%, 20%, 30%, false) diff --git a/tests/typeset.rs b/tests/typeset.rs index f7f2eccf..31610ffc 100644 --- a/tests/typeset.rs +++ b/tests/typeset.rs @@ -11,7 +11,7 @@ use walkdir::WalkDir; use typst::diag::Error; use typst::eval::{Smart, StyleMap, Value}; use typst::frame::{Element, Frame}; -use typst::geom::Length; +use typst::geom::{Length, RgbaColor}; use typst::library::{PageNode, TextNode}; use typst::loading::FsLoader; use typst::parse::Scanner; @@ -77,6 +77,8 @@ fn main() { // Hook up an assert function into the global scope. let mut std = typst::library::new(); + std.def_const("conifer", RgbaColor::new(0x9f, 0xEB, 0x52, 0xFF)); + std.def_const("forest", RgbaColor::new(0x43, 0xA1, 0x27, 0xFF)); std.def_func("test", move |_, args| { let lhs = args.expect::<Value>("left-hand side")?; let rhs = args.expect::<Value>("right-hand side")?; |
