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: Colorcolor supplies solid-draw color and the alpha for shader or image draws.
Shader and image draws ignore its RGB channels.
blend_mode: BlendModeblend_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: PaintStylestyle selects fill or stroke rendering.
Implementations§
Source§impl Paint
impl Paint
Sourcepub fn from_color(color: Color) -> Paint
pub fn from_color(color: Color) -> Paint
from_color creates a solid-color fill paint.
Sourcepub fn from_shader(shader: Shader) -> Paint
pub fn from_shader(shader: Shader) -> Paint
from_shader creates a fill paint using a per-pixel shader.
Sourcepub fn effective_image_filter(&self) -> Option<&ImageFilter>
pub fn effective_image_filter(&self) -> Option<&ImageFilter>
effective_image_filter returns the image filter when it changes pixels.
Sourcepub fn mask_padding(&self) -> f32
pub fn mask_padding(&self) -> f32
mask_padding returns conservative local padding for the mask blur.
Sourcepub fn effect_padding_axes(&self) -> [f32; 2]
pub fn effect_padding_axes(&self) -> [f32; 2]
effect_padding_axes returns local x and y padding for raster effects.
Sourcepub fn effect_padding(&self) -> f32
pub fn effect_padding(&self) -> f32
effect_padding returns the largest local-axis padding for raster effects.
Sourcepub fn device_effect_padding(&self, transform: &Matrix) -> f32
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.
Sourcepub fn effect_bounds(&self, bounds: Rect) -> Bounds
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.
Sourcepub fn draw_fills_clip(&self) -> bool
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).
Sourcepub fn stroke_padding(&self) -> f32
pub fn stroke_padding(&self) -> f32
stroke_padding returns conservative stroke expansion at unit scale.
Sourcepub fn stroke_padding_at_scale(&self, scale: f32) -> f32
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.