Skip to main content

Paint

Struct Paint 

Source
pub struct Paint {
    pub color: Color,
    pub blend_mode: BlendMode,
    pub shader: Option<Shader>,
    pub mask_blur: Option<MaskBlur>,
    pub color_filter: Option<ColorFilter>,
    pub image_filter: Option<ImageFilter>,
    pub style: PaintStyle,
}
Expand description

Paint describes how a drawing operation produces and composites pixels.

The default is an opaque black fill using BlendMode::SrcOver.

Fields§

§color: Color

color supplies solid-draw color and the alpha for shader or image draws.

Shader and image draws ignore its RGB channels.

§blend_mode: BlendMode

blend_mode controls compositing with destination pixels.

§shader: Option<Shader>

shader replaces the solid color with a per-pixel source.

§mask_blur: Option<MaskBlur>

mask_blur softens the draw’s coverage. A save layer’s paint takes none: the layer is recorded without it.

§color_filter: Option<ColorFilter>

color_filter transforms produced colors before mask blur.

§image_filter: Option<ImageFilter>

image_filter transforms the rasterized draw or layer.

§style: PaintStyle

style selects fill or stroke rendering.

Implementations§

Source§

impl Paint

Source

pub fn from_color(color: Color) -> Paint

from_color creates a solid-color fill paint.

Source

pub fn from_shader(shader: Shader) -> Paint

from_shader creates a fill paint using a per-pixel shader.

Source

pub fn is_nop(&self) -> bool

is_nop reports whether this paint can produce no visible change.

Source

pub fn effective_image_filter(&self) -> Option<&ImageFilter>

effective_image_filter returns the image filter when it changes pixels.

Source

pub fn mask_padding(&self) -> f32

mask_padding returns conservative local padding for the mask blur.

Source

pub fn effect_padding_axes(&self) -> [f32; 2]

effect_padding_axes returns local x and y padding for raster effects.

Source

pub fn effect_padding(&self) -> f32

effect_padding returns the largest local-axis padding for raster effects.

Source

pub fn device_effect_padding(&self, transform: &Matrix) -> f32

device_effect_padding returns effect padding in device pixels.

It maps both local padding axes through transform, preserving a conservative bound under rotation and shear.

Source

pub fn effect_bounds(&self, bounds: Rect) -> Bounds

effect_bounds returns where a draw of bounds with this paint may show, in local coordinates, its effects included.

A draw whose paint fills its clip (Paint::draw_fills_clip) is unbounded: only its clip bounds it.

Source

pub fn draw_fills_clip(&self) -> bool

draw_fills_clip reports whether a draw with this paint covers its whole clip, whatever its shape: its image filter colours transparent pixels, which then show everywhere the clip lets them, as Skia draws it.

A colour filter does not: it stays inside the shape it colours (Flutter’s AdjustBoundsForPaint). On a save layer either filter, or a destructive blend, fills the clip instead (Op::SaveLayer’s floods_clip).

Source

pub fn stroke_padding(&self) -> f32

stroke_padding returns conservative stroke expansion at unit scale.

Source

pub fn stroke_padding_at_scale(&self, scale: f32) -> f32

stroke_padding_at_scale returns stroke expansion at a device scale.

Hairlines and minified strokes retain at least one device pixel.

Trait Implementations§

Source§

impl Clone for Paint

Source§

fn clone(&self) -> Paint

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · 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<(), Error>

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

impl Default for Paint

Source§

fn default() -> Paint

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

impl PartialEq for Paint

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Paint

Auto Trait Implementations§

§

impl !RefUnwindSafe for Paint

§

impl !UnwindSafe for Paint

§

impl Freeze for Paint

§

impl Send for Paint

§

impl Sync for Paint

§

impl Unpin for Paint

§

impl UnsafeUnpin 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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

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

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> Downcast<T> for T

Source§

fn downcast(&self) -> &T

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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

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

Source§

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>,

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

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

Source§

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.
Source§

impl<T> Upcast<T> for T

Source§

fn upcast(&self) -> Option<&T>

Source§

impl<T> WasmNotSend for T
where T: Send,

Source§

impl<T> WasmNotSendSync for T

Source§

impl<T> WasmNotSync for T
where T: Sync,