summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfrozolotl <44589151+frozolotl@users.noreply.github.com>2024-03-19 10:36:30 +0100
committerGitHub <noreply@github.com>2024-03-19 09:36:30 +0000
commit9dfc54d726911422a1460159769823a0b21bcbf0 (patch)
tree767bf272179066856984aec1cff4b76ae2ce419b
parent65ae369f2c56644543afd3d7de8d4c87e29296ee (diff)
Fix color documentation (#3688)
-rw-r--r--crates/typst/src/visualize/color.rs13
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(