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

227 lines
No EOL
42 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="A library that makes linear color calculations and conversion easy and accessible for anyone. It uses the type system to enforce correctness and to avoid mistakes, such as mixing incompatible color types."><title>cosmic::cosmic_theme::palette - 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="../../../crates.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 crate"><!--[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"><ul class="block"><li><a id="all-types" href="all.html">All Items</a></li></ul><section id="rustdoc-toc"><h3><a href="#">Sections</a></h3><ul class="block top-toc"><li><a href="#where-do-i-start" title="Where Do I Start?">Where Do I Start?</a></li><li><a href="#type-safety-for-colors" title="Type Safety for Colors">Type Safety for Colors</a></li><li><a href="#color-spaces-and-conversion" title="Color Spaces and Conversion">Color Spaces and Conversion</a></li><li><a href="#transparency" title="Transparency">Transparency</a></li><li><a href="#images-and-buffers" title="Images and Buffers">Images and Buffers</a></li><li><a href="#a-basic-workflow" title="A Basic Workflow">A Basic Workflow</a><ul><li><a href="#1-decoding" title="1. Decoding">1. Decoding</a></li><li><a href="#2-processing" title="2. Processing">2. Processing</a></li><li><a href="#3-encoding" title="3. Encoding">3. Encoding</a></li></ul></li></ul><h3><a href="#modules">Crate 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="#traits" title="Traits">Traits</a></li><li><a href="#functions" title="Functions">Functions</a></li><li><a href="#types" title="Type Aliases">Type Aliases</a></li><li><a href="#derives" title="Derive Macros">Derive Macros</a></li></ul></section><div id="rustdoc-modnav"><h2><a href="../index.html">In cosmic::<wbr>cosmic_<wbr>theme</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></div><h1>Crate <span>palette</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#1-1431">Source</a> </span></div><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>A library that makes linear color calculations and conversion easy and
accessible for anyone. It uses the type system to enforce correctness and to
avoid mistakes, such as mixing incompatible color types.</p>
<h2 id="where-do-i-start"><a class="doc-anchor" href="#where-do-i-start">§</a>Where Do I Start?</h2>
<p>The sections below give an overview of how the types in this library work,
including color conversion. If you want to get your hands dirty, youll
probably want to start with <a href="type.Srgb.html" title="type cosmic::cosmic_theme::palette::Srgb"><code>Srgb</code></a> or <a href="type.Srgba.html" title="type cosmic::cosmic_theme::palette::Srgba"><code>Srgba</code></a>. They are aliases for the
more generic <a href="rgb/struct.Rgb.html" title="struct cosmic::cosmic_theme::palette::rgb::Rgb"><code>Rgb</code></a> type and represent sRGB(A), the most common
RGB format in images and tools. Their documentation has more details and
examples.</p>
<p>The documentation for each module and type goes deeper into their concepts.
Here are a few you may want to read:</p>
<ul>
<li><a href="rgb/struct.Rgb.html" title="struct cosmic::cosmic_theme::palette::rgb::Rgb"><code>Rgb</code></a> - For getting started with RGB values.</li>
<li><a href="struct.Alpha.html" title="struct cosmic::cosmic_theme::palette::Alpha"><code>Alpha</code></a> - For more details on transparency.</li>
<li><a href="convert/index.html" title="mod cosmic::cosmic_theme::palette::convert"><code>convert</code></a> - Describes the conversion traits and how to use and implement
them.</li>
<li><a href="cast/index.html" title="mod cosmic::cosmic_theme::palette::cast"><code>cast</code></a> - Describes how to cast color types to and from other data
formats, such as arrays and unsigned integers.</li>
<li><a href="color_difference/index.html" title="mod cosmic::cosmic_theme::palette::color_difference"><code>color_difference</code></a> - Describes different ways of measuring the
difference between colors.</li>
</ul>
<h2 id="type-safety-for-colors"><a class="doc-anchor" href="#type-safety-for-colors">§</a>Type Safety for Colors</h2>
<p>Digital colors are not “just RGB”, and not even RGB is “just RGB”. There are
multiple representations of color, with a variety of pros and cons, and
multiple standards for how to encode and decode them. Palette represents
these “color spaces” as separate types for increased expressiveness and to
prevent mistakes.</p>
<p>Taking RGB as an example, its often stored or displayed as “gamma
corrected” values, meaning that a non-linear function has been applied to
its values. This encoding is not suitable for all kinds of calculations
(such as rescaling) and will give visibly incorrect results. Functions that
require linear RGB can therefore request, for example, <a href="type.LinSrgb.html" title="type cosmic::cosmic_theme::palette::LinSrgb"><code>LinSrgb</code></a> as their
input type.</p>
<div class="example-wrap compile_fail"><a href="#" class="tooltip" title="This example deliberately fails to compile"></a><pre class="rust rust-example-rendered"><code><span class="comment">// Srgb is an alias for Rgb&lt;Srgb, T&gt;, which is what most pictures store.
// LinSrgb is an alias for Rgb&lt;Linear&lt;Srgb&gt;, T&gt;, better for color manipulation.
</span><span class="kw">use </span>palette::{Srgb, LinSrgb};
<span class="kw">fn </span>do_something(a: LinSrgb, b: LinSrgb) -&gt; LinSrgb {
<span class="comment">// ...
</span>}
<span class="kw">let </span>orangeish = Srgb::new(<span class="number">1.0</span>, <span class="number">0.6</span>, <span class="number">0.0</span>);
<span class="kw">let </span>blueish = Srgb::new(<span class="number">0.0</span>, <span class="number">0.2</span>, <span class="number">1.0</span>);
<span class="kw">let </span>result = do_something(orangeish, blueish); <span class="comment">// Does not compile</span></code></pre></div>
<p>The colors will have to be decoded before being used in the function:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="comment">// Srgb is an alias for Rgb&lt;Srgb, T&gt;, which is what most pictures store.
// LinSrgb is an alias for Rgb&lt;Linear&lt;Srgb&gt;, T&gt;, better for color manipulation.
</span><span class="kw">use </span>palette::{Srgb, LinSrgb};
<span class="kw">fn </span>do_something(a: LinSrgb, b: LinSrgb) -&gt; LinSrgb {
<span class="comment">// ...
</span>}
<span class="kw">let </span>orangeish = Srgb::new(<span class="number">1.0</span>, <span class="number">0.6</span>, <span class="number">0.0</span>).into_linear();
<span class="kw">let </span>blueish = Srgb::new(<span class="number">0.0</span>, <span class="number">0.2</span>, <span class="number">1.0</span>).into_linear();
<span class="kw">let </span>result = do_something(orangeish, blueish);</code></pre></div>
<p>See the <a href="rgb/index.html" title="mod cosmic::cosmic_theme::palette::rgb">rgb</a> module for a deeper dive into RGB and (non-)linearity.</p>
<h2 id="color-spaces-and-conversion"><a class="doc-anchor" href="#color-spaces-and-conversion">§</a>Color Spaces and Conversion</h2>
<p>As the previous section mentions, there are many different ways of
representing colors. These “color spaces” are represented as different types
in Palette, each with a description of what it is and how it works. Most of
them also have two type parameters for customization:</p>
<ul>
<li>The component type (<code>T</code>) that decides which number type is used. The
default is <code>f32</code>, but <code>u8</code>, <code>f64</code>, and any other type that implement the
required traits will work. Including SIMD types in many cases.</li>
<li>The reference white point (<code>W</code>) or standard (<code>S</code>) that affects the range,
encoding or display properties of the color. This varies between color
spaces and can usually be left as its default or be set via a type alias.
For example, the <a href="type.Srgb.html" title="type cosmic::cosmic_theme::palette::Srgb"><code>Srgb</code></a> and <a href="type.LinSrgb.html" title="type cosmic::cosmic_theme::palette::LinSrgb"><code>LinSrgb</code></a> type aliases are both variants
of the <a href="rgb/struct.Rgb.html" title="struct cosmic::cosmic_theme::palette::rgb::Rgb"><code>Rgb</code></a> type, but with different standard (<code>S</code>) types.</li>
</ul>
<p>Selecting the proper color space can have a big impact on how the resulting
image looks (as illustrated by some of the programs in <code>examples</code>), and
Palette makes the conversion between them as easy as a call to
<a href="trait.FromColor.html#tymethod.from_color" title="associated function cosmic::cosmic_theme::palette::FromColor::from_color"><code>from_color</code></a> or
<a href="trait.IntoColor.html#tymethod.into_color" title="method cosmic::cosmic_theme::palette::IntoColor::into_color"><code>into_color</code></a>.</p>
<p>This example takes an sRGB color, converts it to CIE L*C*h°, a color space
similar to the colloquial HSL/HSV color spaces, shifts its hue by 180° and
converts it back to RGB:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>palette::{FromColor, ShiftHue, IntoColor, Lch, Srgb};
<span class="kw">let </span>lch_color: Lch = Srgb::new(<span class="number">0.8</span>, <span class="number">0.2</span>, <span class="number">0.1</span>).into_color();
<span class="kw">let </span>new_color = Srgb::from_color(lch_color.shift_hue(<span class="number">180.0</span>));</code></pre></div>
<h2 id="transparency"><a class="doc-anchor" href="#transparency">§</a>Transparency</h2>
<p>There are many cases where pixel transparency is important, but there are
also many cases where it would just be unused memory space. Palette has
therefore adopted a structure where the transparency component (alpha) is
attachable using the <a href="struct.Alpha.html" title="struct cosmic::cosmic_theme::palette::Alpha"><code>Alpha</code></a> type. This approach has shown to be very
modular and easy to maintain, compared to having transparent copies of each
type.</p>
<p>An additional benefit is allowing operations to selectively affect the alpha
component:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="comment">// Each color type has a transparent alias that ends with "a" for "alpha"
</span><span class="kw">use </span>palette::{LinSrgb, LinSrgba};
<span class="kw">let </span><span class="kw-2">mut </span>c1 = LinSrgba::new(<span class="number">1.0</span>, <span class="number">0.5</span>, <span class="number">0.5</span>, <span class="number">0.8</span>);
<span class="kw">let </span>c2 = LinSrgb::new(<span class="number">0.5</span>, <span class="number">1.0</span>, <span class="number">1.0</span>);
c1.color = c1.color * c2; <span class="comment">//Leave the alpha as it is
</span>c1.blue += <span class="number">0.2</span>; <span class="comment">//The color components can easily be accessed
</span>c1 = c1 * <span class="number">0.5</span>; <span class="comment">//Scale both the color and the alpha</span></code></pre></div>
<p>Theres also <a href="alpha/struct.PreAlpha.html" title="struct cosmic::cosmic_theme::palette::alpha::PreAlpha"><code>PreAlpha</code></a> that represents pre-multiplied
alpha (also known as alpha masked colors). Its commonly used in color
blending and composition.</p>
<h2 id="images-and-buffers"><a class="doc-anchor" href="#images-and-buffers">§</a>Images and Buffers</h2>
<p>Oftentimes, pixel data is stored in a plain array or slice such as a <code>[u8; 3]</code>. The <a href="cast/index.html" title="mod cosmic::cosmic_theme::palette::cast"><code>cast</code></a> module allows for easy conversion between Palette colors
and arrays or slices. This also helps when working with other crates or
systems. Heres an example of how the pixels in an image from the <code>image</code>
crate can be worked with as <code>Srgb&lt;u8&gt;</code>:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>image::RgbImage;
<span class="kw">use </span>palette::{Srgb, Oklab, cast::FromComponents, Lighten, IntoColor, FromColor};
<span class="kw">fn </span>lighten(image: <span class="kw-2">&amp;mut </span>RgbImage, amount: f32) {
<span class="comment">// RgbImage can be dereferenced as [u8], allowing us to cast it as a
// component slice to sRGB with u8 components.
</span><span class="kw">for </span>pixel <span class="kw">in </span>&lt;<span class="kw-2">&amp;mut </span>[Srgb&lt;u8&gt;]&gt;::from_components(<span class="kw-2">&amp;mut **</span>image) {
<span class="comment">// Converting to linear sRGB with f32 components, and then to Oklab.
</span><span class="kw">let </span>color: Oklab = pixel.into_linear::&lt;f32&gt;().into_color();
<span class="kw">let </span>lightened_color = color.lighten(amount);
<span class="comment">// Converting back to non-linear sRGB with u8 components.
</span><span class="kw-2">*</span>pixel = Srgb::from_linear(lightened_color.into_color());
}
}</code></pre></div>
<p>Some of the conversions are also implemented on the color types as <code>From</code>,
<code>TryFrom</code>, <code>Into</code>, <code>TryFrom</code> and <code>AsRef</code>. This example shows how <code>from</code> can
be used to convert a <code>[u8;3]</code> into a Palette color, <code>into_format</code> converts
from <code>Srgb&lt;u8&gt;</code> to <code>Srgb&lt;f32&gt;</code>, and finally <code>into</code> converts back from a
Palette color back to a <code>[u8;3]</code>:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>approx::assert_relative_eq;
<span class="kw">use </span>palette::Srgb;
<span class="kw">let </span>buffer = [<span class="number">255</span>, <span class="number">0</span>, <span class="number">255</span>];
<span class="kw">let </span>srgb = Srgb::from(buffer);
<span class="macro">assert_eq!</span>(srgb, Srgb::&lt;u8&gt;::new(<span class="number">255u8</span>, <span class="number">0</span>, <span class="number">255</span>));
<span class="kw">let </span>srgb_float: Srgb&lt;f32&gt; = srgb.into_format();
<span class="macro">assert_relative_eq!</span>(srgb_float, Srgb::new(<span class="number">1.0</span>, <span class="number">0.0</span>, <span class="number">1.0</span>));
<span class="kw">let </span>array: [u8; <span class="number">3</span>] = srgb_float.into_format().into();
<span class="macro">assert_eq!</span>(array, buffer);</code></pre></div>
<h2 id="a-basic-workflow"><a class="doc-anchor" href="#a-basic-workflow">§</a>A Basic Workflow</h2>
<p>The overall workflow can be divided into three steps, where the first and
last may be taken care of by other parts of the application:</p>
<div class="example-wrap"><pre class="language-text"><code>Decoding -&gt; Processing -&gt; Encoding</code></pre></div><h3 id="1-decoding"><a class="doc-anchor" href="#1-decoding">§</a>1. Decoding</h3>
<p>Find out what the source format is and convert it to a linear color space.
There may be a specification, such as when working with SVG or CSS.</p>
<p>When working with RGB or gray scale (luma):</p>
<ul>
<li>
<p>If you are asking your user to enter an RGB value, you are in a gray zone
where it depends on the context. Its usually safe to assume sRGB, but
sometimes its already linear.</p>
</li>
<li>
<p>If you are decoding an image, there may be some meta data that gives you
the necessary details. Otherwise its most commonly sRGB. Usually you will
end up with a slice or vector with RGB bytes, which can easily be converted
to Palette colors:</p>
</li>
</ul>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>palette::{Srgb, cast::ComponentsAsMut};
<span class="comment">// This works for any color type (not only RGB) that can have the
// buffer element type as component.
</span><span class="kw">let </span>color_buffer: <span class="kw-2">&amp;mut </span>[Srgb&lt;u8&gt;] = image_buffer.components_as_mut();</code></pre></div>
<ul>
<li>If you are getting your colors from the GPU, in a game or other graphical
application, or if they are otherwise generated by the application, then
chances are that they are already linear. Still, make sure to check that
they are not being encoded somewhere.</li>
</ul>
<p>When working with other colors:</p>
<ul>
<li>
<p>For HSL, HSV, HWB: Check if they are based on any other color space than
sRGB, such as Adobe or Apple RGB.</p>
</li>
<li>
<p>For any of the CIE color spaces, check for a specification of white point
and light source. These are necessary for converting to RGB and other
colors, that depend on perception and “viewing devices”. Common defaults are
the D65 light source and the sRGB white point. The Palette defaults should
take you far.</p>
</li>
</ul>
<h3 id="2-processing"><a class="doc-anchor" href="#2-processing">§</a>2. Processing</h3>
<p>When your color has been decoded into some Palette type, its ready for
processing. This includes things like blending, hue shifting, darkening and
conversion to other formats. Just make sure that your non-linear RGB is made
linear first (<code>my_srgb.into_linear()</code>), to make the operations available.</p>
<p>Different color spaced have different capabilities, pros and cons. You may
have to experiment a bit (or look at the example programs) to find out what
gives the desired result.</p>
<h3 id="3-encoding"><a class="doc-anchor" href="#3-encoding">§</a>3. Encoding</h3>
<p>When the desired processing is done, its time to encode the colors back
into some image format. The same rules applies as for the decoding, but the
process reversed.</p>
</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="alpha/index.html" title="mod cosmic::cosmic_theme::palette::alpha">alpha</a></dt><dd>Types related to transparent colors.</dd><dt><a class="mod" href="angle/index.html" title="mod cosmic::cosmic_theme::palette::angle">angle</a></dt><dd>Traits for working with angular values, such as for in hues.</dd><dt><a class="mod" href="blend/index.html" title="mod cosmic::cosmic_theme::palette::blend">blend</a></dt><dd>Color blending and blending equations.</dd><dt><a class="mod" href="bool_mask/index.html" title="mod cosmic::cosmic_theme::palette::bool_mask">bool_<wbr>mask</a></dt><dd>Traits for abstracting over Boolean types.</dd><dt><a class="mod" href="cam16/index.html" title="mod cosmic::cosmic_theme::palette::cam16">cam16</a></dt><dd>Types for the CIE CAM16 color appearance model.</dd><dt><a class="mod" href="cast/index.html" title="mod cosmic::cosmic_theme::palette::cast">cast</a></dt><dd>Traits and functions for casting colors to and from other data types.</dd><dt><a class="mod" href="chromatic_adaptation/index.html" title="mod cosmic::cosmic_theme::palette::chromatic_adaptation">chromatic_<wbr>adaptation</a></dt><dd>Convert colors from one reference white point to another</dd><dt><a class="mod" href="color_difference/index.html" title="mod cosmic::cosmic_theme::palette::color_difference">color_<wbr>difference</a></dt><dd>Algorithms for calculating the difference between colors.</dd><dt><a class="mod" href="color_theory/index.html" title="mod cosmic::cosmic_theme::palette::color_theory">color_<wbr>theory</a></dt><dd>Traits related to traditional color theory.</dd><dt><a class="mod" href="convert/index.html" title="mod cosmic::cosmic_theme::palette::convert">convert</a></dt><dd>Traits for converting between color spaces.</dd><dt><a class="mod" href="encoding/index.html" title="mod cosmic::cosmic_theme::palette::encoding">encoding</a></dt><dd>Number and color encoding traits, types and standards.</dd><dt><a class="mod" href="hsl/index.html" title="mod cosmic::cosmic_theme::palette::hsl">hsl</a></dt><dd>Types for the HSL color space.</dd><dt><a class="mod" href="hsluv/index.html" title="mod cosmic::cosmic_theme::palette::hsluv">hsluv</a></dt><dd>Types for the HSLuv color space.</dd><dt><a class="mod" href="hsv/index.html" title="mod cosmic::cosmic_theme::palette::hsv">hsv</a></dt><dd>Types for the HSV color space.</dd><dt><a class="mod" href="hues/index.html" title="mod cosmic::cosmic_theme::palette::hues">hues</a></dt><dd>Hues and hue related types.</dd><dt><a class="mod" href="hwb/index.html" title="mod cosmic::cosmic_theme::palette::hwb">hwb</a></dt><dd>Types for the HWB color space.</dd><dt><a class="mod" href="lab/index.html" title="mod cosmic::cosmic_theme::palette::lab">lab</a></dt><dd>Types for the CIE L*a*b* (CIELAB) color space.</dd><dt><a class="mod" href="lch/index.html" title="mod cosmic::cosmic_theme::palette::lch">lch</a></dt><dd>Types for the CIE L*C*h° color space.</dd><dt><a class="mod" href="lchuv/index.html" title="mod cosmic::cosmic_theme::palette::lchuv">lchuv</a></dt><dd>Types for the CIE L*C*uv h°uv color space.</dd><dt><a class="mod" href="luma/index.html" title="mod cosmic::cosmic_theme::palette::luma">luma</a></dt><dd>Types for luma and luminance (grayscale) values.</dd><dt><a class="mod" href="luv/index.html" title="mod cosmic::cosmic_theme::palette::luv">luv</a></dt><dd>Types for the CIE L*u*v* (CIELUV) color space.</dd><dt><a class="mod" href="named/index.html" title="mod cosmic::cosmic_theme::palette::named">named</a></dt><dd>A collection of named color constants. Can be toggled with the <code>"named"</code> and
<code>"named_from_str"</code> Cargo features.</dd><dt><a class="mod" href="num/index.html" title="mod cosmic::cosmic_theme::palette::num">num</a></dt><dd>Traits for abstracting over numeric types.</dd><dt><a class="mod" href="okhsl/index.html" title="mod cosmic::cosmic_theme::palette::okhsl">okhsl</a></dt><dd>Types for the Okhsl color space.</dd><dt><a class="mod" href="okhsv/index.html" title="mod cosmic::cosmic_theme::palette::okhsv">okhsv</a></dt><dd>Types for the Okhsv color space.</dd><dt><a class="mod" href="okhwb/index.html" title="mod cosmic::cosmic_theme::palette::okhwb">okhwb</a></dt><dd>Types for the Okhwb color space.</dd><dt><a class="mod" href="oklab/index.html" title="mod cosmic::cosmic_theme::palette::oklab">oklab</a></dt><dd>Types for the Oklab color space.</dd><dt><a class="mod" href="oklch/index.html" title="mod cosmic::cosmic_theme::palette::oklch">oklch</a></dt><dd>Types for the Oklch color space.</dd><dt><a class="mod" href="rgb/index.html" title="mod cosmic::cosmic_theme::palette::rgb">rgb</a></dt><dd>Types for the RGB color space, including spaces and standards.</dd><dt><a class="mod" href="serde/index.html" title="mod cosmic::cosmic_theme::palette::serde">serde</a></dt><dd>Utilities for serializing and deserializing with <code>serde</code>.</dd><dt><a class="mod" href="stimulus/index.html" title="mod cosmic::cosmic_theme::palette::stimulus">stimulus</a></dt><dd>Traits for working with stimulus colors and values, such as RGB and XYZ.</dd><dt><a class="mod" href="white_point/index.html" title="mod cosmic::cosmic_theme::palette::white_point">white_<wbr>point</a></dt><dd>Defines the tristimulus values of the CIE Illuminants.</dd><dt><a class="mod" href="xyz/index.html" title="mod cosmic::cosmic_theme::palette::xyz">xyz</a></dt><dd>Types for the CIE 1931 XYZ color space.</dd><dt><a class="mod" href="yxy/index.html" title="mod cosmic::cosmic_theme::palette::yxy">yxy</a></dt><dd>Types for the CIE 1931 Yxy (xyY) color space.</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.Alpha.html" title="struct cosmic::cosmic_theme::palette::Alpha">Alpha</a></dt><dd>An alpha component wrapper for colors, for adding transparency.</dd><dt><a class="struct" href="struct.FromColorMutGuard.html" title="struct cosmic::cosmic_theme::palette::FromColorMutGuard">From<wbr>Color<wbr>MutGuard</a></dt><dd>A scope guard that restores the guarded colors to their original type when
dropped.</dd><dt><a class="struct" href="struct.Hsl.html" title="struct cosmic::cosmic_theme::palette::Hsl">Hsl</a></dt><dd>HSL color space.</dd><dt><a class="struct" href="struct.Hsluv.html" title="struct cosmic::cosmic_theme::palette::Hsluv">Hsluv</a></dt><dd>HSLuv color space.</dd><dt><a class="struct" href="struct.Hsv.html" title="struct cosmic::cosmic_theme::palette::Hsv">Hsv</a></dt><dd>HSV color space.</dd><dt><a class="struct" href="struct.Hwb.html" title="struct cosmic::cosmic_theme::palette::Hwb">Hwb</a></dt><dd>HWB color space.</dd><dt><a class="struct" href="struct.Lab.html" title="struct cosmic::cosmic_theme::palette::Lab">Lab</a></dt><dd>The CIE L*a*b* (CIELAB) color space.</dd><dt><a class="struct" href="struct.LabHue.html" title="struct cosmic::cosmic_theme::palette::LabHue">LabHue</a></dt><dd>A hue type for the CIE L*a*b* family of color spaces.</dd><dt><a class="struct" href="struct.Lch.html" title="struct cosmic::cosmic_theme::palette::Lch">Lch</a></dt><dd>CIE L*C*h°, a polar version of <a href="struct.Lab.html" title="struct cosmic::cosmic_theme::palette::Lab">CIE L*a*b*</a>.</dd><dt><a class="struct" href="struct.Lchuv.html" title="struct cosmic::cosmic_theme::palette::Lchuv">Lchuv</a></dt><dd>CIE L*C*uv h°uv, a polar version of <a href="struct.Luv.html" title="struct cosmic::cosmic_theme::palette::Luv">CIE L*u*v*</a>.</dd><dt><a class="struct" href="struct.Luv.html" title="struct cosmic::cosmic_theme::palette::Luv">Luv</a></dt><dd>The CIE L*u*v* (CIELUV) color space.</dd><dt><a class="struct" href="struct.LuvHue.html" title="struct cosmic::cosmic_theme::palette::LuvHue">LuvHue</a></dt><dd>A hue type for the CIE L*u*v* family of color spaces.</dd><dt><a class="struct" href="struct.Okhsl.html" title="struct cosmic::cosmic_theme::palette::Okhsl">Okhsl</a></dt><dd>A Hue/Saturation/Lightness representation of <a href="struct.Oklab.html" title="struct cosmic::cosmic_theme::palette::Oklab"><code>Oklab</code></a> in the <code>sRGB</code> color space.</dd><dt><a class="struct" href="struct.Okhsv.html" title="struct cosmic::cosmic_theme::palette::Okhsv">Okhsv</a></dt><dd>A Hue/Saturation/Value representation of <a href="struct.Oklab.html" title="struct cosmic::cosmic_theme::palette::Oklab"><code>Oklab</code></a> in the <code>sRGB</code> color space.</dd><dt><a class="struct" href="struct.Okhwb.html" title="struct cosmic::cosmic_theme::palette::Okhwb">Okhwb</a></dt><dd>A Hue/Whiteness/Blackness representation of <a href="struct.Oklab.html" title="struct cosmic::cosmic_theme::palette::Oklab"><code>Oklab</code></a> in the
<code>sRGB</code> color space, similar to <a href="struct.Okhwb.html" title="struct cosmic::cosmic_theme::palette::Okhwb"><code>Hwb</code></a>.</dd><dt><a class="struct" href="struct.Oklab.html" title="struct cosmic::cosmic_theme::palette::Oklab">Oklab</a></dt><dd>The <a href="https://bottosson.github.io/posts/oklab/">Oklab color space</a>.</dd><dt><a class="struct" href="struct.OklabHue.html" title="struct cosmic::cosmic_theme::palette::OklabHue">Oklab<wbr>Hue</a></dt><dd>A hue type for the Oklab color space.</dd><dt><a class="struct" href="struct.Oklch.html" title="struct cosmic::cosmic_theme::palette::Oklch">Oklch</a></dt><dd>Oklch, a polar version of <a href="struct.Oklab.html" title="struct cosmic::cosmic_theme::palette::Oklab">Oklab</a>.</dd><dt><a class="struct" href="struct.RgbHue.html" title="struct cosmic::cosmic_theme::palette::RgbHue">RgbHue</a></dt><dd>A hue type for the RGB family of color spaces.</dd><dt><a class="struct" href="struct.Xyz.html" title="struct cosmic::cosmic_theme::palette::Xyz">Xyz</a></dt><dd>The CIE 1931 XYZ color space.</dd><dt><a class="struct" href="struct.Yxy.html" title="struct cosmic::cosmic_theme::palette::Yxy">Yxy</a></dt><dd>The CIE 1931 Yxy (xyY) color space.</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.ArrayExt.html" title="trait cosmic::cosmic_theme::palette::ArrayExt">Array<wbr>Ext</a></dt><dd>Extension trait for fixed size arrays.</dd><dt><a class="trait" href="trait.Clamp.html" title="trait cosmic::cosmic_theme::palette::Clamp">Clamp</a></dt><dd>An operator for restricting a colors components to their expected ranges.</dd><dt><a class="trait" href="trait.ClampAssign.html" title="trait cosmic::cosmic_theme::palette::ClampAssign">Clamp<wbr>Assign</a></dt><dd>An assigning operator for restricting a colors components to their expected
ranges.</dd><dt><a class="trait" href="trait.ColorDifference.html" title="trait cosmic::cosmic_theme::palette::ColorDifference">Color<wbr>Difference</a><wbr><span class="stab deprecated" title="">Deprecated</span></dt><dd>A trait for calculating the color difference between two colors.</dd><dt><a class="trait" href="trait.Darken.html" title="trait cosmic::cosmic_theme::palette::Darken">Darken</a></dt><dd>Operators for darkening a color;</dd><dt><a class="trait" href="trait.DarkenAssign.html" title="trait cosmic::cosmic_theme::palette::DarkenAssign">Darken<wbr>Assign</a></dt><dd>Assigning operators for darkening a color;</dd><dt><a class="trait" href="trait.Desaturate.html" title="trait cosmic::cosmic_theme::palette::Desaturate">Desaturate</a></dt><dd>Operator for decreasing the saturation (or chroma) of a color.</dd><dt><a class="trait" href="trait.DesaturateAssign.html" title="trait cosmic::cosmic_theme::palette::DesaturateAssign">Desaturate<wbr>Assign</a></dt><dd>Assigning operator for decreasing the saturation (or chroma) of a color.</dd><dt><a class="trait" href="trait.FromColor.html" title="trait cosmic::cosmic_theme::palette::FromColor">From<wbr>Color</a></dt><dd>A trait for converting one color from another, in a possibly lossy way.</dd><dt><a class="trait" href="trait.FromColorMut.html" title="trait cosmic::cosmic_theme::palette::FromColorMut">From<wbr>Color<wbr>Mut</a></dt><dd>Temporarily convert colors in place.</dd><dt><a class="trait" href="trait.GetHue.html" title="trait cosmic::cosmic_theme::palette::GetHue">GetHue</a></dt><dd>A trait for colors where a hue may be calculated.</dd><dt><a class="trait" href="trait.IntoColor.html" title="trait cosmic::cosmic_theme::palette::IntoColor">Into<wbr>Color</a></dt><dd>A trait for converting a color into another, in a possibly lossy way.</dd><dt><a class="trait" href="trait.IntoColorMut.html" title="trait cosmic::cosmic_theme::palette::IntoColorMut">Into<wbr>Color<wbr>Mut</a></dt><dd>Temporarily convert colors in place. The <code>Into</code> counterpart to
<a href="trait.FromColorMut.html" title="trait cosmic::cosmic_theme::palette::FromColorMut"><code>FromColorMut</code></a>.</dd><dt><a class="trait" href="trait.IsWithinBounds.html" title="trait cosmic::cosmic_theme::palette::IsWithinBounds">IsWithin<wbr>Bounds</a></dt><dd>Checks if color components are within their expected range bounds.</dd><dt><a class="trait" href="trait.Lighten.html" title="trait cosmic::cosmic_theme::palette::Lighten">Lighten</a></dt><dd>Operators for lightening a color.</dd><dt><a class="trait" href="trait.LightenAssign.html" title="trait cosmic::cosmic_theme::palette::LightenAssign">Lighten<wbr>Assign</a></dt><dd>Assigning operators for lightening a color.</dd><dt><a class="trait" href="trait.Mix.html" title="trait cosmic::cosmic_theme::palette::Mix">Mix</a></dt><dd>Linear color interpolation of two colors.</dd><dt><a class="trait" href="trait.MixAssign.html" title="trait cosmic::cosmic_theme::palette::MixAssign">MixAssign</a></dt><dd>Assigning linear color interpolation of two colors.</dd><dt><a class="trait" href="trait.NextArray.html" title="trait cosmic::cosmic_theme::palette::NextArray">Next<wbr>Array</a></dt><dd>Temporary helper trait for getting an array type of size <code>N + 1</code>.</dd><dt><a class="trait" href="trait.RelativeContrast.html" title="trait cosmic::cosmic_theme::palette::RelativeContrast">Relative<wbr>Contrast</a><wbr><span class="stab deprecated" title="">Deprecated</span></dt><dd>A trait for calculating relative contrast between two colors.</dd><dt><a class="trait" href="trait.Saturate.html" title="trait cosmic::cosmic_theme::palette::Saturate">Saturate</a></dt><dd>Operator for increasing the saturation (or chroma) of a color.</dd><dt><a class="trait" href="trait.SaturateAssign.html" title="trait cosmic::cosmic_theme::palette::SaturateAssign">Saturate<wbr>Assign</a></dt><dd>Assigning operator for increasing the saturation (or chroma) of a color.</dd><dt><a class="trait" href="trait.SetHue.html" title="trait cosmic::cosmic_theme::palette::SetHue">SetHue</a></dt><dd>Change the hue of a color to a specific value without moving.</dd><dt><a class="trait" href="trait.ShiftHue.html" title="trait cosmic::cosmic_theme::palette::ShiftHue">Shift<wbr>Hue</a></dt><dd>Operator for increasing or decreasing the hue by an amount.</dd><dt><a class="trait" href="trait.ShiftHueAssign.html" title="trait cosmic::cosmic_theme::palette::ShiftHueAssign">Shift<wbr>HueAssign</a></dt><dd>Assigning operator for increasing or decreasing the hue by an amount.</dd><dt><a class="trait" href="trait.WithAlpha.html" title="trait cosmic::cosmic_theme::palette::WithAlpha">With<wbr>Alpha</a></dt><dd>A trait for color types that can have or be given transparency (alpha channel).</dd><dt><a class="trait" href="trait.WithHue.html" title="trait cosmic::cosmic_theme::palette::WithHue">WithHue</a></dt><dd>Change the hue of a color to a specific value.</dd></dl><h2 id="functions" class="section-header">Functions<a href="#functions" class="anchor">§</a></h2><dl class="item-table"><dt><a class="fn" href="fn.contrast_ratio.html" title="fn cosmic::cosmic_theme::palette::contrast_ratio">contrast_<wbr>ratio</a><wbr><span class="stab deprecated" title="">Deprecated</span></dt><dd>Calculate the ratio between two <code>luma</code> values.</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.GammaLuma.html" title="type cosmic::cosmic_theme::palette::GammaLuma">Gamma<wbr>Luma</a></dt><dd>Gamma 2.2 encoded luminance.</dd><dt><a class="type" href="type.GammaLumaa.html" title="type cosmic::cosmic_theme::palette::GammaLumaa">Gamma<wbr>Lumaa</a></dt><dd>Gamma 2.2 encoded luminance with an alpha component.</dd><dt><a class="type" href="type.GammaSrgb.html" title="type cosmic::cosmic_theme::palette::GammaSrgb">Gamma<wbr>Srgb</a></dt><dd>Gamma 2.2 encoded sRGB.</dd><dt><a class="type" href="type.GammaSrgba.html" title="type cosmic::cosmic_theme::palette::GammaSrgba">Gamma<wbr>Srgba</a></dt><dd>Gamma 2.2 encoded sRGB with an alpha component.</dd><dt><a class="type" href="type.Hsla.html" title="type cosmic::cosmic_theme::palette::Hsla">Hsla</a></dt><dd>Linear HSL with an alpha component. See the <a href="struct.Alpha.html#Hsla" title="struct cosmic::cosmic_theme::palette::Alpha"><code>Hsla</code> implementation in
<code>Alpha</code></a>.</dd><dt><a class="type" href="type.Hsluva.html" title="type cosmic::cosmic_theme::palette::Hsluva">Hsluva</a></dt><dd>HSLuv with an alpha component. See the <a href="struct.Alpha.html#Hsluva" title="struct cosmic::cosmic_theme::palette::Alpha"><code>Hsluva</code> implementation in
<code>Alpha</code></a>.</dd><dt><a class="type" href="type.Hsva.html" title="type cosmic::cosmic_theme::palette::Hsva">Hsva</a></dt><dd>Linear HSV with an alpha component. See the <a href="struct.Alpha.html#Hsva" title="struct cosmic::cosmic_theme::palette::Alpha"><code>Hsva</code> implementation in
<code>Alpha</code></a>.</dd><dt><a class="type" href="type.Hwba.html" title="type cosmic::cosmic_theme::palette::Hwba">Hwba</a></dt><dd>Linear HWB with an alpha component. See the <a href="struct.Alpha.html#Hwba" title="struct cosmic::cosmic_theme::palette::Alpha"><code>Hwba</code> implementation in
<code>Alpha</code></a>.</dd><dt><a class="type" href="type.Laba.html" title="type cosmic::cosmic_theme::palette::Laba">Laba</a></dt><dd>CIE L*a*b* (CIELAB) with an alpha component. See the <a href="struct.Alpha.html#Laba" title="struct cosmic::cosmic_theme::palette::Alpha"><code>Laba</code>
implementation in <code>Alpha</code></a>.</dd><dt><a class="type" href="type.Lcha.html" title="type cosmic::cosmic_theme::palette::Lcha">Lcha</a></dt><dd>CIE L*C*h° with an alpha component. See the <a href="struct.Alpha.html#Lcha" title="struct cosmic::cosmic_theme::palette::Alpha"><code>Lcha</code> implementation in
<code>Alpha</code></a>.</dd><dt><a class="type" href="type.Lchuva.html" title="type cosmic::cosmic_theme::palette::Lchuva">Lchuva</a></dt><dd>CIE L*C*uv h°uv with an alpha component. See the <a href="struct.Alpha.html#Lchuva" title="struct cosmic::cosmic_theme::palette::Alpha"><code>Lchuva</code> implementation in
<code>Alpha</code></a>.</dd><dt><a class="type" href="type.LinLuma.html" title="type cosmic::cosmic_theme::palette::LinLuma">LinLuma</a></dt><dd>Linear luminance.</dd><dt><a class="type" href="type.LinLumaa.html" title="type cosmic::cosmic_theme::palette::LinLumaa">LinLumaa</a></dt><dd>Linear luminance with an alpha component.</dd><dt><a class="type" href="type.LinSrgb.html" title="type cosmic::cosmic_theme::palette::LinSrgb">LinSrgb</a></dt><dd>Linear sRGB.</dd><dt><a class="type" href="type.LinSrgba.html" title="type cosmic::cosmic_theme::palette::LinSrgba">LinSrgba</a></dt><dd>Linear sRGB with an alpha component.</dd><dt><a class="type" href="type.Luva.html" title="type cosmic::cosmic_theme::palette::Luva">Luva</a></dt><dd>CIE L*u*v* (CIELUV) with an alpha component. See the <a href="struct.Alpha.html#Luva" title="struct cosmic::cosmic_theme::palette::Alpha"><code>Luva</code>
implementation in <code>Alpha</code></a>.</dd><dt><a class="type" href="type.Mat3.html" title="type cosmic::cosmic_theme::palette::Mat3">Mat3</a></dt><dd>A 9 element array representing a 3x3 matrix.</dd><dt><a class="type" href="type.Okhsla.html" title="type cosmic::cosmic_theme::palette::Okhsla">Okhsla</a></dt><dd>Okhsl with an alpha component.</dd><dt><a class="type" href="type.Okhsva.html" title="type cosmic::cosmic_theme::palette::Okhsva">Okhsva</a></dt><dd>Okhsv with an alpha component. See the <a href="struct.Alpha.html#Okhsva" title="struct cosmic::cosmic_theme::palette::Alpha"><code>Okhsva</code> implementation in
<code>Alpha</code></a>.</dd><dt><a class="type" href="type.Okhwba.html" title="type cosmic::cosmic_theme::palette::Okhwba">Okhwba</a></dt><dd>Okhwb with an alpha component. See the <a href="struct.Alpha.html#Okhwba" title="struct cosmic::cosmic_theme::palette::Alpha"><code>Okhwba</code> implementation in
<code>Alpha</code></a>.</dd><dt><a class="type" href="type.Oklaba.html" title="type cosmic::cosmic_theme::palette::Oklaba">Oklaba</a></dt><dd>Oklab with an alpha component.</dd><dt><a class="type" href="type.Oklcha.html" title="type cosmic::cosmic_theme::palette::Oklcha">Oklcha</a></dt><dd>Oklch with an alpha component. See the <a href="struct.Alpha.html#Oklcha" title="struct cosmic::cosmic_theme::palette::Alpha"><code>Oklcha</code> implementation in
<code>Alpha</code></a>.</dd><dt><a class="type" href="type.Srgb.html" title="type cosmic::cosmic_theme::palette::Srgb">Srgb</a></dt><dd>Non-linear sRGB, the most common RGB input/output format.</dd><dt><a class="type" href="type.SrgbLuma.html" title="type cosmic::cosmic_theme::palette::SrgbLuma">Srgb<wbr>Luma</a></dt><dd>sRGB encoded luminance.</dd><dt><a class="type" href="type.SrgbLumaa.html" title="type cosmic::cosmic_theme::palette::SrgbLumaa">Srgb<wbr>Lumaa</a></dt><dd>sRGB encoded luminance with an alpha component.</dd><dt><a class="type" href="type.Srgba.html" title="type cosmic::cosmic_theme::palette::Srgba">Srgba</a></dt><dd>Non-linear sRGB with an alpha component.</dd><dt><a class="type" href="type.Xyza.html" title="type cosmic::cosmic_theme::palette::Xyza">Xyza</a></dt><dd>CIE 1931 XYZ with an alpha component. See the <a href="struct.Alpha.html#Xyza" title="struct cosmic::cosmic_theme::palette::Alpha"><code>Xyza</code> implementation in
<code>Alpha</code></a>.</dd><dt><a class="type" href="type.Yxya.html" title="type cosmic::cosmic_theme::palette::Yxya">Yxya</a></dt><dd>CIE 1931 Yxy (xyY) with an alpha component. See the <a href="struct.Alpha.html#Yxya" title="struct cosmic::cosmic_theme::palette::Alpha"><code>Yxya</code> implementation
in <code>Alpha</code></a>.</dd></dl><h2 id="derives" class="section-header">Derive Macros<a href="#derives" class="anchor">§</a></h2><dl class="item-table"><dt><a class="derive" href="derive.WithAlpha.html" title="derive cosmic::cosmic_theme::palette::WithAlpha">With<wbr>Alpha</a></dt></dl></section></div></main></body></html>