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.
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) -> Self
pub fn from_color(color: Color) -> Self
from_color creates a solid-color fill paint.
Sourcepub fn from_shader(shader: Shader) -> Self
pub fn from_shader(shader: Shader) -> Self
from_shader creates a fill paint using a per-pixel shader.
Sourcepub fn is_opacity_only(&self) -> bool
pub fn is_opacity_only(&self) -> bool
is_opacity_only reports whether this paint is only a SrcOver alpha.
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) -> Rect
pub fn effect_bounds(&self, bounds: Rect) -> Rect
effect_bounds returns local bounds required by this paint’s effects.
Filters that create visible pixels from transparency return unbounded coverage for the caller to intersect with its active 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.