pub enum ImageFilter {
Blur {
sigma_x: f64,
sigma_y: f64,
bounds: Option<Rect>,
},
Color(ColorFilter),
Compose {
outer: Arc<ImageFilter>,
inner: Arc<ImageFilter>,
},
Matrix {
data: Matrix4,
filter_quality: FilterQuality,
},
Shader {
shader: RuntimeShader,
filter_quality: FilterQuality,
},
}Expand description
A filter operation to apply to a raster image.
See also:
BackdropFilter, a widget that appliesImageFilterto its rendering.ImageFiltered, a widget that appliesImageFilterto its children.SceneBuilder.pushBackdropFilter, which is the low-level API for using this class as a backdrop filter.SceneBuilder.pushImageFilter, which is the low-level API for using this class as a child layer filter.
Variants§
Blur
A Gaussian blur; Dart’s _GaussianBlurImageFilter.
Fields
Color(ColorFilter)
A ColorFilter used as an image filter; Dart’s ColorFilter implements ImageFilter.
Compose
outer applied to the result of inner; Dart’s _ComposeImageFilter.
Fields
outer: Arc<ImageFilter>The filter that receives the filtered result of inner.
inner: Arc<ImageFilter>The filter that receives the original input.
Matrix
The input moved by a matrix; Dart’s _MatrixImageFilter, made by
ImageFilter::matrix.
Fields
filter_quality: FilterQualityThe quality the moved input is sampled at.
Shader
A FragmentShader’s program run over the input; Dart’s
_FragmentShaderImageFilter, made by ImageFilter::shader.
Fields
shader: RuntimeShaderThe shader’s uniforms and images as they were when the filter was made, its first
image left for the input, which is sampled at filter_quality.
filter_quality: FilterQualityThe quality the input is sampled at.
Implementations§
Source§impl ImageFilter
impl ImageFilter
Sourcepub const fn blur(sigma_x: f64, sigma_y: f64) -> ImageFilter
pub const fn blur(sigma_x: f64, sigma_y: f64) -> ImageFilter
Creates an image filter that applies a Gaussian blur.
Sourcepub fn bounds(self, bounds: Rect) -> ImageFilter
pub fn bounds(self, bounds: Rect) -> ImageFilter
Dart ImageFilter.blur(bounds:).
Sourcepub const fn matrix(
matrix4: Matrix4,
filter_quality: FilterQuality,
) -> ImageFilter
pub const fn matrix( matrix4: Matrix4, filter_quality: FilterQuality, ) -> ImageFilter
Creates an image filter that applies a matrix transformation.
For example, applying a positive scale matrix (see Matrix4.diagonal3) when used with
BackdropFilter would magnify the background image.
The filter_quality argument sets the quality level the moved input is sampled at;
Flutter’s default is FilterQuality::Medium.
Sourcepub fn compose(outer: ImageFilter, inner: ImageFilter) -> ImageFilter
pub fn compose(outer: ImageFilter, inner: ImageFilter) -> ImageFilter
Composes the inner filter with outer, to combine their effects.
Creates a single ImageFilter that when applied, has the same effect as
subsequently applying inner and outer, i.e.,
result = outer(inner(source)).
Sourcepub fn shader(
shader: &FragmentShader,
filter_quality: FilterQuality,
) -> ImageFilter
pub fn shader( shader: &FragmentShader, filter_quality: FilterQuality, ) -> ImageFilter
Creates an image filter from a FragmentShader.
The fragment shader provided here has additional requirements to be used by the engine
for filtering. The first uniform value must be a vec2, this will be set by the engine to
the size of the bound texture. There must also be at least one image, the first of which
will be set by the engine to contain the filter input.
The filter_quality argument sets the quality level used to sample the filter input;
Flutter’s default is FilterQuality::None.
For example, the following is a valid fragment shader that can be used with this API. Note that the uniform names are not required to have any particular value.
struct Uniforms { u_size: vec2<f32>, u_time: f32 }
@group(2) @binding(0) var<uniform> u: Uniforms;
@group(1) @binding(0) var u_texture_input: texture_2d<f32>;
@group(1) @binding(1) var u_texture_input_sampler: sampler;
fn shade(position: vec2<f32>) -> vec4<f32> {
let uv = position / u.u_size;
return textureSampleLevel(u_texture_input, u_texture_input_sampler, uv, 0.0) * u.u_time;
}The uniforms and images are those shader has now; setting them afterwards changes the
filter made next, not this one.
§Panics
Where the shader’s first uniform is not a vec2 or it has no image, as Dart throws a
StateError.
Sourcepub const fn is_shader_filter_supported() -> bool
pub const fn is_shader_filter_supported() -> bool
Whether ImageFilter::shader is supported on the current backend: always, as valo
runs every shader the way Impeller does.
Sourcepub fn debug_short_description(&self) -> String
pub fn debug_short_description(&self) -> String
Dart’s debugShortDescription.
Source§impl ImageFilter
impl ImageFilter
Sourcepub fn to_valo(&self) -> ImageFilter
pub fn to_valo(&self) -> ImageFilter
The valo filter that replays this one, step for step and in the same order.