diff options
| author | frozolotl <44589151+frozolotl@users.noreply.github.com> | 2024-03-19 10:36:30 +0100 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2024-05-16 12:46:18 +0200 |
| commit | babe44c5d674b1eb37594b908ca858fa84992b4a (patch) | |
| tree | e662bba9a9785232df948fe7d34948ca223fbc34 | |
| parent | b279b9d21490333958ea79ca4d882f70c9bff529 (diff) | |
Fix color documentation (#3688)
| -rw-r--r-- | crates/typst/src/visualize/color.rs | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/crates/typst/src/visualize/color.rs b/crates/typst/src/visualize/color.rs index 309619de..185e990b 100644 --- a/crates/typst/src/visualize/color.rs +++ b/crates/typst/src/visualize/color.rs @@ -117,13 +117,12 @@ static TO_SRGB: Lazy<qcms::Transform> = Lazy::new(|| { /// columns: 9, /// gutter: 10pt, /// ..colors.map(name => { -/// let c = eval(name) -/// let cp = c.components() -/// let x = cp.sum() / cp.len() -/// set text(fill: white) if x < 50% -/// set square(stroke: black) if c == white +/// let col = eval(name) +/// let luminance = luma(col).components().first() +/// set text(fill: white) if luminance < 50% +/// set square(stroke: black) if col == white /// set align(center + horizon) -/// square(size: 50pt, fill: c, name) +/// square(size: 50pt, fill: col, name) /// }) /// ) /// ``` @@ -736,7 +735,7 @@ impl Color { /// /// ```example /// // note that the alpha component is included by default - /// #(rgb(40%, 60%, 80%).components() == (40%, 60%, 80%, 100%)) + /// #rgb(40%, 60%, 80%).components() /// ``` #[func] pub fn components( |
