Skip to content
프로젝트

소개

Compose Multiplatform / Jetpack Compose용 배경 흐림 효과

웹 및 앱 개발

이 수치를 측정하는 방법

측정된 스타 증가

in 24h
+3
in 7 days
+14
in 15 days
+24
in 1 month
+50

서로 겹치는 기간의 순증가량이며 일별 합계가 아닙니다. 측정값이 없으면 비워 둡니다. 스타는 관심도를 나타내며 품질을 보장하지 않습니다.

README.md

Original

Haze

Haze

Maven Central Build status

Composable visual effects for Compose Multiplatform.

https://github.com/user-attachments/assets/836dd79a-abdc-4cdc-b27d-baee394c1e26

Haze provides hardware-accelerated visual effects for Compose Multiplatform — Android, iOS, macOS, Desktop, and Web. Its modular Haze 2 API lets you apply source-backed or own-content Blur, refraction-driven Glass, and custom effects with explicit, reusable configuration.

If you are upgrading from Haze 1.x, see the Haze 2 migration guide.

Platforms

Platform Support
Android ✅
Desktop (JVM) ✅
iOS ✅
macOS ✅
Wasm / JS ✅

Modules

Add the core module and only the effect modules you use. Keep every Haze artifact on the same version.

Artifact Purpose
haze Source capture and the typed custom-effect API.
haze-blur Blur for captured sources or a modifier's own content.
haze-blur-materials Optional ready-made Blur Styles, including HazeMaterials.thin().
haze-blur-material3 Optional Compose Material 3 Blur Style factory.
haze-glass Refraction-driven Glass effect.
haze-glass-material3 Optional Compose Material 3 Glass Style factory.

Download

dependencies {
    // Core infrastructure and Blur
    implementation("dev.chrisbanes.haze:haze:<version>")
    implementation("dev.chrisbanes.haze:haze-blur:<version>")

    // Optional: ready-made Blur styles
    implementation("dev.chrisbanes.haze:haze-blur-materials:<version>")
}

For Glass, add the core module and the Glass artifact:

dependencies {
    implementation("dev.chrisbanes.haze:haze:<version>")
    implementation("dev.chrisbanes.haze:haze-glass:<version>")
}

Blur

val hazeState = rememberHazeState()
val style = remember { HazeBlurStyle { blurRadius(20.dp) } }

Box {
    Image(
        painter = painter,
        contentDescription = null,
        modifier = Modifier.hazeSource(hazeState),
    )
    Box(
        modifier = Modifier
            .matchParentSize()
            .hazeBlur(
                input = HazeInput.Sources(hazeState),
                style = style,
            ),
    )
}

HazeInput.Sources renders captured hazeSource content. Use HazeInput.Content to blur the modifier's own content instead. Share a HazeBlurStyle between modifiers and use then to derive variations. Snapshot state read inside a remembered Style block updates each node without recomposition; supply a replacement Style to change the selected Style.

The optional Blur material presets provide HazeMaterials.ultraThin(), thin(), regular(), thick(), and ultraThick(). The haze-blur-material3 integration provides HazeBlurStyle.Material3() for a Style based on the current Material 3 surface.

Glass

haze-glass is a Haze 2 module for material-like Glass: refraction, depth Blur, tint, lighting, highlights, rounded shapes, and optional pointer, focus, and press responses.

Modifier.hazeGlass(
    input = HazeInput.Sources(hazeState),
    style = GlassStyle.regular.then {
        tint(Color.White.copy(alpha = 0.16f))
        shape(RoundedCornerShape(20.dp))
    },
)

Start with GlassStyle.regular, or use GlassStyle.clear when the background should remain more visible. Consult the Glass guide for custom optics, interaction, retention, and platform fallback behavior. Add haze-glass-material3 to use material3() with your current Material 3 surface color. Regular and Clear follow the system appearance without Material 3. The optional integration supplies the app theme's surface color and can add a tint.

Performance

Built-in Blur and Glass use HazePerformanceMode.Default, which selects the fixed Balanced profile. Begin with that setting and measure a release-like build on representative devices before selecting Quality, Performance, or Fixed(...). Adaptive remains as a deprecated compatibility alias for Default. Custom effects keep the separate HazeSampling policy. See the performance guide for the decision framework and effect-specific guidance.

Camera and platform views

Blur and Glass can process a live camera preview when its pixels are drawn in the same Compose graphics layer as hazeSource. On Android, CameraX requires PreviewView.ImplementationMode.COMPATIBLE; a SurfaceView cannot be captured. The camera guide covers CameraX, Kamera, and the same constraint for video and other platform views.

Learn more

License

Copyright 2024 Chris Banes

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    https://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

관련 프로젝트 살펴보기

불러오는 중…