pub struct ColorValue {
pub space: Option<Arc<ColorSpace>>,
pub components: SmallVec<[f32; 4]>,
pub pattern: Option<Box<PatternValue>>,
}Expand description
A colour in some space.
Cheap to clone — the space is shared, the components are inline.
Fields§
§space: Option<Arc<ColorSpace>>The space the components live in. None before any colour operator
has run, which reads as DeviceGray on first use.
components: SmallVec<[f32; 4]>The components, whose length always matches the space when set.
pattern: Option<Box<PatternValue>>The pattern, when the space is /Pattern.
Implementations§
Source§impl ColorValue
impl ColorValue
Sourcepub fn set_space(&mut self, space: Arc<ColorSpace>)
pub fn set_space(&mut self, space: Arc<ColorSpace>)
Install a colorspace, resetting the components to its default colour.
This is what makes cs discard whatever colour was current: the
operands that follow are the only ones that count.
Sourcepub fn set_components(
&mut self,
values: &[f32],
) -> Result<(), SetComponentsError>
pub fn set_components( &mut self, values: &[f32], ) -> Result<(), SetComponentsError>
Set the components without changing the space.
Too few values change nothing; surplus values are kept, since
PDFium stores the vector verbatim. With no space installed,
DeviceGray is installed first.
§Errors
SetComponentsError::TooFew when values is shorter than the space
requires. SetComponentsError::PatternSpace when the current space
is a pattern — only scn with a name changes a pattern colour.
Sourcepub fn set_stock(&mut self, space: ColorSpace, values: &[f32])
pub fn set_stock(&mut self, space: ColorSpace, values: &[f32])
Set both the space and the components in one step, as g, rg and
k do.
Sourcepub fn set_pattern(
&mut self,
name: Name,
values: &[f32],
loaded: Option<Arc<Pattern>>,
)
pub fn set_pattern( &mut self, name: Name, values: &[f32], loaded: Option<Arc<Pattern>>, )
Install a pattern, with the operands an uncoloured one paints with.
More than sixteen operands is refused outright: nothing is written, so
the colour keeps whatever pattern it had, or none. Otherwise the space
becomes /Pattern if it was not one already, so a /P1 scn with no
preceding /Pattern cs still paints the pattern rather than resolving
its operands through whatever space was current.
Sourcepub fn to_rgb(&self) -> Option<Rgb>
pub fn to_rgb(&self) -> Option<Rgb>
The colour to paint with, or None when the space cannot produce one
— a /None separation, an out-of-range palette index, or a pattern.
Sourcepub fn is_pattern(&self) -> bool
pub fn is_pattern(&self) -> bool
Whether this colour comes from a pattern.
Trait Implementations§
Source§impl Clone for ColorValue
impl Clone for ColorValue
Source§fn clone(&self) -> ColorValue
fn clone(&self) -> ColorValue
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more