BlurVisualEffect

A VisualEffect implementation that applies blur effects to content.

This effect supports various blur-related features including:

  • Configurable blur radius

  • Tinting with multiple colors

  • Progressive (gradient) blur

  • Noise overlays

  • Background color

  • Alpha masking

Example usage:

Modifier.hazeEffect { scope ->
scope.visualEffect = BlurVisualEffect().apply {
blurRadius = 20.dp
tints = listOf(HazeTint(Color.Black.copy(alpha = 0.5f)))
}
}

Constructors

Link copied to clipboard
constructor()

Properties

Link copied to clipboard

The opacity that the overall effect will drawn with, in the range of 0..1.

Link copied to clipboard

Color to draw behind the blurred content. Ideally should be opaque so that the original content is not visible behind. Typically this would be MaterialTheme.colorScheme.surface or similar.

Link copied to clipboard

Whether the blur effect is enabled or not, when running on platforms which support blurring.

Link copied to clipboard

Radius of the blur.

Link copied to clipboard

The BlurredEdgeTreatment to use when blurring content.

Link copied to clipboard

The HazeTints to apply to the blurred content.

Link copied to clipboard

The HazeTint to use when Haze uses the fallback scrim functionality.

Link copied to clipboard
var mask: Brush?

Optional alpha mask which allows effects such as fading via a Brush.verticalGradient or similar. This is only applied when progressive is null.

Link copied to clipboard

Amount of noise applied to the content, in the range 0f to 1f. Anything outside of that range will be clamped.

Link copied to clipboard

Parameters for enabling a progressive (or gradient) blur effect, or null for a uniform blurring effect. Defaults to null.

Link copied to clipboard

Style set on this specific blur effect.

Functions

Link copied to clipboard
open override fun attach(context: VisualEffectContext)
Link copied to clipboard
Link copied to clipboard
open override fun calculateLayerBounds(rect: Rect, density: Density): Rect
Link copied to clipboard
open override fun detach()
Link copied to clipboard
open override fun DrawScope.draw(context: VisualEffectContext)
Link copied to clipboard
open override fun onTrimMemory(context: VisualEffectContext, level: TrimMemoryLevel)
Link copied to clipboard
open override fun preferClipToAreaBounds(): Boolean
Link copied to clipboard
open override fun requireInvalidation(): Boolean
Link copied to clipboard
open override fun shouldClip(): Boolean
Link copied to clipboard
Link copied to clipboard
open override fun update(context: VisualEffectContext)