pub struct Paint { /* private fields */ }
Implementations§
source§impl Paint
impl Paint
sourcepub fn from_color(color: &Color4f) -> Self
pub fn from_color(color: &Color4f) -> Self
Constructs Paint with default values and the given color.
sourcepub fn from_color_space(
color: &Color4f,
color_space: &Option<ColorSpace>
) -> Self
pub fn from_color_space( color: &Color4f, color_space: &Option<ColorSpace> ) -> Self
Constructs Paint with default values and the given color.
Sets alpha and RGB used when stroking and filling.
The color is four floating point values, unpremultiplied.
The color values are interpreted as being in the color_space
.
If color_space
is None, then color is assumed to be in the
sRGB
color space.
§Parameters
color
- unpremultiplied RGBAcolor_space
-ColorSpace
describing the encoding of color
sourcepub fn reset(&mut self)
pub fn reset(&mut self)
Sets all Paint contents to their initial values.
This is equivalent to replacing Paint with the result of Paint::default()
.
sourcepub const fn get_stroke_width(&self) -> Scalar
pub const fn get_stroke_width(&self) -> Scalar
Returns the thickness of the pen used by Paint to outline the shape.
Returns zero for hairline, greater than zero for pen thickness
sourcepub fn set_stroke_width(&mut self, width: Scalar)
pub fn set_stroke_width(&mut self, width: Scalar)
Sets the thickness of the pen used by the paint to outline the shape.
A stroke-width of zero is treated as “hairline” width. Hairlines are always exactly one pixel wide in device space (their thickness does not change as the canvas is scaled). Negative stroke-widths are invalid; setting a negative width will have no effect.
§Parameters
width
- zero thickness for hairline; greater than zero for pen thickness
sourcepub const fn get_stroke_miter(&self) -> Scalar
pub const fn get_stroke_miter(&self) -> Scalar
Returns the limit at which a sharp corner is drawn beveled.
Returns zero and greater miter limit
sourcepub fn set_stroke_miter(&mut self, miter: Scalar)
pub fn set_stroke_miter(&mut self, miter: Scalar)
Sets the limit at which a sharp corner is drawn beveled.
Valid values are zero and greater. Has no effect if miter is less than zero.
§Parameters
miter
- zero and greater miter limit
sourcepub const fn is_anti_alias(&self) -> bool
pub const fn is_anti_alias(&self) -> bool
Returns true if pixels on the active edges of Path may be drawn with partial transparency.
sourcepub fn set_anti_alias(&mut self, aa: bool)
pub fn set_anti_alias(&mut self, aa: bool)
Requests, but does not require, that edge pixels draw opaque or with partial transparency.
sourcepub const fn is_dither(&self) -> bool
pub const fn is_dither(&self) -> bool
Returns true if color error may be distributed to smooth color transition.
sourcepub fn set_dither(&mut self, dither: bool)
pub fn set_dither(&mut self, dither: bool)
Requests, but does not require, to distribute color error.
sourcepub const fn get_style(&self) -> PaintStyle
pub const fn get_style(&self) -> PaintStyle
Returns whether the geometry is filled, stroked, or filled and stroked.
sourcepub fn set_style(&mut self, style: PaintStyle)
pub fn set_style(&mut self, style: PaintStyle)
Sets whether the geometry is filled, stroked, or filled and stroked.
Has no effect if style is not a legal PaintStyle
value.
sourcepub fn set_stroke(&mut self, is_stroke: bool)
pub fn set_stroke(&mut self, is_stroke: bool)
Set paint’s style to PaintStyle::Stroke
if true, or PaintStyle::Fill
if false.
sourcepub const fn get_stroke_cap(&self) -> StrokeCap
pub const fn get_stroke_cap(&self) -> StrokeCap
Returns the geometry drawn at the beginning and end of strokes.
sourcepub fn set_stroke_cap(&mut self, cap: StrokeCap)
pub fn set_stroke_cap(&mut self, cap: StrokeCap)
Sets the geometry drawn at the beginning and end of strokes.
sourcepub const fn get_stroke_join(&self) -> StrokeJoin
pub const fn get_stroke_join(&self) -> StrokeJoin
Returns the geometry drawn at the corners of strokes.
sourcepub fn set_stroke_join(&mut self, join: StrokeJoin)
pub fn set_stroke_join(&mut self, join: StrokeJoin)
Sets the geometry drawn at the corners of strokes.
sourcepub fn get_color(&self) -> Color
pub fn get_color(&self) -> Color
Retrieves alpha and RGB, unpremultiplied, packed into 32 bits.
Use helpers get_alpha()
, get_red()
, get_green()
, and get_blue()
to extract a color component.
sourcepub const fn get_color4f(&self) -> &Color4f
pub const fn get_color4f(&self) -> &Color4f
Retrieves alpha and RGB, unpremultiplied, as four floating point values.
RGB are extended sRGB
values (sRGB
gamut, and encoded with the sRGB
transfer function).
sourcepub fn set_color(&mut self, color: Color)
pub fn set_color(&mut self, color: Color)
Sets alpha and RGB used when stroking and filling.
The color is a 32-bit value, unpremultiplied, packing 8-bit components for alpha, red, blue, and green.
§Parameters
color
- unpremultiplied ARGB
sourcepub fn set_color_space(
&mut self,
color: &Color4f,
color_space: &Option<ColorSpace>
)
pub fn set_color_space( &mut self, color: &Color4f, color_space: &Option<ColorSpace> )
Sets alpha and RGB used when stroking and filling.
The color is four floating point values, unpremultiplied.
The color values are interpreted as being in the color_space
.
If color_space
is None , then color is assumed to be in the sRGB
color space.
§Parameters
color
- unpremultiplied RGBAcolor_space
-ColorSpace
describing the encoding of color
sourcepub const fn get_alphaf(&self) -> Scalar
pub const fn get_alphaf(&self) -> Scalar
Retrieves alpha from the color used when stroking and filling.
Returns alpha ranging from zero, fully transparent, to one, fully opaque
sourcepub fn set_alphaf(&mut self, alpha: f32)
pub fn set_alphaf(&mut self, alpha: f32)
Replaces alpha, leaving RGB unchanged.
alpha is a value from 0.0 to 1.0. alpha set to zero makes color fully transparent; a set to 1.0 makes color fully opaque.
sourcepub fn set_alpha(&mut self, alpha: u8)
pub fn set_alpha(&mut self, alpha: u8)
Helper that accepts an int between 0 and 255, and divides it by 255.0
sourcepub fn set_argb(&mut self, alpha: u8, red: u8, green: u8, blue: u8)
pub fn set_argb(&mut self, alpha: u8, red: u8, green: u8, blue: u8)
Sets color used when drawing solid fills.
The color components range from 0 to 255. The color is unpremultiplied; alpha sets the transparency independent of RGB.
§Parameters
alpha
- amount of alpha, from fully transparent (0) to fully opaque (255)red
- amount of red, from no red (0) to full red (255)green
- amount of green, from no green (0) to full green (255)blue
- amount of blue, from no blue (0) to full blue (255)