pub trait ColorBase {
type Component;
// Required methods
fn color_component_count(&self) -> usize ⓘ;
fn color_components_write(&self, buffer: &mut [Self::Component]);
// Provided method
fn color_components_vec(&self) -> Vec<Self::Component> ⓘ
where Self::Component: Default + Clone { ... }
}
Available on crate feature
color
only.Expand description
Base trait for general color data representation.
Provides a core interface for working with color data across different formats and models, supporting both practical and scientific applications.
Required Associated Types§
Required Methods§
Sourcefn color_component_count(&self) -> usize ⓘ
fn color_component_count(&self) -> usize ⓘ
Returns the number of color components.
For example:
- RGB returns
3
- Spectral data may return
n
Sourcefn color_components_write(&self, buffer: &mut [Self::Component])
fn color_components_write(&self, buffer: &mut [Self::Component])
Writes the color components to a pre-allocated buffer.
§Panics
Panics if the buffer size is less than color_component_count()
.