andrew
06/23/2024, 12:29 AMModifier.graphicsLayer {
compositingStrategy = CompositingStrategy.Offscreen
}.drawWithContent {
val brush = Brush.verticalGradient(listOf(Color.Black, Color.Black.copy(0F)))
drawContent()
drawRect(brush, blendMode = BlendMode.DstIn)
}
Using this chain of modifier on any other compose view masks it with a gradient, effectively fading out an edge. iOS has a nice blur look where they use a gradient to decrease/increase the blur with a gradient mask, is this achievable with Haze?andrew
06/23/2024, 1:24 AMSergey Y.
06/23/2024, 9:14 AMSergey Y.
06/23/2024, 9:20 AMromainguy
06/23/2024, 11:37 AMSergey Y.
06/23/2024, 11:44 AMandrew
06/23/2024, 8:17 PMSergey Y.
06/23/2024, 9:01 PMRenderNode
. The steps are as follows: first, draw the original, non-blurred background. Next, create another node for the blurred background and draw it on top of the original, applying the gradient mask. This step will create a nice effect of gradually increasing blur over the crisp image. Finally, draw the content of the child that will have this background effect on top.
This is how I handle it with my OpenGL-based blurring with gradient masks, but I'm not 100% confident if this is the right approach — it's just what I'm doing in my case (and I'm starting to hate OpenGL blending functions 🫠).
https://github.com/chrisbanes/haze/blob/main/haze/src/androidMain/kotlin/dev/chrisbanes/haze/AndroidHazeNode.kt#L298andrew
06/24/2024, 5:37 AMSergey Y.
06/24/2024, 4:21 PMandrew
06/24/2024, 8:12 PMandrew
06/24/2024, 8:12 PMSergey Y.
06/24/2024, 8:17 PMandrew
06/24/2024, 8:22 PMSergey Y.
06/24/2024, 8:31 PMfinalColor.rgb = mix(backgroundColor.rgb, blurColor.rgb, maskColor.r);
In the case of Haze, instead of using shaders and mixing, there will be blending modesandrew
06/24/2024, 8:36 PMSergey Y.
06/24/2024, 8:37 PMSergey Y.
06/24/2024, 8:38 PM