Trait HasGray

Source
pub trait HasGray {
    type Component;

    // Required methods
    fn gray(&self) -> Self::Component;
    fn set_gray(&mut self, value: Self::Component);

    // Provided methods
    fn new_gray(value: Self::Component) -> Self
       where Self: Sized + Default { ... }
    fn with_gray(self, value: Self::Component) -> Self
       where Self: Sized { ... }
}
Expand description

A trait for types that have a ⚫ ⚪ gray component.

Required Associated Types§

Source

type Component

The type of the gray component.

Required Methods§

Source

fn gray(&self) -> Self::Component

Returns the value of the gray component.

Source

fn set_gray(&mut self, value: Self::Component)

Sets the gray component to the given value.

If the color has other components, they are left unchanged.

Provided Methods§

Source

fn new_gray(value: Self::Component) -> Self
where Self: Sized + Default,

Creates a new color with the given gray component.

The other components are set to their default values.

Source

fn with_gray(self, value: Self::Component) -> Self
where Self: Sized,

Converts the color into a new type with the gray component set to the given value.

The other components are left unchanged.

Implementors§

Source§

impl<T> HasGray for Gray<T>
where T: Copy,

Source§

impl<T> HasGray for GrayAlpha<T>
where T: Copy,