| 1 | //! Linear encoding |
| 2 | |
| 3 | use corerust-analyzer cargo core https://github.com/rust-lang/rust/library/core crate/::markerrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/::PhantomDatarust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/PhantomData#; |
| 4 | |
| 5 | use craterust-analyzer cargo palette 0.7.6 crate/::{ |
| 6 | lumarust-analyzer cargo palette 0.7.6 luma/::LumaStandardrust-analyzer cargo palette 0.7.6 luma/LumaStandard#, |
| 7 | rgbrust-analyzer cargo palette 0.7.6 rgb/::{RgbSpacerust-analyzer cargo palette 0.7.6 rgb/RgbSpace#, RgbStandardrust-analyzer cargo palette 0.7.6 rgb/RgbStandard#}, |
| 8 | }; |
| 9 | |
| 10 | use superrust-analyzer cargo palette 0.7.6 encoding/::{FromLinearrust-analyzer cargo palette 0.7.6 encoding/FromLinear#, IntoLinearrust-analyzer cargo palette 0.7.6 encoding/IntoLinear#}; |
| 11 | |
| 12 | /// A generic standard with linear components. |
| 13 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Copy:, Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:, Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:, Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq:)] |
| 14 | pub struct Linearrust-analyzer cargo palette 0.7.6 encoding/linear/Linear#<S>(PhantomDatarust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/PhantomData#<S>); |
| 15 | |
| 16 | impl<Sp> RgbStandardrust-analyzer cargo palette 0.7.6 rgb/RgbStandard# for Linearrust-analyzer cargo palette 0.7.6 encoding/linear/Linear#<Sp> |
| 17 | where |
| 18 | Sp: RgbSpacerust-analyzer cargo palette 0.7.6 rgb/RgbSpace#, |
| 19 | { |
| 20 | type Spacerust-analyzer cargo palette 0.7.6 encoding/linear/impl#[`Linear<Sp>`][RgbStandard]Space# = Sp; |
| 21 | type TransferFnrust-analyzer cargo palette 0.7.6 encoding/linear/impl#[`Linear<Sp>`][RgbStandard]TransferFn# = LinearFnrust-analyzer cargo palette 0.7.6 encoding/linear/LinearFn#; |
| 22 | } |
| 23 | |
| 24 | impl<Wp> LumaStandardrust-analyzer cargo palette 0.7.6 luma/LumaStandard# for Linearrust-analyzer cargo palette 0.7.6 encoding/linear/Linear#<Wp> { |
| 25 | type WhitePointrust-analyzer cargo palette 0.7.6 encoding/linear/impl#[`Linear<Wp>`][LumaStandard]WhitePoint# = Wp; |
| 26 | type TransferFnrust-analyzer cargo palette 0.7.6 encoding/linear/impl#[`Linear<Wp>`][LumaStandard]TransferFn# = LinearFnrust-analyzer cargo palette 0.7.6 encoding/linear/LinearFn#; |
| 27 | } |
| 28 | |
| 29 | /// Linear color component encoding. |
| 30 | /// |
| 31 | /// Converting anything from linear to linear space is a no-op and constant |
| 32 | /// time. This is a useful property in generic code, where the transfer |
| 33 | /// functions may be unknown. |
| 34 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Copy:, Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:, Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:, Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq:)] |
| 35 | pub struct LinearFnrust-analyzer cargo palette 0.7.6 encoding/linear/LinearFn#; |
| 36 | |
| 37 | impl<T> IntoLinearrust-analyzer cargo palette 0.7.6 encoding/IntoLinear#<T, T> for LinearFnrust-analyzer cargo palette 0.7.6 encoding/linear/LinearFn# { |
| 38 | #[inline(always)] |
| 39 | fn into_linearrust-analyzer cargo palette 0.7.6 encoding/linear/impl#[LinearFn][`IntoLinear<T, T>`]into_linear().(x: T) -> T { |
| 40 | x |
| 41 | } |
| 42 | } |
| 43 | |
| 44 | impl<T> FromLinearrust-analyzer cargo palette 0.7.6 encoding/FromLinear#<T, T> for LinearFnrust-analyzer cargo palette 0.7.6 encoding/linear/LinearFn# { |
| 45 | #[inline(always)] |
| 46 | fn from_linearrust-analyzer cargo palette 0.7.6 encoding/linear/impl#[LinearFn][`FromLinear<T, T>`]from_linear().(x: T) -> T { |
| 47 | x |
| 48 | } |
| 49 | } |