libcosmic/cosmic/cosmic_theme/palette/cam16/index.html
2026-04-18 20:11:25 +00:00

68 lines
No EOL
18 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="Types for the CIE CAM16 color appearance model."><title>cosmic::cosmic_theme::palette::cam16 - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Italic-81dc35de.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-MediumItalic-ccf7e434.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2" crossorigin href="../../../../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../../../../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../../../../static.files/rustdoc-aa0817cf.css"><meta name="rustdoc-vars" data-root-path="../../../../" data-static-root-path="../../../../static.files/" data-current-crate="cosmic" data-themes="" data-resource-suffix="" data-rustdoc-version="1.90.0-nightly (3048886e5 2025-07-30)" data-channel="nightly" data-search-js="search-fa3e91e5.js" data-settings-js="settings-5514c975.js" ><script src="../../../../static.files/storage-68b7e25d.js"></script><script defer src="../sidebar-items.js"></script><script defer src="../../../../static.files/main-eebb9057.js"></script><noscript><link rel="stylesheet" href="../../../../static.files/noscript-32bb7600.css"></noscript><link rel="alternate icon" type="image/png" href="../../../../static.files/favicon-32x32-6580c154.png"><link rel="icon" type="image/svg+xml" href="../../../../static.files/favicon-044be391.svg"></head><body class="rustdoc mod"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle" title="show sidebar"></button></nav><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../../../../cosmic/index.html">cosmic</a><span class="version">1.0.0</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">Module cam16</a></h2><h3><a href="#">Sections</a></h3><ul class="block top-toc"><li><a href="#converting-between-xyz-and-cam16" title="Converting Between XYZ and CAM16">Converting Between XYZ and CAM16</a></li><li><a href="#the-cam16-ucs-color-space" title="The CAM16-UCS Color Space">The CAM16-UCS Color Space</a></li></ul><h3><a href="#modules">Module Items</a></h3><ul class="block"><li><a href="#modules" title="Modules">Modules</a></li><li><a href="#structs" title="Structs">Structs</a></li><li><a href="#enums" title="Enums">Enums</a></li><li><a href="#traits" title="Traits">Traits</a></li><li><a href="#types" title="Type Aliases">Type Aliases</a></li></ul></section><div id="rustdoc-modnav"><h2><a href="../index.html">In cosmic::<wbr>cosmic_<wbr>theme::<wbr>palette</a></h2></div></div></nav><div class="sidebar-resizer" title="Drag to resize sidebar"></div><main><div class="width-limiter"><rustdoc-search></rustdoc-search><section id="main-content" class="content"><div class="main-heading"><div class="rustdoc-breadcrumbs"><a href="../../../index.html">cosmic</a>::<wbr><a href="../../index.html">cosmic_theme</a>::<wbr><a href="../index.html">palette</a></div><h1>Module <span>cam16</span><button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="https://docs.rs/palette/0.7.6/src/palette/lib.rs.html#347">Source</a> </span></div><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Types for the CIE CAM16 color appearance model.</p>
<p>CIE CAM16 is a color appearance model that tries to predict the appearance
of a color under certain viewing conditions, as specified via the
<a href="struct.Parameters.html" title="struct cosmic::cosmic_theme::palette::cam16::Parameters"><code>Parameters</code></a> type. The <a href="struct.Cam16.html" title="struct cosmic::cosmic_theme::palette::cam16::Cam16"><code>Cam16</code></a> type has descriptions for the CAM16
attributes. The <a href="https://en.wikipedia.org/wiki/Color_appearance_model">Color appearance model page on Wikipedia</a>
has some history and background as well.</p>
<h2 id="converting-between-xyz-and-cam16"><a class="doc-anchor" href="#converting-between-xyz-and-cam16">§</a>Converting Between XYZ and CAM16</h2>
<p>The CIE CAM16 implementation in Palette has the <a href="struct.Cam16.html" title="struct cosmic::cosmic_theme::palette::cam16::Cam16"><code>Cam16</code></a> type and its
partial variants on one side of the boundary, and <a href="../struct.Xyz.html" title="struct cosmic::cosmic_theme::palette::Xyz"><code>Xyz</code></a> on the
other. Going between <code>Xyz</code> and <code>Cam16</code> requires the viewing conditions to be
specified as <a href="struct.Parameters.html" title="struct cosmic::cosmic_theme::palette::cam16::Parameters"><code>Parameters</code></a>.</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>palette::{
Srgb, FromColor, IntoColor,
cam16::{Cam16, Parameters},
};
<span class="comment">// Customize these according to the viewing conditions:
</span><span class="kw">let </span><span class="kw-2">mut </span>example_parameters = Parameters::default_static_wp(<span class="number">40.0</span>);
<span class="comment">// CAM16 from sRGB, or most other color spaces:
</span><span class="kw">let </span>rgb = Srgb::new(<span class="number">0.3f32</span>, <span class="number">0.8</span>, <span class="number">0.1</span>);
<span class="kw">let </span>cam16_from_rgb = Cam16::from_xyz(rgb.into_color(), example_parameters);
<span class="comment">// sRGB from CAM16, using lightness, chroma and hue by default:
</span><span class="kw">let </span>rgb_from_cam16 = Srgb::from_color(cam16_from_rgb.into_xyz(example_parameters));</code></pre></div>
<p>For more control over the attributes to use when converting from CAM16, one
of the partial CAM16 types can be used:</p>
<ul>
<li><a href="struct.Cam16Jch.html" title="struct cosmic::cosmic_theme::palette::cam16::Cam16Jch"><code>Cam16Jch</code></a>: lightness and chroma.</li>
<li><a href="struct.Cam16Jmh.html" title="struct cosmic::cosmic_theme::palette::cam16::Cam16Jmh"><code>Cam16Jmh</code></a>: lightness and colorfulness.</li>
<li><a href="struct.Cam16Jsh.html" title="struct cosmic::cosmic_theme::palette::cam16::Cam16Jsh"><code>Cam16Jsh</code></a>: lightness and saturation.</li>
<li><a href="struct.Cam16Qch.html" title="struct cosmic::cosmic_theme::palette::cam16::Cam16Qch"><code>Cam16Qch</code></a>: brightness and chroma.</li>
<li><a href="struct.Cam16Qmh.html" title="struct cosmic::cosmic_theme::palette::cam16::Cam16Qmh"><code>Cam16Qmh</code></a>: brightness and colorfulness.</li>
<li><a href="struct.Cam16Qsh.html" title="struct cosmic::cosmic_theme::palette::cam16::Cam16Qsh"><code>Cam16Qsh</code></a>: brightness and saturation.</li>
</ul>
<p>Generic traits and functions can make use of the <a href="trait.IntoCam16Unclamped.html" title="trait cosmic::cosmic_theme::palette::cam16::IntoCam16Unclamped"><code>IntoCam16Unclamped</code></a>,
<a href="trait.FromCam16Unclamped.html" title="trait cosmic::cosmic_theme::palette::cam16::FromCam16Unclamped"><code>FromCam16Unclamped</code></a>, <a href="trait.Cam16IntoUnclamped.html" title="trait cosmic::cosmic_theme::palette::cam16::Cam16IntoUnclamped"><code>Cam16IntoUnclamped</code></a>, and <a href="trait.Cam16FromUnclamped.html" title="trait cosmic::cosmic_theme::palette::cam16::Cam16FromUnclamped"><code>Cam16FromUnclamped</code></a>
traits. They are similar to the traits from the <a href="../convert/index.html" title="mod cosmic::cosmic_theme::palette::convert"><code>convert</code></a>
module and help abstracting away most of the implementation details.</p>
<h2 id="the-cam16-ucs-color-space"><a class="doc-anchor" href="#the-cam16-ucs-color-space">§</a>The CAM16-UCS Color Space</h2>
<p>CIE CAM16 specifies a visually uniform color space that can be used for
color manipulation. Its represented by the <a href="struct.Cam16UcsJmh.html" title="struct cosmic::cosmic_theme::palette::cam16::Cam16UcsJmh"><code>Cam16UcsJmh</code></a> and
<a href="struct.Cam16UcsJab.html" title="struct cosmic::cosmic_theme::palette::cam16::Cam16UcsJab"><code>Cam16UcsJab</code></a> types, similar to <a href="../struct.Lch.html" title="struct cosmic::cosmic_theme::palette::Lch"><code>Lch</code></a> and
<a href="../struct.Lab.html" title="struct cosmic::cosmic_theme::palette::Lab"><code>Lab</code></a>.</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>palette::{
Srgb, FromColor, IntoColor,
cam16::{Cam16Jmh, Parameters, Cam16UcsJmh},
};
<span class="comment">// Customize these according to the viewing conditions:
</span><span class="kw">let </span><span class="kw-2">mut </span>example_parameters = Parameters::default_static_wp(<span class="number">40.0</span>);
<span class="comment">// CAM16-UCS from sRGB, or most other color spaces:
</span><span class="kw">let </span>rgb = Srgb::new(<span class="number">0.3f32</span>, <span class="number">0.8</span>, <span class="number">0.1</span>);
<span class="kw">let </span>cam16 = Cam16Jmh::from_xyz(rgb.into_color(), example_parameters);
<span class="kw">let </span><span class="kw-2">mut </span>ucs_from_rgb = Cam16UcsJmh::from_color(cam16);
<span class="comment">// Shift the hue by 120 degrees in CAM16-UCS:
</span>ucs_from_rgb.hue += <span class="number">120.0</span>;
<span class="comment">// Convert back to sRGB under the same viewing conditions:
</span><span class="kw">let </span>rgb = Srgb::from_color(Cam16Jmh::from_color(ucs_from_rgb).into_xyz(example_parameters));</code></pre></div>
</div></details><h2 id="modules" class="section-header">Modules<a href="#modules" class="anchor">§</a></h2><dl class="item-table"><dt><a class="mod" href="cam16_jch/index.html" title="mod cosmic::cosmic_theme::palette::cam16::cam16_jch">cam16_<wbr>jch</a></dt><dd>Partial CIE CAM16, with lightness and chroma, and helper types.</dd><dt><a class="mod" href="cam16_jmh/index.html" title="mod cosmic::cosmic_theme::palette::cam16::cam16_jmh">cam16_<wbr>jmh</a></dt><dd>Partial CIE CAM16, with lightness and colorfulness, and helper types.</dd><dt><a class="mod" href="cam16_jsh/index.html" title="mod cosmic::cosmic_theme::palette::cam16::cam16_jsh">cam16_<wbr>jsh</a></dt><dd>Partial CIE CAM16, with lightness and saturation, and helper types.</dd><dt><a class="mod" href="cam16_qch/index.html" title="mod cosmic::cosmic_theme::palette::cam16::cam16_qch">cam16_<wbr>qch</a></dt><dd>Partial CIE CAM16, with brightness and chroma, and helper types.</dd><dt><a class="mod" href="cam16_qmh/index.html" title="mod cosmic::cosmic_theme::palette::cam16::cam16_qmh">cam16_<wbr>qmh</a></dt><dd>Partial CIE CAM16, with brightness and colorfulness, and helper types.</dd><dt><a class="mod" href="cam16_qsh/index.html" title="mod cosmic::cosmic_theme::palette::cam16::cam16_qsh">cam16_<wbr>qsh</a></dt><dd>Partial CIE CAM16, with brightness and saturation, and helper types.</dd></dl><h2 id="structs" class="section-header">Structs<a href="#structs" class="anchor">§</a></h2><dl class="item-table"><dt><a class="struct" href="struct.BakedParameters.html" title="struct cosmic::cosmic_theme::palette::cam16::BakedParameters">Baked<wbr>Parameters</a></dt><dd>Pre-calculated variables for CAM16, that only depend on the viewing
conditions.</dd><dt><a class="struct" href="struct.Cam16.html" title="struct cosmic::cosmic_theme::palette::cam16::Cam16">Cam16</a></dt><dd>The CIE CAM16 color appearance model.</dd><dt><a class="struct" href="struct.Cam16Jch.html" title="struct cosmic::cosmic_theme::palette::cam16::Cam16Jch">Cam16<wbr>Jch</a></dt><dd>Partial CIE CAM16, with lightness and chroma.</dd><dt><a class="struct" href="struct.Cam16Jmh.html" title="struct cosmic::cosmic_theme::palette::cam16::Cam16Jmh">Cam16<wbr>Jmh</a></dt><dd>Partial CIE CAM16, with lightness and colorfulness.</dd><dt><a class="struct" href="struct.Cam16Jsh.html" title="struct cosmic::cosmic_theme::palette::cam16::Cam16Jsh">Cam16<wbr>Jsh</a></dt><dd>Partial CIE CAM16, with lightness and saturation.</dd><dt><a class="struct" href="struct.Cam16Qch.html" title="struct cosmic::cosmic_theme::palette::cam16::Cam16Qch">Cam16<wbr>Qch</a></dt><dd>Partial CIE CAM16, with brightness and chroma.</dd><dt><a class="struct" href="struct.Cam16Qmh.html" title="struct cosmic::cosmic_theme::palette::cam16::Cam16Qmh">Cam16<wbr>Qmh</a></dt><dd>Partial CIE CAM16, with brightness and colorfulness.</dd><dt><a class="struct" href="struct.Cam16Qsh.html" title="struct cosmic::cosmic_theme::palette::cam16::Cam16Qsh">Cam16<wbr>Qsh</a></dt><dd>Partial CIE CAM16, with brightness and saturation.</dd><dt><a class="struct" href="struct.Cam16UcsJab.html" title="struct cosmic::cosmic_theme::palette::cam16::Cam16UcsJab">Cam16<wbr>UcsJab</a></dt><dd>The Cartesian form of CAM16-UCS, or J a b.</dd><dt><a class="struct" href="struct.Cam16UcsJabIter.html" title="struct cosmic::cosmic_theme::palette::cam16::Cam16UcsJabIter">Cam16<wbr>UcsJab<wbr>Iter</a></dt><dd>An iterator for <a href="struct.Cam16UcsJab.html" title="struct cosmic::cosmic_theme::palette::cam16::Cam16UcsJab"><code>Cam16UcsJab</code></a> values.</dd><dt><a class="struct" href="struct.Cam16UcsJmh.html" title="struct cosmic::cosmic_theme::palette::cam16::Cam16UcsJmh">Cam16<wbr>UcsJmh</a></dt><dd>The polar form of CAM16-UCS, or JMh.</dd><dt><a class="struct" href="struct.Cam16UcsJmhIter.html" title="struct cosmic::cosmic_theme::palette::cam16::Cam16UcsJmhIter">Cam16<wbr>UcsJmh<wbr>Iter</a></dt><dd>An iterator for <a href="struct.Cam16UcsJmh.html" title="struct cosmic::cosmic_theme::palette::cam16::Cam16UcsJmh"><code>Cam16UcsJmh</code></a> values.</dd><dt><a class="struct" href="struct.Parameters.html" title="struct cosmic::cosmic_theme::palette::cam16::Parameters">Parameters</a></dt><dd>Parameters for CAM16 that describe the viewing conditions.</dd><dt><a class="struct" href="struct.StaticWp.html" title="struct cosmic::cosmic_theme::palette::cam16::StaticWp">Static<wbr>Wp</a></dt><dd>Represents a static white point in <a href="struct.Parameters.html" title="struct cosmic::cosmic_theme::palette::cam16::Parameters"><code>Parameters</code></a>, as opposed to a dynamic
<a href="../struct.Xyz.html" title="struct cosmic::cosmic_theme::palette::Xyz"><code>Xyz</code></a> value.</dd></dl><h2 id="enums" class="section-header">Enums<a href="#enums" class="anchor">§</a></h2><dl class="item-table"><dt><a class="enum" href="enum.Discounting.html" title="enum cosmic::cosmic_theme::palette::cam16::Discounting">Discounting</a></dt><dd>The degree of discounting of (or adaptation to) the illuminant.</dd><dt><a class="enum" href="enum.Surround.html" title="enum cosmic::cosmic_theme::palette::cam16::Surround">Surround</a></dt><dd>A description of the peripheral area.</dd></dl><h2 id="traits" class="section-header">Traits<a href="#traits" class="anchor">§</a></h2><dl class="item-table"><dt><a class="trait" href="trait.Cam16FromUnclamped.html" title="trait cosmic::cosmic_theme::palette::cam16::Cam16FromUnclamped">Cam16<wbr>From<wbr>Unclamped</a></dt><dd>A trait for converting into a CAM16 color type from <code>C</code> without clamping.</dd><dt><a class="trait" href="trait.Cam16IntoUnclamped.html" title="trait cosmic::cosmic_theme::palette::cam16::Cam16IntoUnclamped">Cam16<wbr>Into<wbr>Unclamped</a></dt><dd>A trait for converting from a CAM16 color type into <code>C</code> without clamping.</dd><dt><a class="trait" href="trait.FromCam16Unclamped.html" title="trait cosmic::cosmic_theme::palette::cam16::FromCam16Unclamped">From<wbr>Cam16<wbr>Unclamped</a></dt><dd>A trait for converting from a CAM16 color type <code>C</code> without clamping.</dd><dt><a class="trait" href="trait.IntoCam16Unclamped.html" title="trait cosmic::cosmic_theme::palette::cam16::IntoCam16Unclamped">Into<wbr>Cam16<wbr>Unclamped</a></dt><dd>A trait for converting into a CAM16 color type <code>C</code> without clamping.</dd><dt><a class="trait" href="trait.WhitePointParameter.html" title="trait cosmic::cosmic_theme::palette::cam16::WhitePointParameter">White<wbr>Point<wbr>Parameter</a></dt><dd>A trait for types that can be used as white point parameters in
<a href="struct.Parameters.html" title="struct cosmic::cosmic_theme::palette::cam16::Parameters"><code>Parameters</code></a>.</dd></dl><h2 id="types" class="section-header">Type Aliases<a href="#types" class="anchor">§</a></h2><dl class="item-table"><dt><a class="type" href="type.Cam16Jcha.html" title="type cosmic::cosmic_theme::palette::cam16::Cam16Jcha">Cam16<wbr>Jcha</a></dt><dd>Partial CIE CAM16 with lightness, chroma, and an alpha component.</dd><dt><a class="type" href="type.Cam16Jmha.html" title="type cosmic::cosmic_theme::palette::cam16::Cam16Jmha">Cam16<wbr>Jmha</a></dt><dd>Partial CIE CAM16 with lightness, colorfulness, and an alpha component.</dd><dt><a class="type" href="type.Cam16Jsha.html" title="type cosmic::cosmic_theme::palette::cam16::Cam16Jsha">Cam16<wbr>Jsha</a></dt><dd>Partial CIE CAM16 with lightness, saturation, and an alpha component.</dd><dt><a class="type" href="type.Cam16Qcha.html" title="type cosmic::cosmic_theme::palette::cam16::Cam16Qcha">Cam16<wbr>Qcha</a></dt><dd>Partial CIE CAM16 with brightness, chroma, and an alpha component.</dd><dt><a class="type" href="type.Cam16Qmha.html" title="type cosmic::cosmic_theme::palette::cam16::Cam16Qmha">Cam16<wbr>Qmha</a></dt><dd>Partial CIE CAM16 with brightness, colorfulness, and an alpha component.</dd><dt><a class="type" href="type.Cam16Qsha.html" title="type cosmic::cosmic_theme::palette::cam16::Cam16Qsha">Cam16<wbr>Qsha</a></dt><dd>Partial CIE CAM16 with brightness, saturation, and an alpha component.</dd><dt><a class="type" href="type.Cam16UcsJaba.html" title="type cosmic::cosmic_theme::palette::cam16::Cam16UcsJaba">Cam16<wbr>UcsJaba</a></dt><dd>Cartesian CAM16-UCS with an alpha component.</dd><dt><a class="type" href="type.Cam16UcsJmha.html" title="type cosmic::cosmic_theme::palette::cam16::Cam16UcsJmha">Cam16<wbr>UcsJmha</a></dt><dd>Polar CAM16-UCS with an alpha component.</dd><dt><a class="type" href="type.Cam16a.html" title="type cosmic::cosmic_theme::palette::cam16::Cam16a">Cam16a</a></dt><dd>CIE CAM16 with an alpha component.</dd></dl></section></div></main></body></html>