### Install Android Sample on Device Source: https://github.com/chrisbanes/haze/blob/main/AGENTS.md Load the Android sample application onto a connected device. ```bash ./gradlew :sample:android:installDebug ``` -------------------------------- ### HazeEffectScope Configuration Example Source: https://github.com/chrisbanes/haze/blob/main/docs/architecture.md Demonstrates configuring common properties within the HazeEffectScope lambda for a haze effect. ```kotlin modifier = Modifier.hazeEffect(state) { inputScale = HazeInputScale.Auto drawContentBehind = true // Effect-specific configuration } ``` -------------------------------- ### Foreground Blurring: v1 Example Source: https://github.com/chrisbanes/haze/blob/main/docs/migrating-2.0.md Example of applying foreground blurring using Haze v1's `hazeEffect` modifier. ```kotlin Modifier.hazeEffect { colorEffects = listOf(HazeColorEffect.tint(Color.Black.copy(alpha = 0.5f))) progressive = HazeProgressive.verticalGradient(...) } ``` -------------------------------- ### Blur Effect Registration Example Source: https://github.com/chrisbanes/haze/blob/main/docs/architecture.md Shows how to register and configure the blur effect using builder extension functions on HazeEffectScope. ```kotlin // Blur effect example modifier = Modifier.hazeEffect(state) { blurEffect { style = HazeMaterials.thin() progressive = HazeProgressive.verticalGradient(...) } } ``` -------------------------------- ### Foreground Blurring: v2 Example Source: https://github.com/chrisbanes/haze/blob/main/docs/migrating-2.0.md Example of applying foreground blurring using Haze v2's `hazeEffect` modifier with the new `blurEffect` block. ```kotlin Modifier.hazeEffect { blurEffect { colorEffects = listOf(HazeColorEffect.tint(Color.Black.copy(alpha = 0.5f))) progressive = HazeProgressive.verticalGradient(...) } } ``` -------------------------------- ### Background Source Layers Example Source: https://github.com/chrisbanes/haze/blob/main/docs/custom-effects.md Demonstrates setting up multiple transformed background layers using hazeSource and applying a custom hazeEffect. Ensure a shared HazeState is used for synchronization. ```kotlin val hazeState = rememberHazeState() Box(Modifier.fillMaxSize()) { AsyncImage( model = rememberRandomSampleImageUrl(), contentDescription = null, modifier = Modifier .fillMaxSize() .graphicsLayer { scaleX = 1.06f translationX = 24f } .hazeSource(state = hazeState) ) Box( modifier = Modifier .size(260.dp, 180.dp) .graphicsLayer { rotationZ = 10f } .hazeSource(state = hazeState, zIndex = 1f) ) Box( modifier = Modifier .align(Alignment.Center) .hazeEffect(state = hazeState) { sparkEffect { } } ) } ``` -------------------------------- ### Force Screen Coordinates for Position Strategy Source: https://github.com/chrisbanes/haze/blob/main/docs/migrating-2.0.md Use `HazePositionStrategy.Screen` when initializing `rememberHazeState` if you need to force screen coordinates, for example, in custom cross-window setups. ```kotlin val state = rememberHazeState(positionStrategy = HazePositionStrategy.Screen) ``` -------------------------------- ### Background Effect Example Source: https://github.com/chrisbanes/haze/blob/main/docs/core-concepts.md Apply a background blur effect by combining Modifier.hazeSource on the content to be blurred and Modifier.hazeEffect on the overlaying element. This is the most common usage pattern. ```kotlin Box { LazyColumn( modifier = Modifier.hazeSource(state = hazeState) ) { // content } TopAppBar( modifier = Modifier.hazeEffect(state = hazeState) { blurEffect { /* ... */ } } ) } ``` -------------------------------- ### Linear Gradient Blur Options Source: https://github.com/chrisbanes/haze/blob/main/docs/blur/usage.md Provides options for creating linear progressive blurs, including vertical and horizontal gradients with adjustable start and end intensities. ```kotlin progressive = HazeProgressive.verticalGradient( startIntensity = 1f, endIntensity = 0f ) // or horizontal progressive = HazeProgressive.horizontalGradient( startIntensity = 1f, endIntensity = 0f ) ``` -------------------------------- ### Force Screen Haze Position Strategy Source: https://github.com/chrisbanes/haze/blob/main/docs/core-concepts.md Manually override the position strategy to force screen-level coordinates, suitable for cross-window setups like dialogs. ```kotlin val hazeState = rememberHazeState(positionStrategy = HazePositionStrategy.Screen) ``` -------------------------------- ### Foreground Effect Example Source: https://github.com/chrisbanes/haze/blob/main/docs/core-concepts.md Apply a foreground blur effect by using only Modifier.hazeEffect on a composable. This blurs the content within the composable itself, without needing a separate hazeSource. ```kotlin Box( modifier = Modifier.hazeEffect { blurEffect { /* ... */ } } ) { // This content will be blurred } ``` -------------------------------- ### Builder Extension for Custom Effect Source: https://github.com/chrisbanes/haze/blob/main/docs/custom-effects.md An example of a builder extension function to expose a custom visual effect (SparkVisualEffect) within the HazeEffectScope. This pattern simplifies the creation and configuration of custom effects. ```kotlin @OptIn(ExperimentalHazeApi::class) fun HazeEffectScope.sparkEffect( block: SparkVisualEffect.() -> Unit, ) { val effect = visualEffect as? SparkVisualEffect ?: SparkVisualEffect() visualEffect = effect effect.block() } ``` -------------------------------- ### Applying Liquid Glass Effect to a Box Source: https://github.com/chrisbanes/haze/blob/main/docs/effects/liquid-glass.md Apply the liquid glass effect to a Box composable using the hazeEffect modifier. This example demonstrates setting various parameters for the liquid glass effect. ```kotlin Box( Modifier .size(180.dp) .clip(RoundedCornerShape(20.dp)) .hazeEffect(state = hazeState) { liquidGlassEffect { tint = Color.White.copy(alpha = 0.16f) refractionStrength = 0.8f refractionHeight = 0.32f depth = 0.5f specularIntensity = 0.7f ambientResponse = 0.7f edgeSoftness = 14.dp shape = RoundedCornerShape(20.dp) surfaceProfile = SurfaceProfile.Squircle chromaticAberrationStrength = 0.2f } } ) ``` -------------------------------- ### Run Desktop Sample Source: https://github.com/chrisbanes/haze/blob/main/AGENTS.md Execute the desktop demo application. ```bash ./gradlew :sample:desktop:run ``` -------------------------------- ### Build Full Multi-Platform Artifacts Source: https://github.com/chrisbanes/haze/blob/main/AGENTS.md Run a comprehensive build and verification process for all platforms. ```bash ./gradlew build ``` -------------------------------- ### Filtering Areas in Haze Blur Source: https://github.com/chrisbanes/haze/blob/main/docs/blur/usage.md Control which layers are included in the Haze blur effect using the `canDrawArea` filter. This example excludes the source itself from being blurred. ```kotlin CreditCard( modifier = Modifier .hazeSource(hazeState, zIndex = 2f, key = "foo") .hazeEffect(hazeState) { canDrawArea = { area -> area.key != "foo" // Exclude self } }, ) ``` -------------------------------- ### Apply Code Formatting Source: https://github.com/chrisbanes/haze/blob/main/AGENTS.md Enforce code formatting standards using Spotless and ktlint before committing. ```bash ./gradlew spotlessApply ``` -------------------------------- ### Build Library Artifacts and Run Tests Source: https://github.com/chrisbanes/haze/blob/main/AGENTS.md Execute targeted development builds for library artifacts and their unit tests. ```bash ./gradlew assembleDebug testDebug ``` -------------------------------- ### Run Screenshot Test Suite Source: https://github.com/chrisbanes/haze/blob/main/AGENTS.md Execute the visual verification suite for screenshot tests. ```bash ./gradlew :haze-screenshot-tests:test ``` -------------------------------- ### Basic Blur Effect Usage Source: https://github.com/chrisbanes/haze/blob/main/docs/blur/index.md Apply the blur effect to a composable using Modifier.hazeEffect. This example shows blurring a TopAppBar over scrollable content in a LazyColumn. ```kotlin val hazeState = rememberHazeState() Box { LazyColumn( modifier = Modifier .fillMaxSize() .hazeSource(state = hazeState) ) { // scrollable content } TopAppBar( modifier = Modifier .hazeEffect(state = hazeState) { blurEffect { style = HazeMaterials.thin() } } ) } ``` -------------------------------- ### Run All Local Checks Source: https://github.com/chrisbanes/haze/blob/main/AGENTS.md Execute all local checks, including unit tests and code style, before opening a PR. ```bash ./gradlew check ``` -------------------------------- ### VisualEffect Update with Local State Source: https://github.com/chrisbanes/haze/blob/main/docs/custom-effects.md Example of updating the VisualEffect's state based on a CompositionLocal. It reads a color from LocalSparkColor and invalidates the draw if the color changes. ```kotlin override fun update(context: VisualEffectContext) { val newColor = context.currentValueOf(LocalSparkColor) if (newColor != color) { color = newColor context.invalidateDraw() } } ``` -------------------------------- ### Configure Maven Repositories for Snapshots Source: https://github.com/chrisbanes/haze/blob/main/docs/using-snapshot-version.md Add the Sonatype snapshot repository to your project's repositories block to enable fetching snapshot versions. ```kotlin repositories { // ... maven("https://central.sonatype.com/repository/maven-snapshots") } ``` -------------------------------- ### Applying Vertical Gradient Blur Source: https://github.com/chrisbanes/haze/blob/main/docs/blur/usage.md Enables a progressive blur effect that varies vertically using a gradient from full intensity at the start to zero intensity at the end. ```kotlin TopAppBar( modifier = Modifier.hazeEffect(hazeState) { blurEffect { progressive = HazeProgressive.verticalGradient( startIntensity = 1f, endIntensity = 0f ) } } ) ``` -------------------------------- ### Platform-Specific Shader Creation (Desktop/Skiko) Source: https://github.com/chrisbanes/haze/blob/main/docs/custom-effects.md The 'actual' implementation of createPlatformShader for Desktop (Skiko). This provides the platform-specific code for creating a shader. ```kotlin // desktopMain / skikoMain actual fun createPlatformShader(size: Size): Shader { // Desktop implementation } ``` -------------------------------- ### Apply Fluent Blur Effect Source: https://github.com/chrisbanes/haze/blob/main/docs/blur/materials.md Apply blur styles matching Windows platforms using FluentMaterials.thin(). ```kotlin blurEffect { style = FluentMaterials.thin() } ``` -------------------------------- ### Record Roborazzi Snapshots Source: https://github.com/chrisbanes/haze/blob/main/AGENTS.md Regenerate UI snapshots using Roborazzi when intentional visual changes occur. ```bash ./gradlew :haze-screenshot-tests:recordRoborazzi ``` -------------------------------- ### Override calculateLayerBounds for Extra Sampling Space Source: https://github.com/chrisbanes/haze/blob/main/docs/custom-effects.md Example of overriding the calculateLayerBounds function to provide additional sampling space for an effect. This is useful when an effect needs to read pixels beyond its immediate bounds. ```kotlin override fun calculateLayerBounds(rect: Rect, density: Density): Rect { val extra = with(density) { 24.dp.toPx() } return rect.inflate(extra) } ``` -------------------------------- ### createRuntimeEffect Source: https://github.com/chrisbanes/haze/blob/main/haze-utils/api/2.0.0-alpha01.txt Creates a PlatformRuntimeEffect from a Skia Shading Language (SL) string. ```APIDOC ## createRuntimeEffect ### Description Creates a PlatformRuntimeEffect from a Skia Shading Language (SL) string. ### Method static ### Endpoint N/A (SDK Method) ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body N/A ### Request Example N/A ### Response #### Success Response - **dev.chrisbanes.haze.PlatformRuntimeEffect** - The created PlatformRuntimeEffect. #### Response Example N/A ``` -------------------------------- ### HazeColorEffect.Companion Source: https://github.com/chrisbanes/haze/blob/main/haze-blur/api/api.txt Factory methods for creating HazeColorEffects. ```APIDOC ## HazeColorEffect.Companion ### Description Companion object for `HazeColorEffect` providing factory methods to create different types of color effects. ### Methods - `colorFilter(ColorFilter colorFilter, optional int blendMode)`: Creates a `HazeColorEffect.ColorFilter`. - `tint(Brush brush, optional int blendMode)`: Creates a `HazeColorEffect.TintBrush`. - `tint(long color, optional int blendMode)`: Creates a `HazeColorEffect.TintColor`. ### Properties - `DefaultBlendMode` (androidx.compose.ui.graphics.BlendMode): The default blend mode. ``` -------------------------------- ### FluentMaterials Source: https://github.com/chrisbanes/haze/blob/main/haze-materials/api/api.txt Provides blur styles inspired by Fluent design. ```APIDOC ## FluentMaterials ### Description Provides blur styles inspired by Fluent design. ### Methods - **accentAcrylicBase(optional long accentColor, optional boolean isDark)**: Applies an accent acrylic base blur. - **accentAcrylicDefault(optional long accentColor, optional boolean isDark)**: Applies a default accent acrylic blur. - **acrylicBase(optional boolean isDark)**: Applies a base acrylic blur. - **acrylicDefault(optional boolean isDark)**: Applies a default acrylic blur. - **mica(optional boolean isDark)**: Applies a mica blur. - **micaAlt(optional boolean isDark)**: Applies an alternative mica blur. - **thinAcrylic(optional boolean isDark)**: Applies a thin acrylic blur. ``` -------------------------------- ### Add Snapshot Dependencies for Haze Source: https://github.com/chrisbanes/haze/blob/main/docs/using-snapshot-version.md Include snapshot versions of the Haze core and blur modules in your project's dependencies. Replace 'XXX' with the latest version number. ```kotlin dependencies { // Check the latest SNAPSHOT version from the link above // Core infrastructure (required) implementation("dev.chrisbanes.haze:haze:XXX-SNAPSHOT") // For blur effects (most users will need this) implementation("dev.chrisbanes.haze:haze-blur:XXX-SNAPSHOT") } ``` -------------------------------- ### Apply Haze Effect to Dialogs Source: https://github.com/chrisbanes/haze/blob/main/docs/core-concepts.md Mark the effect source before showing the dialog and apply the haze effect to the dialog's surface. ```kotlin val hazeState = rememberHazeState() var showDialog by remember { mutableStateOf(false) } Box { LazyColumn( modifier = Modifier.hazeSource(state = hazeState) ) { // background content } if (showDialog) { Dialog(onDismissRequest = { showDialog = false }) { Surface( modifier = Modifier.hazeEffect(state = hazeState) { blurEffect { /* ... */ } } ) { // dialog content } } } } ``` -------------------------------- ### HazeState Configuration Source: https://github.com/chrisbanes/haze/blob/main/haze/api/api.txt Provides methods to configure various aspects of the Haze effect, such as drawing areas, clipping bounds, and visual effects. ```APIDOC ## HazeState Properties and Methods ### Description Allows direct configuration of Haze behavior through properties and methods. ### Methods - `getCanDrawArea()`: Boolean? - Returns whether drawing is restricted to a specific area. - `getClipToAreasBounds()`: Boolean? - Returns whether drawing is clipped to the bounds of defined areas. - `getDrawContentBehind()`: Boolean - Returns whether content behind the Haze effect is drawn. - `getExpandLayerBounds()`: Boolean? - Returns whether the layer bounds are expanded. - `getForceInvalidateOnPreDraw()`: Boolean - Returns whether invalidation is forced before drawing. - `getInputScale()`: HazeInputScale - Returns the input scale strategy. - `getVisualEffect()`: VisualEffect - Returns the current visual effect. - `setCanDrawArea(Function1?)`: Sets the area restriction for drawing. - `setClipToAreasBounds(Boolean?)`: Sets whether to clip drawing to area bounds. - `setDrawContentBehind(Boolean)`: Sets whether to draw content behind the effect. - `setExpandLayerBounds(Boolean?)`: Sets whether to expand layer bounds. - `setForceInvalidateOnPreDraw(Boolean)`: Sets whether to force invalidation before drawing. - `setInputScale(HazeInputScale)`: Sets the input scale strategy. - `setVisualEffect(VisualEffect)`: Sets the visual effect. ### Properties - `canDrawArea`: Function1? - Controls drawing restrictions to a specific area. - `clipToAreasBounds`: Boolean? - Determines if drawing is clipped to the bounds of defined areas. - `drawContentBehind`: Boolean - Controls whether content behind the Haze effect is drawn. - `expandLayerBounds`: Boolean? - Controls the expansion of layer bounds. - `forceInvalidateOnPreDraw`: Boolean - Forces invalidation before each draw pass. - `inputScale`: HazeInputScale - Defines the strategy for scaling input. - `visualEffect`: VisualEffect - Specifies the visual effect to be applied. ``` -------------------------------- ### Platform Callback Registration (commonMain) Source: https://github.com/chrisbanes/haze/blob/main/docs/specs/2026-04-24-issue-891-trimmemory-design.md An internal expect/actual helper to register/unregister system trim-memory callbacks for the HazeEffectNode lifecycle. On non-Android platforms, the actual implementation is a no-op. ```kotlin // commonMain internal expect fun registerTrimMemoryCallback( context: PlatformContext, callback: (TrimMemoryLevel) -> Unit, ): Cancellable ``` -------------------------------- ### Platform-Specific Shader Creation (Common) Source: https://github.com/chrisbanes/haze/blob/main/docs/custom-effects.md The 'expect' declaration for creating a platform-specific shader. This defines the contract that must be implemented by each platform. ```kotlin // commonMain expect fun createPlatformShader(size: Size): Shader ``` -------------------------------- ### CupertinoMaterials Source: https://github.com/chrisbanes/haze/blob/main/haze-materials/api/api.txt Provides blur styles inspired by Cupertino design. ```APIDOC ## CupertinoMaterials ### Description Provides blur styles inspired by Cupertino design. ### Methods - **regular(optional long containerColor)**: Applies a regular blur. - **thick(optional long containerColor)**: Applies a thick blur. - **thin(optional long containerColor)**: Applies a thin blur. - **ultraThin(optional long containerColor)**: Applies an ultra-thin blur. ``` -------------------------------- ### ShaderEffect Implementation Source: https://github.com/chrisbanes/haze/blob/main/docs/custom-effects.md A sample VisualEffect implementation that uses a platform-specific shader. It demonstrates the use of 'expect'/'actual' for cross-platform compatibility and the attach lifecycle method. ```kotlin @OptIn(ExperimentalHazeApi::class) class ShaderEffect : VisualEffect { private lateinit var shader: Shader override fun attach(context: VisualEffectContext) { shader = createPlatformShader(context.size) } } ``` -------------------------------- ### Add Haze Dependencies Source: https://github.com/chrisbanes/haze/blob/main/README.md Include the necessary Haze libraries in your project's dependencies to enable visual effects. ```kotlin dependencies { implementation("dev.chrisbanes.haze:haze:") implementation("dev.chrisbanes.haze:haze-blur:") implementation("dev.chrisbanes.haze:haze-materials:") } ``` -------------------------------- ### Basic Blur Configuration v1 vs v2 Source: https://github.com/chrisbanes/haze/blob/main/docs/migrating-2.0.md In v2, blur properties like `blurRadius`, `colorEffects`, and `noiseFactor` must be wrapped within a `blurEffect {}` block inside `hazeEffect`. ```kotlin Modifier.hazeEffect(state = hazeState) { blurRadius = 20.dp colorEffects = listOf(HazeColorEffect.tint(Color.Black.copy(alpha = 0.7f))) noiseFactor = 0.15f } ``` ```kotlin Modifier.hazeEffect(state = hazeState) { blurEffect { // NEW: wrap blur properties blurRadius = 20.dp colorEffects = listOf(HazeColorEffect.tint(Color.Black.copy(alpha = 0.7f))) noiseFactor = 0.15f } } ``` -------------------------------- ### Implement Custom Visual Effect Source: https://github.com/chrisbanes/haze/blob/main/docs/architecture.md Implement the VisualEffect interface to define custom rendering logic. Provide a builder extension for easy integration into the Haze effect scope. ```kotlin class CustomVisualEffect : VisualEffect { override fun attach(context: VisualEffectContext) { // Initialize resources } override fun update(context: VisualEffectContext) { // Update state from composition locals or snapshot state } override fun detach(context: VisualEffectContext) { // Clean up resources } override fun DrawScope.draw(context: VisualEffectContext) { // Render the effect using the DrawScope receiver } } // Provide a builder extension fun HazeEffectScope.customEffect(block: CustomVisualEffect.() -> Unit = {}) { visualEffect = CustomVisualEffect().apply(block) } ``` -------------------------------- ### Update Blur Imports for v2 Source: https://github.com/chrisbanes/haze/blob/main/docs/migrating-2.0.md Blur-related classes have moved to the `dev.chrisbanes.haze.blur` package in v2. Note the new `blurEffect` extension function. ```kotlin import dev.chrisbanes.haze.blur.HazeBlurStyle import dev.chrisbanes.haze.blur.HazeColorEffect import dev.chrisbanes.haze.blur.HazeProgressive import dev.chrisbanes.haze.blur.LocalHazeBlurStyle import dev.chrisbanes.haze.blur.blurEffect // NEW: extension function ``` -------------------------------- ### Background Blurring with HazeState Source: https://github.com/chrisbanes/haze/blob/main/docs/blur/usage.md Demonstrates background blurring by applying a haze effect to a TopAppBar, which blurs content from a scrollable LazyColumn marked with hazeSource. Requires a HazeState. ```kotlin val hazeState = rememberHazeState() Box { LazyColumn( modifier = Modifier .fillMaxSize() .hazeSource(state = hazeState) ) { // scrollable content } TopAppBar( modifier = Modifier .hazeEffect(state = hazeState) { blurEffect { style = HazeMaterials.thin() } } .fillMaxWidth() ) } ``` -------------------------------- ### VisualEffectContext Interface Source: https://github.com/chrisbanes/haze/blob/main/docs/custom-effects.md Provides geometry, environment, and lifecycle helpers for visual effects. It offers access to size, position, scale, and other contextual information. ```kotlin interface VisualEffectContext { val position: Offset val size: Size val layerSize: Size val layerOffset: Offset val rootBounds: Rect val inputScale: HazeInputScale val windowId: Any? val areas: List val state: HazeState? val coroutineScope: CoroutineScope fun requireDensity(): Density fun currentValueOf(local: CompositionLocal): T fun requireGraphicsContext(): GraphicsContext fun invalidateDraw() } ``` -------------------------------- ### HazeBlurStyleKt Source: https://github.com/chrisbanes/haze/blob/main/haze-blur/api/api.txt Utility functions and local composition locals for HazeBlurStyle. ```APIDOC ## HazeBlurStyleKt ### Description Provides utility functions and local composition locals for HazeBlurStyle, including deprecated methods for creating HazeTint effects. ### Methods - `getLocalHazeBlurStyle()`: Returns the local composition local for HazeBlurStyle. - `getLocalHazeStyle()`: Returns the deprecated local composition local for HazeStyle. - `@Deprecated HazeTint(Brush brush, optional int blendMode)`: Deprecated method to create a HazeColorEffect from a Brush. - `@Deprecated HazeTint(long color, optional int blendMode)`: Deprecated method to create a HazeColorEffect from a color. ### Properties - `LocalHazeBlurStyle`: The local composition local for HazeBlurStyle. - `@Deprecated LocalHazeStyle`: The deprecated local composition local for HazeStyle. ``` -------------------------------- ### Platform Callback Registration (androidMain) Source: https://github.com/chrisbanes/haze/blob/main/docs/specs/2026-04-24-issue-891-trimmemory-design.md The actual implementation for registering trim memory callbacks on Android. It uses ComponentCallbacks2 to listen for trim memory events and low memory conditions. ```kotlin // androidMain internal actual fun registerTrimMemoryCallback(...): Cancellable = context.registerComponentCallbacks(object : ComponentCallbacks2 { override fun onTrimMemory(level: Int) { callback(level.toTrimMemoryLevel()) } override fun onConfigurationChanged(newConfig: Configuration) = Unit override fun onLowMemory() = callback(TrimMemoryLevel.COMPLETE) }) ``` -------------------------------- ### RenderEffect_skikoKt.createRuntimeShaderRenderEffect Source: https://github.com/chrisbanes/haze/blob/main/haze-utils/api/api.txt Creates a RenderEffect from a PlatformRuntimeEffect. ```APIDOC ## RenderEffect_skikoKt.createRuntimeShaderRenderEffect ### Description Creates a RenderEffect from a PlatformRuntimeEffect, specifying shader names, inputs, and uniforms. ### Method public static android.graphics.RenderEffect createRuntimeShaderRenderEffect(dev.chrisbanes.haze.PlatformRuntimeEffect effect, String[] shaderNames, android.graphics.RenderEffect?[] inputs, optional kotlin.jvm.functions.Function1 uniforms) ### Parameters * **effect** (dev.chrisbanes.haze.PlatformRuntimeEffect) - The runtime effect to use. * **shaderNames** (String[]) - An array of shader names. * **inputs** (android.graphics.RenderEffect?[]) - An array of input RenderEffects. * **uniforms** (optional kotlin.jvm.functions.Function1) - An optional lambda to configure uniforms. ``` -------------------------------- ### Apply Cupertino Blur Effect Source: https://github.com/chrisbanes/haze/blob/main/docs/blur/materials.md Apply blur styles matching Apple platforms using CupertinoMaterials.thin(). ```kotlin blurEffect { style = CupertinoMaterials.thin() } ``` -------------------------------- ### HazeProgressive.Companion.forShader Source: https://github.com/chrisbanes/haze/blob/main/haze-blur/api/api.txt Creates a shader for HazeProgressive effects. It takes a block that generates a Shader based on the provided Size. ```APIDOC ## HazeProgressive.Companion.forShader ### Description Creates a shader for HazeProgressive effects. It takes a block that generates a Shader based on the provided Size. ### Method `fun forShader(block: (Size) -> Shader): Brush` ### Parameters #### Block Parameter - **block** (Function1) - A lambda function that returns a Shader based on the Size. ### Returns - `Brush` - A Brush object representing the shader. ### Endpoint N/A (This is an SDK method call) ``` -------------------------------- ### PlatformRuntimeEffect Constructor Source: https://github.com/chrisbanes/haze/blob/main/haze-utils/api/2.0.0-alpha01.txt Creates a PlatformRuntimeEffect from a SkSL string. ```APIDOC ## PlatformRuntimeEffect Constructor ### Description Creates a PlatformRuntimeEffect from a SkSL string. This class is marked with `@InternalHazeApi`. ### Method `public PlatformRuntimeEffect(String sksl)` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```kotlin val runtimeEffect = dev.chrisbanes.haze.PlatformRuntimeEffect("your_sksl_code") ``` ### Response #### Success Response - `PlatformRuntimeEffect` (dev.chrisbanes.haze.PlatformRuntimeEffect) - The created PlatformRuntimeEffect instance. #### Response Example ```json { "example": "platformRuntimeEffectInstance" } ``` ``` -------------------------------- ### Default Haze Position Strategy Source: https://github.com/chrisbanes/haze/blob/main/docs/core-concepts.md Uses the default Auto strategy for HazeState, which automatically adapts to most scenarios. ```kotlin val hazeState = rememberHazeState() // Auto strategy (default) ``` -------------------------------- ### HazeMaterials Source: https://github.com/chrisbanes/haze/blob/main/haze-materials/api/api.txt Provides standard Haze blur styles. ```APIDOC ## HazeMaterials ### Description Provides standard Haze blur styles. ### Methods - **regular(optional long containerColor)**: Applies a regular blur. - **thick(optional long containerColor)**: Applies a thick blur. - **thin(optional long containerColor)**: Applies a thin blur. - **ultraThick(optional long containerColor)**: Applies an ultra-thick blur. - **ultraThin(optional long containerColor)**: Applies an ultra-thin blur. ``` -------------------------------- ### Add Haze Dependencies Source: https://github.com/chrisbanes/haze/blob/main/docs/index.md Include the Haze library and its blur effect module in your project's build.gradle file. Ensure you have mavenCentral() configured in your repositories. ```kotlin repositories { mavenCentral() } dependencies { // Core library. Usually don't need this... implementation("dev.chrisbanes.haze:haze:") // For blur effects: implementation("dev.chrisbanes.haze:haze-blur:") } ``` -------------------------------- ### HazeBlurStyle Companion Source: https://github.com/chrisbanes/haze/blob/main/haze-blur/api/api.txt Provides access to unspecified HazeBlurStyle and a companion object. ```APIDOC ## HazeBlurStyle.Companion ### Description Provides access to the `Unspecified` HazeBlurStyle and a companion object for HazeBlurStyle. ### Methods - `getUnspecified()`: Returns the unspecified HazeBlurStyle. ### Properties - `Unspecified`: The unspecified HazeBlurStyle. ``` -------------------------------- ### Platform-Specific Shader Creation (Android) Source: https://github.com/chrisbanes/haze/blob/main/docs/custom-effects.md The 'actual' implementation of createPlatformShader for Android. This provides the platform-specific code for creating a shader. ```kotlin // androidMain actual fun createPlatformShader(size: Size): Shader { // Android implementation } ``` -------------------------------- ### Android Screenshot Testing with Robolectric Source: https://github.com/chrisbanes/haze/blob/main/docs/core-concepts.md Configure Robolectric tests to use SDK 35+ for correct blur effect rendering at effect edges. ```kotlin @Config(sdk = [35]) class MyScreenshotTest { // tests } ``` -------------------------------- ### Share HazeState via CompositionLocal Source: https://github.com/chrisbanes/haze/blob/main/docs/core-concepts.md For deep UI hierarchies, use a CompositionLocal to provide HazeState. Define a LocalHazeState and provide the rememberHazeState() instance using CompositionLocalProvider. ```kotlin val LocalHazeState = compositionLocalOf { HazeState() } @Composable fun HazeExample() { val hazeState = rememberHazeState() CompositionLocalProvider(LocalHazeState provides hazeState) { Box { Background() Foreground() } } } @Composable fun Foreground() { Text( modifier = Modifier.hazeEffect(state = LocalHazeState.current) { blurEffect { /* ... */ } } ) } ``` -------------------------------- ### Haze Blur Dependencies Source: https://github.com/chrisbanes/haze/blob/main/docs/blur/index.md Add the core Haze library and the blur effect module to your project's dependencies. Use the latest version available. ```kotlin repositories { mavenCentral() } dependencies { // Core library infrastructure implementation("dev.chrisbanes.haze:haze:") // Blur effect implementation("dev.chrisbanes.haze:haze-blur:") // Optional: Pre-built blur styles implementation("dev.chrisbanes.haze:haze-materials:") } ``` -------------------------------- ### Fetch GitHub Releases for Changelog Source: https://github.com/chrisbanes/haze/blob/main/AGENTS.md Retrieve release information from the GitHub API to maintain the CHANGELOG.md. ```bash curl -s "https://api.github.com/repos/chrisbanes/haze/releases?per_page=100" ``` -------------------------------- ### Create HazeState Source: https://github.com/chrisbanes/haze/blob/main/docs/core-concepts.md Initialize a HazeState instance using rememberHazeState(). This state is shared between hazeSource and hazeEffect modifiers. ```kotlin val hazeState = rememberHazeState() ``` -------------------------------- ### requirePlatformContext Source: https://github.com/chrisbanes/haze/blob/main/haze-utils/api/2.0.0-alpha02.txt Retrieves the platform-specific context required for certain Haze operations. This is an internal API and should not be used directly. ```APIDOC ## requirePlatformContext ### Description This function retrieves the platform-specific context needed for Haze operations. It is marked as an internal API and is intended for use within the Haze library itself. ### Method Signature `@dev.chrisbanes.haze.InternalHazeApi public static dev.chrisbanes.haze.PlatformContext requirePlatformContext(androidx.compose.ui.node.CompositionLocalConsumerModifierNode)` ### Parameters - `node` (androidx.compose.ui.node.CompositionLocalConsumerModifierNode) - The composition local consumer modifier node. ``` -------------------------------- ### Setting a Custom LiquidGlassStyle Source: https://github.com/chrisbanes/haze/blob/main/docs/effects/liquid-glass.md Define a custom LiquidGlassStyle to set baseline parameters for multiple liquid glass effects. These styles are provided via CompositionLocalProvider. ```kotlin val myStyle = LiquidGlassStyle( tint = Color.White.copy(alpha = 0.16f), refractionStrength = 0.8f, shape = RoundedCornerShape(20.dp), ) CompositionLocalProvider(LocalLiquidGlassStyle provides myStyle) { // All liquid glass effects in this scope will use myStyle as their baseline } ``` -------------------------------- ### Foreground Blurring without HazeState Source: https://github.com/chrisbanes/haze/blob/main/docs/blur/usage.md Shows how to apply a blur effect directly to a composable for foreground blurring. This method does not require a HazeState or hazeSource. ```kotlin @Composable fun HazeExample(modifier: Modifier = Modifier) { Box(modifier = modifier) { Foreground( modifier = Modifier .hazeEffect { blurEffect { style = HazeMaterials.thin() } } .fillMaxSize() ) } } ``` -------------------------------- ### Scaffold with Haze Effects Source: https://github.com/chrisbanes/haze/blob/main/docs/recipes.md Applies Haze blur effects to the TopAppBar and NavigationBar of a Scaffold, while the content behind is blurred using hazeSource. ```kotlin val hazeState = rememberHazeState() Scaffold( topBar = { TopAppBar( // Need to make app bar transparent to see the content behind colors = TopAppBarDefaults.largeTopAppBarColors(Color.Transparent), modifier = Modifier .hazeEffect(state = hazeState) { blurEffect { style = HazeMaterials.thin() } } .fillMaxWidth(), ) { /* todo */ } }, bottomBar = { NavigationBar( containerColor = Color.Transparent, modifier = Modifier .hazeEffect(state = hazeState) { blurEffect { style = HazeMaterials.thin() } } .fillMaxWidth(), ) { /* todo */ } }, ) { LazyVerticalGrid( modifier = Modifier .hazeSource( state = hazeState, ), ) { // todo } } ``` -------------------------------- ### requirePlatformContext Source: https://github.com/chrisbanes/haze/blob/main/haze-utils/api/2.0.0-alpha01.txt Retrieves the platform-specific context required for Haze operations. ```APIDOC ## requirePlatformContext ### Description Retrieves the platform-specific context required for Haze operations. This function is marked with `@InternalHazeApi` and should generally not be used outside of the Haze library. ### Method `static dev.chrisbanes.haze.PlatformContext requirePlatformContext(androidx.compose.ui.node.CompositionLocalConsumerModifierNode)` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```kotlin val context = dev.chrisbanes.haze.PlatformContextKt.requirePlatformContext(modifierNode) ``` ### Response #### Success Response - `PlatformContext` (dev.chrisbanes.haze.PlatformContext) - The platform-specific context. #### Response Example ```json { "example": "platformContextInstance" } ``` ``` -------------------------------- ### Create Custom Blur Style with HazeBlurStyle Source: https://github.com/chrisbanes/haze/blob/main/docs/blur/materials.md Define a custom blur style using the HazeBlurStyle data class with specific blur radius, color effects, and noise factor. ```kotlin val customStyle = HazeBlurStyle( blurRadius = 15.dp, colorEffects = listOf(HazeColorEffect.tint(Color.Black.copy(alpha = 0.2f))), noiseFactor = 0.1f ) blurEffect { style = customStyle } ``` -------------------------------- ### createFractalNoiseShader Source: https://github.com/chrisbanes/haze/blob/main/haze-utils/api/2.0.0-alpha01.txt Creates a Shader that generates fractal noise. ```APIDOC ## createFractalNoiseShader ### Description Creates a Shader that generates fractal noise. ### Method static ### Endpoint N/A (SDK Method) ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body N/A ### Request Example N/A ### Response #### Success Response - **androidx.compose.ui.graphics.Shader** - The created fractal noise Shader. #### Response Example N/A ``` -------------------------------- ### Force Local Haze Position Strategy Source: https://github.com/chrisbanes/haze/blob/main/docs/core-concepts.md Manually override the position strategy to force root-relative coordinates, suitable for same-window scenarios. ```kotlin val hazeState = rememberHazeState(positionStrategy = HazePositionStrategy.Local) ``` -------------------------------- ### RuntimeShader_androidKt.createRuntimeEffect Source: https://github.com/chrisbanes/haze/blob/main/haze-utils/api/api.txt Creates a PlatformRuntimeEffect from SkSL code. ```APIDOC ## RuntimeShader_androidKt.createRuntimeEffect ### Description Creates a PlatformRuntimeEffect from SkSL shader code. ### Method public static dev.chrisbanes.haze.PlatformRuntimeEffect createRuntimeEffect(String sksl) ### Parameters * **sksl** (String) - The SkSL code for the runtime effect. ``` -------------------------------- ### Usage of Custom Effect Builder Source: https://github.com/chrisbanes/haze/blob/main/docs/custom-effects.md Demonstrates how to use a custom effect builder (sparkEffect) within the hazeEffect modifier. This shows the integration of a custom effect with Haze's state management. ```kotlin Modifier.hazeEffect(state = hazeState) { sparkEffect { color = Color.Blue alpha = 0.3f } } ``` -------------------------------- ### HazeBlendMode Conversions Source: https://github.com/chrisbanes/haze/blob/main/haze-utils/api/2.0.0-alpha01.txt Provides functions to convert between HazeBlendMode and platform-specific blend modes (Android and Skia). ```APIDOC ## toHazeBlendMode ### Description Converts an integer representation to a `HazeBlendMode`. ### Method `static dev.chrisbanes.haze.HazeBlendMode toHazeBlendMode(int)` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Response #### Success Response (200) - **HazeBlendMode** (dev.chrisbanes.haze.HazeBlendMode) - The converted HazeBlendMode. ## toAndroidBlendMode ### Description Converts a `HazeBlendMode` to an Android `android.graphics.BlendMode`. ### Method `static android.graphics.BlendMode toAndroidBlendMode(dev.chrisbanes.haze.HazeBlendMode)` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Response #### Success Response (200) - **BlendMode** (android.graphics.BlendMode) - The converted Android BlendMode. ## toSkiaBlendMode ### Description Converts a `HazeBlendMode` to a Skia `org.jetbrains.skia.BlendMode`. ### Method `static org.jetbrains.skia.BlendMode toSkiaBlendMode(dev.chrisbanes.haze.HazeBlendMode)` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Response #### Success Response (200) - **BlendMode** (org.jetbrains.skia.BlendMode) - The converted Skia BlendMode. ## toPlatformColorFilter (Android) ### Description Converts an `androidx.compose.ui.graphics.ColorFilter` to an Android `android.graphics.ColorFilter`. ### Method `static android.graphics.ColorFilter toPlatformColorFilter(androidx.compose.ui.graphics.ColorFilter)` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Response #### Success Response (200) - **ColorFilter** (android.graphics.ColorFilter) - The converted Android ColorFilter. ## toPlatformColorFilter (Skiko) ### Description Converts an `androidx.compose.ui.graphics.ColorFilter` to a Skiko `android.graphics.ColorFilter`. ### Method `static android.graphics.ColorFilter toPlatformColorFilter(androidx.compose.ui.graphics.ColorFilter)` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Response #### Success Response (200) - **ColorFilter** (android.graphics.ColorFilter) - The converted Skiko ColorFilter. ``` -------------------------------- ### HazeSourceNode Constructor Source: https://github.com/chrisbanes/haze/blob/main/haze/api/api.txt Constructor for creating a HazeSourceNode, which is a Modifier.Node for the Haze effect. ```APIDOC ## HazeSourceNode Constructor ### Description Initializes a HazeSourceNode with the provided state and optional parameters. ### Constructor `HazeSourceNode(HazeState state, Float? zIndex, Any? key)` ### Parameters - `state`: HazeState - The Haze state to associate with this node. - `zIndex`: Float? - Optional z-index for layering. - `key`: Any? - Optional key for identifying the node. ``` -------------------------------- ### Shader_androidKt.createFractalNoiseShader Source: https://github.com/chrisbanes/haze/blob/main/haze-utils/api/api.txt Creates a fractal noise Shader (API Tiramisu+). ```APIDOC ## Shader_androidKt.createFractalNoiseShader ### Description Creates a fractal noise Shader with specified base frequencies, octaves, and seed. Requires API Tiramisu. ### Method @RequiresApi(android.os.Build.VERSION_CODES.TIRAMISU) public static androidx.compose.ui.graphics.Shader createFractalNoiseShader(float baseFrequencyX, float baseFrequencyY, int numOctaves, float seed) ### Parameters * **baseFrequencyX** (float) - The base frequency on the X-axis. * **baseFrequencyY** (float) - The base frequency on the Y-axis. * **numOctaves** (int) - The number of octaves for the noise. * **seed** (float) - The seed for the noise generation. ``` -------------------------------- ### RuntimeShader_androidKt.createRuntimeShaderRenderEffect Source: https://github.com/chrisbanes/haze/blob/main/haze-utils/api/api.txt Creates a RenderEffect from a PlatformRuntimeEffect (API 33+). ```APIDOC ## RuntimeShader_androidKt.createRuntimeShaderRenderEffect ### Description Creates a RenderEffect from a PlatformRuntimeEffect, specifying shader names, inputs, and uniforms. Requires API 33 (TIRAMISU). ### Method @RequiresApi(android.os.Build.VERSION_CODES.TIRAMISU) public static android.graphics.RenderEffect createRuntimeShaderRenderEffect(dev.chrisbanes.haze.PlatformRuntimeEffect effect, String[] shaderNames, android.graphics.RenderEffect?[] inputs, optional kotlin.jvm.functions.Function1 uniforms) ### Parameters * **effect** (dev.chrisbanes.haze.PlatformRuntimeEffect) - The runtime effect to use. * **shaderNames** (String[]) - An array of shader names. * **inputs** (android.graphics.RenderEffect?[]) - An array of input RenderEffects. * **uniforms** (optional kotlin.jvm.functions.Function1) - An optional lambda to configure uniforms. ``` -------------------------------- ### RenderEffect_skikoKt.createRuntimeEffect Source: https://github.com/chrisbanes/haze/blob/main/haze-utils/api/api.txt Creates a PlatformRuntimeEffect from SkSL code. ```APIDOC ## RenderEffect_skikoKt.createRuntimeEffect ### Description Creates a PlatformRuntimeEffect from SkSL shader code. ### Method public static dev.chrisbanes.haze.PlatformRuntimeEffect createRuntimeEffect(String sksl) ### Parameters * **sksl** (String) - The SkSL code for the runtime effect. ``` -------------------------------- ### createBlendRenderEffect Source: https://github.com/chrisbanes/haze/blob/main/haze-utils/api/api.txt Creates a blend RenderEffect for Android. ```APIDOC ## createBlendRenderEffect ### Description Creates a blend `RenderEffect` for Android, combining a background and foreground effect with a specified blend mode. Requires API level 31 and is marked with `@InternalHazeApi`. ### Method `createBlendRenderEffect` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters - `blendMode` (dev.chrisbanes.haze.HazeBlendMode) - Required - The blend mode to use. - `background` (android.graphics.RenderEffect) - Required - The background RenderEffect. - `foreground` (android.graphics.RenderEffect) - Required - The foreground RenderEffect. - `crop` (optional androidx.compose.ui.geometry.Rect?) - Optional - A crop rectangle. ### Returns - `android.graphics.RenderEffect` - The created blend RenderEffect. ### Example ```kotlin val blendEffect = RenderEffect_androidKt.createBlendRenderEffect(HazeBlendMode.Screen, backgroundEffect, foregroundEffect) ``` ``` -------------------------------- ### Input Scale for Haze Blur Performance Source: https://github.com/chrisbanes/haze/blob/main/docs/blur/usage.md Optimize Haze blur performance by rendering the effect at a lower resolution using `HazeInputScale`. Values less than 1.0 improve performance at the cost of quality. ```kotlin TopAppBar( modifier = Modifier.hazeEffect(state = hazeState) { inputScale = HazeInputScale.Auto blurEffect { // ... } } ) ``` -------------------------------- ### createFractalNoiseShader Source: https://github.com/chrisbanes/haze/blob/main/haze-utils/api/2.0.0-alpha02.txt Creates a Shader that generates fractal noise. Available from API level TIRAMISU. ```APIDOC ## createFractalNoiseShader ### Description Creates a Shader that generates fractal noise. Available from API level TIRAMISU. ### Method `@RequiresApi(android.os.Build.VERSION_CODES.TIRAMISU) public static androidx.compose.ui.graphics.Shader createFractalNoiseShader(float baseFrequencyX, float baseFrequencyY, int numOctaves, float seed)` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response (200) - **androidx.compose.ui.graphics.Shader** - The created fractal noise Shader. #### Response Example None ``` -------------------------------- ### HazeColorEffect.TintBrush Source: https://github.com/chrisbanes/haze/blob/main/haze-blur/api/api.txt A HazeColorEffect implementation using a Brush. ```APIDOC ## HazeColorEffect.TintBrush ### Description An immutable implementation of `HazeColorEffect` that uses an Android `Brush`. ### Constructors - `TintBrush(Brush brush, optional BlendMode blendMode)`: Creates a new `TintBrush` effect. ### Methods - `component1()`: Returns the `Brush`. - `copy-GB0RdKg(Brush brush, int blendMode)`: Creates a copy of the `TintBrush` effect with optional updated values. - `getBrush()`: Returns the `Brush`. - `isSpecified()`: Returns true if the brush is specified. ### Properties - `blendMode` (androidx.compose.ui.graphics.BlendMode): The blend mode for the color effect. - `brush` (androidx.compose.ui.graphics.Brush): The Android `Brush`. - `isSpecified` (boolean): Indicates whether the color effect is specified. ``` -------------------------------- ### Sticky Headers with Haze Source: https://github.com/chrisbanes/haze/blob/main/docs/recipes.md Applies Haze blur to sticky headers in a LazyColumn by using hazeEffect on the header and hazeSource on the scrollable content items. ```kotlin val hazeState = rememberHazeState() LazyColumn(...) { stickyHeader { Header( modifier = Modifier .hazeEffect(state = hazeState) { blurEffect { style = HazeMaterials.thin() } }, ) } items(list) { item -> Foo( modifier = Modifier .hazeSource(hazeState), ) } } ``` -------------------------------- ### Blurring Dialog Backgrounds with Haze Source: https://github.com/chrisbanes/haze/blob/main/docs/blur/usage.md Implement blurred backgrounds for dialogs using Haze. Ensure the dialog has a translucent background color instead of relying on tints. ```kotlin val hazeState = rememberHazeState() var showDialog by remember { mutableStateOf(false) } Box { if (showDialog) { Dialog(onDismissRequest = { showDialog = false }) { Surface( modifier = Modifier .fillMaxWidth() .fillMaxHeight(fraction = .5f), shape = MaterialTheme.shapes.extraLarge, // Set translucent background instead of using tints color = MaterialTheme.colorScheme.surface.copy(alpha = 0.2f), ) { Box( Modifier.hazeEffect(state = hazeState) { blurEffect { style = HazeMaterials.regular() } }, ) { // Dialog content } } } } LazyVerticalGrid( modifier = Modifier.hazeSource(state = hazeState), ) { // Background content } } ```