Trait palette::stimulus::Stimulus

source ·
pub trait Stimulus: Zero {
    // Required method
    fn max_intensity() -> Self;
}
Expand description

Color components that represent a stimulus intensity.

The term “stimulus” comes from “tristimulus”, literally a set of three stimuli, which is a term for color spaces that measure the intensity of three primary color values. Classic examples of tristimulus color space are XYZ and RGB.

Stimulus values are expected to have these properties:

  • Has a typical range from 0 to some finite maximum, the “max intensity”. This represents a range from 0% to 100%. For example 0u8 to 255u8, 0.0f32 to 1.0f32.
  • Values below 0 are considered invalid for display purposes, but may still be used in calculations.
  • Values above the “max intensity” are sometimes supported, depending on the application. For example in 3D rendering, where high values represent intense light.
  • Unsigned integer values (u8, u16, u32, etc.) have a range from 0 to their largest representable value. For example 0u8 to 255u8 or 0u16 to 65535u16.
  • Real values (f32, f64, fixed point types, etc.) have a range from 0.0 to 1.0.

Required Methods§

source

fn max_intensity() -> Self

The highest displayable value this component type can reach. Integers types are expected to return their maximum value, while real numbers (like floats) return 1.0. Higher values are allowed, but they may be lowered to this before converting to another format.

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl Stimulus for u8

source§

impl Stimulus for u16

source§

impl Stimulus for u32

source§

impl Stimulus for u64

source§

impl Stimulus for u128

Implementors§

source§

impl<T> Stimulus for T
where T: Real + One + Zero,