pub enum Color {
Luma(Luma),
Oklab(Oklab),
Oklch(Oklch),
Rgb(Rgb),
LinearRgb(LinearRgb),
Cmyk(Cmyk),
Hsl(Hsl),
Hsv(Hsv),
}
Expand description
A color in a specific color space.
Typst supports:
- sRGB through the
rgb
function - Device CMYK through
cmyk
function - D65 Gray through the
luma
function - Oklab through the
oklab
function - Oklch through the
oklch
function - Linear RGB through the
color.linear-rgb
function - HSL through the
color.hsl
function - HSV through the
color.hsv
function
§Example
#rect(fill: aqua)
§Predefined colors
Typst defines the following built-in colors:
Color | Definition |
---|---|
black | {luma(0)} |
gray | {luma(170)} |
silver | {luma(221)} |
white | {luma(255)} |
navy | {rgb("#001f3f")} |
blue | {rgb("#0074d9")} |
aqua | {rgb("#7fdbff")} |
teal | {rgb("#39cccc")} |
eastern | {rgb("#239dad")} |
purple | {rgb("#b10dc9")} |
fuchsia | {rgb("#f012be")} |
maroon | {rgb("#85144b")} |
red | {rgb("#ff4136")} |
orange | {rgb("#ff851b")} |
yellow | {rgb("#ffdc00")} |
olive | {rgb("#3d9970")} |
green | {rgb("#2ecc40")} |
lime | {rgb("#01ff70")} |
The predefined colors and the most important color constructors are
available globally and also in the color type’s scope, so you can write
either color.red
or just red
.
#let colors = (
"black", "gray", "silver", "white",
"navy", "blue", "aqua", "teal",
"eastern", "purple", "fuchsia",
"maroon", "red", "orange", "yellow",
"olive", "green", "lime",
)
#set text(font: "PT Sans")
#set page(width: auto)
#grid(
columns: 9,
gutter: 10pt,
..colors.map(name => {
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: col, name)
})
)
§Predefined color maps
Typst also includes a number of preset color maps that can be used for
gradients. These are simply arrays of colors defined in
the module color.map
.
#circle(fill: gradient.linear(..color.map.crest))
Map | Details |
---|---|
turbo | A perceptually uniform rainbow-like color map. Read this blog post for more details. |
cividis | A blue to gray to yellow color map. See this blog post for more details. |
rainbow | Cycles through the full color spectrum. This color map is best used by setting the interpolation color space to HSL. The rainbow gradient is not suitable for data visualization because it is not perceptually uniform, so the differences between values become unclear to your readers. It should only be used for decorative purposes. |
spectral | Red to yellow to blue color map. |
viridis | A purple to teal to yellow color map. |
inferno | A black to red to yellow color map. |
magma | A black to purple to yellow color map. |
plasma | A purple to pink to yellow color map. |
rocket | A black to red to white color map. |
mako | A black to teal to yellow color map. |
vlag | A light blue to white to red color map. |
icefire | A light teal to black to yellow color map. |
flare | A orange to purple color map that is perceptually uniform. |
crest | A blue to white to red color map. |
Some popular presets are not included because they are not available under a free licence. Others, like Jet, are not included because they are not color blind friendly. Feel free to use or create a package with other presets that are useful to you!
#set page(width: auto, height: auto)
#set text(font: "PT Sans", size: 8pt)
#let maps = (
"turbo", "cividis", "rainbow", "spectral",
"viridis", "inferno", "magma", "plasma",
"rocket", "mako", "vlag", "icefire",
"flare", "crest",
)
#stack(dir: ltr, spacing: 3pt, ..maps.map((name) => {
let map = eval("color.map." + name)
stack(
dir: ttb,
block(
width: 15pt,
height: 100pt,
fill: gradient.linear(..map, angle: 90deg),
),
block(
width: 15pt,
height: 32pt,
move(dy: 8pt, rotate(90deg, name)),
),
)
}))
Variants§
Luma(Luma)
A 32-bit luma color.
Oklab(Oklab)
A 32-bit L*a*b* color in the Oklab color space.
Oklch(Oklch)
A 32-bit LCh color in the Oklab color space.
Rgb(Rgb)
A 32-bit RGB color.
LinearRgb(LinearRgb)
A 32-bit linear RGB color.
Cmyk(Cmyk)
A 32-bit CMYK color.
Hsl(Hsl)
A 32-bit HSL color.
Hsv(Hsv)
A 32-bit HSV color.
Implementations§
Source§impl Color
impl Color
Sourcepub const MAP: fn() -> Module = {<{closure@src/visualize/color.rs:215:37: 215:39} as std::ops::FnOnce<()>>::call_once as fn() -> foundations::module::Module}
pub const MAP: fn() -> Module = {<{closure@src/visualize/color.rs:215:37: 215:39} as std::ops::FnOnce<()>>::call_once as fn() -> foundations::module::Module}
The module of preset color maps.
pub const BLACK: Self
pub const GRAY: Self
pub const WHITE: Self
pub const SILVER: Self
pub const NAVY: Self
pub const BLUE: Self
pub const AQUA: Self
pub const TEAL: Self
pub const EASTERN: Self
pub const PURPLE: Self
pub const FUCHSIA: Self
pub const MAROON: Self
pub const RED: Self
pub const ORANGE: Self
pub const YELLOW: Self
pub const OLIVE: Self
pub const GREEN: Self
pub const LIME: Self
Sourcepub fn luma(args: &mut Args) -> SourceResult<Color>
pub fn luma(args: &mut Args) -> SourceResult<Color>
Create a grayscale color.
A grayscale color is represented internally by a single lightness
component.
These components are also available using the
components
method.
#for x in range(250, step: 50) {
box(square(fill: luma(x)))
}
Sourcepub fn oklab(args: &mut Args) -> SourceResult<Color>
pub fn oklab(args: &mut Args) -> SourceResult<Color>
Create an Oklab color.
This color space is well suited for the following use cases:
- Color manipulation such as saturating while keeping perceived hue
- Creating grayscale images with uniform perceived lightness
- Creating smooth and uniform color transition and gradients
A linear Oklab color is represented internally by an array of four components:
- lightness ([
ratio
]) - a ([
float
] or [ratio
]. Ratios are relative to{0.4}
; meaning{50%}
is equal to{0.2}
) - b ([
float
] or [ratio
]. Ratios are relative to{0.4}
; meaning{50%}
is equal to{0.2}
) - alpha ([
ratio
])
These components are also available using the
components
method.
#square(
fill: oklab(27%, 20%, -3%, 50%)
)
Sourcepub fn oklch(args: &mut Args) -> SourceResult<Color>
pub fn oklch(args: &mut Args) -> SourceResult<Color>
Create an Oklch color.
This color space is well suited for the following use cases:
- Color manipulation involving lightness, chroma, and hue
- Creating grayscale images with uniform perceived lightness
- Creating smooth and uniform color transition and gradients
A linear Oklch color is represented internally by an array of four components:
- lightness ([
ratio
]) - chroma ([
float
] or [ratio
]. Ratios are relative to{0.4}
; meaning{50%}
is equal to{0.2}
) - hue ([
angle
]) - alpha ([
ratio
])
These components are also available using the
components
method.
#square(
fill: oklch(40%, 0.2, 160deg, 50%)
)
Sourcepub fn linear_rgb(args: &mut Args) -> SourceResult<Color>
pub fn linear_rgb(args: &mut Args) -> SourceResult<Color>
Create an RGB(A) color with linear luma.
This color space is similar to sRGB, but with the distinction that the
color component are not gamma corrected. This makes it easier to perform
color operations such as blending and interpolation. Although, you
should prefer to use the oklab
function for these.
A linear RGB(A) color is represented internally by an array of four components:
- red ([
ratio
]) - green ([
ratio
]) - blue ([
ratio
]) - alpha ([
ratio
])
These components are also available using the
components
method.
#square(fill: color.linear-rgb(
30%, 50%, 10%,
))
Sourcepub fn rgb(args: &mut Args) -> SourceResult<Color>
pub fn rgb(args: &mut Args) -> SourceResult<Color>
Create an RGB(A) color.
The color is specified in the sRGB color space.
An RGB(A) color is represented internally by an array of four components:
- red ([
ratio
]) - green ([
ratio
]) - blue ([
ratio
]) - alpha ([
ratio
])
These components are also available using the components
method.
#square(fill: rgb("#b1f2eb"))
#square(fill: rgb(87, 127, 230))
#square(fill: rgb(25%, 13%, 65%))
Sourcepub fn cmyk(args: &mut Args) -> SourceResult<Color>
pub fn cmyk(args: &mut Args) -> SourceResult<Color>
Create a CMYK color.
This is useful if you want to target a specific printer. The conversion to RGB for display preview might differ from how your printer reproduces the color.
A CMYK color is represented internally by an array of four components:
- cyan ([
ratio
]) - magenta ([
ratio
]) - yellow ([
ratio
]) - key ([
ratio
])
These components are also available using the
components
method.
Note that CMYK colors are not currently supported when PDF/A output is enabled.
#square(
fill: cmyk(27%, 0%, 3%, 5%)
)
Sourcepub fn hsl(args: &mut Args) -> SourceResult<Color>
pub fn hsl(args: &mut Args) -> SourceResult<Color>
Create an HSL color.
This color space is useful for specifying colors by hue, saturation and lightness. It is also useful for color manipulation, such as saturating while keeping perceived hue.
An HSL color is represented internally by an array of four components:
- hue ([
angle
]) - saturation ([
ratio
]) - lightness ([
ratio
]) - alpha ([
ratio
])
These components are also available using the
components
method.
#square(
fill: color.hsl(30deg, 50%, 60%)
)
Sourcepub fn hsv(args: &mut Args) -> SourceResult<Color>
pub fn hsv(args: &mut Args) -> SourceResult<Color>
Create an HSV color.
This color space is useful for specifying colors by hue, saturation and value. It is also useful for color manipulation, such as saturating while keeping perceived hue.
An HSV color is represented internally by an array of four components:
- hue ([
angle
]) - saturation ([
ratio
]) - value ([
ratio
]) - alpha ([
ratio
])
These components are also available using the
components
method.
#square(
fill: color.hsv(30deg, 50%, 60%)
)
Sourcepub fn components(self, alpha: bool) -> Array
pub fn components(self, alpha: bool) -> Array
Extracts the components of this color.
The size and values of this array depends on the color space. You can
obtain the color space using space
. Below is a table
of the color spaces and their components:
Color space | C1 | C2 | C3 | C4 |
---|---|---|---|---|
luma | Lightness | |||
oklab | Lightness | a | b | Alpha |
oklch | Lightness | Chroma | Hue | Alpha |
linear-rgb | Red | Green | Blue | Alpha |
rgb | Red | Green | Blue | Alpha |
cmyk | Cyan | Magenta | Yellow | Key |
hsl | Hue | Saturation | Lightness | Alpha |
hsv | Hue | Saturation | Value | Alpha |
For the meaning and type of each individual value, see the documentation
of the corresponding color space. The alpha component is optional and
only included if the alpha
argument is true
. The length of the
returned array depends on the number of components and whether the alpha
component is included.
// note that the alpha component is included by default
#rgb(40%, 60%, 80%).components()
Sourcepub fn space(self) -> ColorSpace
pub fn space(self) -> ColorSpace
Sourcepub fn to_hex(self) -> EcoString
pub fn to_hex(self) -> EcoString
Returns the color’s RGB(A) hex representation (such as #ffaa32
or
#020304fe
). The alpha component (last two digits in #020304fe
) is
omitted if it is equal to ff
(255 / 100%).
Sourcepub fn saturate(self, span: Span, factor: Ratio) -> SourceResult<Color>
pub fn saturate(self, span: Span, factor: Ratio) -> SourceResult<Color>
Increases the saturation of a color by a given factor.
Sourcepub fn desaturate(self, span: Span, factor: Ratio) -> SourceResult<Color>
pub fn desaturate(self, span: Span, factor: Ratio) -> SourceResult<Color>
Decreases the saturation of a color by a given factor.
Sourcepub fn negate(self, space: ColorSpace) -> Color
pub fn negate(self, space: ColorSpace) -> Color
Produces the complementary color using a provided color space. You can think of it as the opposite side on a color wheel.
#square(fill: yellow)
#square(fill: yellow.negate())
#square(fill: yellow.negate(space: rgb))
Sourcepub fn rotate(
self,
span: Span,
angle: Angle,
space: ColorSpace,
) -> SourceResult<Color>
pub fn rotate( self, span: Span, angle: Angle, space: ColorSpace, ) -> SourceResult<Color>
Rotates the hue of the color by a given angle.
Sourcepub fn mix(colors: Vec<WeightedColor>, space: ColorSpace) -> StrResult<Color>
pub fn mix(colors: Vec<WeightedColor>, space: ColorSpace) -> StrResult<Color>
Create a color by mixing two or more colors.
In color spaces with a hue component (hsl, hsv, oklch), only two colors can be mixed at once. Mixing more than two colors in such a space will result in an error!
#set block(height: 20pt, width: 100%)
#block(fill: red.mix(blue))
#block(fill: red.mix(blue, space: rgb))
#block(fill: color.mix(red, blue, white))
#block(fill: color.mix((red, 70%), (blue, 30%)))
Sourcepub fn transparentize(self, scale: Ratio) -> StrResult<Color>
pub fn transparentize(self, scale: Ratio) -> StrResult<Color>
Makes a color more transparent by a given factor.
This method is relative to the existing alpha value.
If the scale is positive, calculates alpha - alpha * scale
.
Negative scales behave like color.opacify(-scale)
.
#block(fill: red)[opaque]
#block(fill: red.transparentize(50%))[half red]
#block(fill: red.transparentize(75%))[quarter red]
Sourcepub fn opacify(self, scale: Ratio) -> StrResult<Color>
pub fn opacify(self, scale: Ratio) -> StrResult<Color>
Makes a color more opaque by a given scale.
This method is relative to the existing alpha value.
If the scale is positive, calculates alpha + scale - alpha * scale
.
Negative scales behave like color.transparentize(-scale)
.
#let half-red = red.transparentize(50%)
#block(fill: half-red.opacify(100%))[opaque]
#block(fill: half-red.opacify(50%))[three quarters red]
#block(fill: half-red.opacify(-50%))[one quarter red]
Source§impl Color
impl Color
Sourcepub fn mix_iter(
colors: impl IntoIterator<Item = WeightedColor, IntoIter = impl ExactSizeIterator<Item = WeightedColor>>,
space: ColorSpace,
) -> StrResult<Color>
pub fn mix_iter( colors: impl IntoIterator<Item = WeightedColor, IntoIter = impl ExactSizeIterator<Item = WeightedColor>>, space: ColorSpace, ) -> StrResult<Color>
Same as Color::mix
, but takes an iterator instead of a vector.
Sourcepub fn from_u8(r: u8, g: u8, b: u8, a: u8) -> Self
pub fn from_u8(r: u8, g: u8, b: u8, a: u8) -> Self
Construct a new RGBA color from 8-bit values.
Sourcepub fn with_alpha(self, alpha: f32) -> Self
pub fn with_alpha(self, alpha: f32) -> Self
Sets the alpha channel of the color, if it has one.
Sourcepub fn to_vec4_u8(&self) -> [u8; 4]
pub fn to_vec4_u8(&self) -> [u8; 4]
Converts the color to a vec of four u8
s.
pub fn to_space(self, space: ColorSpace) -> Self
pub fn to_luma(self) -> Self
pub fn to_oklab(self) -> Self
pub fn to_oklch(self) -> Self
pub fn to_rgb(self) -> Self
pub fn to_linear_rgb(self) -> Self
pub fn to_cmyk(self) -> Self
pub fn to_hsl(self) -> Self
pub fn to_hsv(self) -> Self
Trait Implementations§
Source§impl FromStr for Color
impl FromStr for Color
Source§impl FromValue for Color
impl FromValue for Color
Source§fn from_value(value: Value) -> HintedStrResult<Self>
fn from_value(value: Value) -> HintedStrResult<Self>
Self
.Source§impl NativeScope for Color
impl NativeScope for Color
Source§fn constructor() -> Option<&'static NativeFuncData>
fn constructor() -> Option<&'static NativeFuncData>
Source§impl NativeType for Color
impl NativeType for Color
impl Copy for Color
impl Eq for Color
Auto Trait Implementations§
impl Freeze for Color
impl RefUnwindSafe for Color
impl Send for Color
impl Sync for Color
impl Unpin for Color
impl UnwindSafe for Color
Blanket Implementations§
Source§impl<S, D, Swp, Dwp, T> AdaptInto<D, Swp, Dwp, T> for Swhere
T: Real + Zero + Arithmetics + Clone,
Swp: WhitePoint<T>,
Dwp: WhitePoint<T>,
D: AdaptFrom<S, Swp, Dwp, T>,
impl<S, D, Swp, Dwp, T> AdaptInto<D, Swp, Dwp, T> for Swhere
T: Real + Zero + Arithmetics + Clone,
Swp: WhitePoint<T>,
Dwp: WhitePoint<T>,
D: AdaptFrom<S, Swp, Dwp, T>,
Source§fn adapt_into_using<M>(self, method: M) -> Dwhere
M: TransformMatrix<T>,
fn adapt_into_using<M>(self, method: M) -> Dwhere
M: TransformMatrix<T>,
Source§fn adapt_into(self) -> D
fn adapt_into(self) -> D
Source§impl<T, C> ArraysFrom<C> for Twhere
C: IntoArrays<T>,
impl<T, C> ArraysFrom<C> for Twhere
C: IntoArrays<T>,
Source§fn arrays_from(colors: C) -> T
fn arrays_from(colors: C) -> T
Source§impl<T, C> ArraysInto<C> for Twhere
C: FromArrays<T>,
impl<T, C> ArraysInto<C> for Twhere
C: FromArrays<T>,
Source§fn arrays_into(self) -> C
fn arrays_into(self) -> C
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<WpParam, T, U> Cam16IntoUnclamped<WpParam, T> for Uwhere
T: FromCam16Unclamped<WpParam, U>,
impl<WpParam, T, U> Cam16IntoUnclamped<WpParam, T> for Uwhere
T: FromCam16Unclamped<WpParam, U>,
Source§type Scalar = <T as FromCam16Unclamped<WpParam, U>>::Scalar
type Scalar = <T as FromCam16Unclamped<WpParam, U>>::Scalar
parameters
when converting.Source§fn cam16_into_unclamped(
self,
parameters: BakedParameters<WpParam, <U as Cam16IntoUnclamped<WpParam, T>>::Scalar>,
) -> T
fn cam16_into_unclamped( self, parameters: BakedParameters<WpParam, <U as Cam16IntoUnclamped<WpParam, T>>::Scalar>, ) -> T
self
into C
, using the provided parameters.Source§impl<T> CheckedAs for T
impl<T> CheckedAs for T
Source§fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
Source§impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
Source§fn checked_cast_from(src: Src) -> Option<Dst>
fn checked_cast_from(src: Src) -> Option<Dst>
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T, C> ComponentsFrom<C> for Twhere
C: IntoComponents<T>,
impl<T, C> ComponentsFrom<C> for Twhere
C: IntoComponents<T>,
Source§fn components_from(colors: C) -> T
fn components_from(colors: C) -> T
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.Source§impl<T> FromAngle<T> for T
impl<T> FromAngle<T> for T
Source§fn from_angle(angle: T) -> T
fn from_angle(angle: T) -> T
angle
.Source§impl<T, U> FromStimulus<U> for Twhere
U: IntoStimulus<T>,
impl<T, U> FromStimulus<U> for Twhere
U: IntoStimulus<T>,
Source§fn from_stimulus(other: U) -> T
fn from_stimulus(other: U) -> T
other
into Self
, while performing the appropriate scaling,
rounding and clamping.Source§impl<T> FromValue<Spanned<Value>> for Twhere
T: FromValue,
impl<T> FromValue<Spanned<Value>> for Twhere
T: FromValue,
Source§fn from_value(value: Spanned<Value>) -> Result<T, HintedString>
fn from_value(value: Spanned<Value>) -> Result<T, HintedString>
Self
.Source§impl<T, U> IntoAngle<U> for Twhere
U: FromAngle<T>,
impl<T, U> IntoAngle<U> for Twhere
U: FromAngle<T>,
Source§fn into_angle(self) -> U
fn into_angle(self) -> U
T
.Source§impl<WpParam, T, U> IntoCam16Unclamped<WpParam, T> for Uwhere
T: Cam16FromUnclamped<WpParam, U>,
impl<WpParam, T, U> IntoCam16Unclamped<WpParam, T> for Uwhere
T: Cam16FromUnclamped<WpParam, U>,
Source§type Scalar = <T as Cam16FromUnclamped<WpParam, U>>::Scalar
type Scalar = <T as Cam16FromUnclamped<WpParam, U>>::Scalar
parameters
when converting.Source§fn into_cam16_unclamped(
self,
parameters: BakedParameters<WpParam, <U as IntoCam16Unclamped<WpParam, T>>::Scalar>,
) -> T
fn into_cam16_unclamped( self, parameters: BakedParameters<WpParam, <U as IntoCam16Unclamped<WpParam, T>>::Scalar>, ) -> T
self
into C
, using the provided parameters.Source§impl<T, U> IntoColor<U> for Twhere
U: FromColor<T>,
impl<T, U> IntoColor<U> for Twhere
U: FromColor<T>,
Source§fn into_color(self) -> U
fn into_color(self) -> U
Source§impl<T, U> IntoColorUnclamped<U> for Twhere
U: FromColorUnclamped<T>,
impl<T, U> IntoColorUnclamped<U> for Twhere
U: FromColorUnclamped<T>,
Source§fn into_color_unclamped(self) -> U
fn into_color_unclamped(self) -> U
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> IntoResult for Twhere
T: IntoValue,
impl<T> IntoResult for Twhere
T: IntoValue,
Source§fn into_result(self, _: Span) -> Result<Value, EcoVec<SourceDiagnostic>>
fn into_result(self, _: Span) -> Result<Value, EcoVec<SourceDiagnostic>>
Source§impl<T> IntoStimulus<T> for T
impl<T> IntoStimulus<T> for T
Source§fn into_stimulus(self) -> T
fn into_stimulus(self) -> T
self
into T
, while performing the appropriate scaling,
rounding and clamping.Source§impl<T> OverflowingAs for T
impl<T> OverflowingAs for T
Source§fn overflowing_as<Dst>(self) -> (Dst, bool)where
T: OverflowingCast<Dst>,
fn overflowing_as<Dst>(self) -> (Dst, bool)where
T: OverflowingCast<Dst>,
Source§impl<Src, Dst> OverflowingCastFrom<Src> for Dstwhere
Src: OverflowingCast<Dst>,
impl<Src, Dst> OverflowingCastFrom<Src> for Dstwhere
Src: OverflowingCast<Dst>,
Source§fn overflowing_cast_from(src: Src) -> (Dst, bool)
fn overflowing_cast_from(src: Src) -> (Dst, bool)
Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> SaturatingAs for T
impl<T> SaturatingAs for T
Source§fn saturating_as<Dst>(self) -> Dstwhere
T: SaturatingCast<Dst>,
fn saturating_as<Dst>(self) -> Dstwhere
T: SaturatingCast<Dst>,
Source§impl<Src, Dst> SaturatingCastFrom<Src> for Dstwhere
Src: SaturatingCast<Dst>,
impl<Src, Dst> SaturatingCastFrom<Src> for Dstwhere
Src: SaturatingCast<Dst>,
Source§fn saturating_cast_from(src: Src) -> Dst
fn saturating_cast_from(src: Src) -> Dst
Source§impl<T, C> TryComponentsInto<C> for Twhere
C: TryFromComponents<T>,
impl<T, C> TryComponentsInto<C> for Twhere
C: TryFromComponents<T>,
Source§type Error = <C as TryFromComponents<T>>::Error
type Error = <C as TryFromComponents<T>>::Error
try_into_colors
fails to cast.Source§fn try_components_into(self) -> Result<C, <T as TryComponentsInto<C>>::Error>
fn try_components_into(self) -> Result<C, <T as TryComponentsInto<C>>::Error>
Source§impl<T, U> TryIntoColor<U> for Twhere
U: TryFromColor<T>,
impl<T, U> TryIntoColor<U> for Twhere
U: TryFromColor<T>,
Source§fn try_into_color(self) -> Result<U, OutOfBounds<U>>
fn try_into_color(self) -> Result<U, OutOfBounds<U>>
OutOfBounds
error is returned which contains
the unclamped color. Read more