Struct jiao::core::paint::Paint

source ·
pub struct Paint { /* private fields */ }

Implementations§

source§

impl Paint

source

pub fn new() -> Self

Constructs Paint with default values.

source

pub fn from_color(color: &Color4f) -> Self

Constructs Paint with default values and the given color.

source

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 RGBA
  • color_space - ColorSpace describing the encoding of color
source

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().

source

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

source

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
source

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

source

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
source

pub const fn is_anti_alias(&self) -> bool

Returns true if pixels on the active edges of Path may be drawn with partial transparency.

source

pub fn set_anti_alias(&mut self, aa: bool)

Requests, but does not require, that edge pixels draw opaque or with partial transparency.

source

pub const fn is_dither(&self) -> bool

Returns true if color error may be distributed to smooth color transition.

source

pub fn set_dither(&mut self, dither: bool)

Requests, but does not require, to distribute color error.

source

pub const fn get_style(&self) -> PaintStyle

Returns whether the geometry is filled, stroked, or filled and stroked.

source

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.

source

pub fn set_stroke(&mut self, is_stroke: bool)

Set paint’s style to PaintStyle::Stroke if true, or PaintStyle::Fill if false.

source

pub const fn get_stroke_cap(&self) -> StrokeCap

Returns the geometry drawn at the beginning and end of strokes.

source

pub fn set_stroke_cap(&mut self, cap: StrokeCap)

Sets the geometry drawn at the beginning and end of strokes.

source

pub const fn get_stroke_join(&self) -> StrokeJoin

Returns the geometry drawn at the corners of strokes.

source

pub fn set_stroke_join(&mut self, join: StrokeJoin)

Sets the geometry drawn at the corners of strokes.

source

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.

source

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).

source

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
source

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 RGBA
  • color_space - ColorSpace describing the encoding of color
source

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

source

pub fn get_alpha(&self) -> u8

Helper that scales the alpha by 255.

source

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.

source

pub fn set_alpha(&mut self, alpha: u8)

Helper that accepts an int between 0 and 255, and divides it by 255.0

source

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)

Trait Implementations§

source§

impl Clone for Paint

source§

fn clone(&self) -> Paint

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Paint

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for Paint

source§

fn default() -> Self

Returns the “default value” for a type. Read more
source§

impl PartialEq for Paint

source§

fn eq(&self, other: &Paint) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl StructuralPartialEq for Paint

Auto Trait Implementations§

§

impl Freeze for Paint

§

impl RefUnwindSafe for Paint

§

impl Send for Paint

§

impl Sync for Paint

§

impl Unpin for Paint

§

impl UnwindSafe for Paint

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.