style(android): improve idle background

This commit is contained in:
Peter Steinberger
2025-12-18 00:41:21 +01:00
parent 579da8cc9b
commit 14fa2f47f5

View File

@@ -5,10 +5,13 @@ import androidx.compose.animation.core.animateFloat
import androidx.compose.animation.core.infiniteRepeatable import androidx.compose.animation.core.infiniteRepeatable
import androidx.compose.animation.core.rememberInfiniteTransition import androidx.compose.animation.core.rememberInfiniteTransition
import androidx.compose.animation.core.tween import androidx.compose.animation.core.tween
import androidx.compose.foundation.background
import androidx.compose.foundation.Canvas import androidx.compose.foundation.Canvas
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.blur
import androidx.compose.ui.geometry.Offset import androidx.compose.ui.geometry.Offset
import androidx.compose.ui.graphics.BlendMode import androidx.compose.ui.graphics.BlendMode
import androidx.compose.ui.graphics.Brush import androidx.compose.ui.graphics.Brush
@@ -49,64 +52,75 @@ fun ClawdisIdleBackground(modifier: Modifier = Modifier) {
label = "glowY", label = "glowY",
).value ).value
Canvas(modifier = modifier.fillMaxSize()) { Box(modifier = modifier.fillMaxSize().background(Color.Black)) {
drawRect(Color.Black) Canvas(modifier = Modifier.fillMaxSize()) {
val w = size.width
val h = size.height
val w = size.width fun radial(cx: Float, cy: Float, r: Float, color: Color): Brush =
val h = size.height Brush.radialGradient(
colors = listOf(color, Color.Transparent),
center = Offset(cx, cy),
radius = r,
)
fun radial(cx: Float, cy: Float, r: Float, color: Color): Brush = drawRect(
Brush.radialGradient( brush = radial(w * 0.15f, h * 0.20f, r = maxOf(w, h) * 0.85f, color = Color(0xFF2A71FF).copy(alpha = 0.18f)),
colors = listOf(color, Color.Transparent), )
center = Offset(cx, cy), drawRect(
radius = r, brush = radial(w * 0.85f, h * 0.30f, r = maxOf(w, h) * 0.75f, color = Color(0xFFFF008A).copy(alpha = 0.14f)),
)
drawRect(
brush = radial(w * 0.60f, h * 0.90f, r = maxOf(w, h) * 0.85f, color = Color(0xFF00D1FF).copy(alpha = 0.10f)),
) )
drawRect( rotate(degrees = -7f) {
brush = radial(w * 0.15f, h * 0.20f, r = maxOf(w, h) * 0.85f, color = Color(0xFF2A71FF).copy(alpha = 0.18f)), val spacing = 48.dp.toPx()
) val line = Color.White.copy(alpha = 0.02f)
drawRect( val offset = Offset(gridX.dp.toPx(), gridY.dp.toPx())
brush = radial(w * 0.85f, h * 0.30f, r = maxOf(w, h) * 0.75f, color = Color(0xFFFF008A).copy(alpha = 0.14f)),
)
drawRect(
brush = radial(w * 0.60f, h * 0.90f, r = maxOf(w, h) * 0.85f, color = Color(0xFF00D1FF).copy(alpha = 0.10f)),
)
rotate(degrees = -7f) { var x = (-w * 0.6f) + (offset.x % spacing)
val spacing = 48.dp.toPx() while (x < w * 1.6f) {
val line = Color.White.copy(alpha = 0.02f) drawLine(color = line, start = Offset(x, -h * 0.6f), end = Offset(x, h * 1.6f))
val offset = Offset(gridX.dp.toPx(), gridY.dp.toPx()) x += spacing
}
var x = (-w * 0.6f) + (offset.x % spacing) var y = (-h * 0.6f) + (offset.y % spacing)
while (x < w * 1.6f) { while (y < h * 1.6f) {
drawLine(color = line, start = Offset(x, -h * 0.6f), end = Offset(x, h * 1.6f)) drawLine(color = line, start = Offset(-w * 0.6f, y), end = Offset(w * 1.6f, y))
x += spacing y += spacing
} }
var y = (-h * 0.6f) + (offset.y % spacing)
while (y < h * 1.6f) {
drawLine(color = line, start = Offset(-w * 0.6f, y), end = Offset(w * 1.6f, y))
y += spacing
} }
} }
// Glow drift layer (approximation of iOS WebView scaffold). // Glow drift layer (closer to iOS WebView scaffold: blur + screen blend).
val glowOffset = Offset(glowX.dp.toPx(), glowY.dp.toPx()) Canvas(modifier = Modifier.fillMaxSize().blur(28.dp)) {
drawRect( val w = size.width
brush = radial(w * 0.30f + glowOffset.x, h * 0.30f + glowOffset.y, r = maxOf(w, h) * 0.75f, color = Color(0xFF2A71FF).copy(alpha = 0.16f)), val h = size.height
blendMode = BlendMode.Screen, val glowOffset = Offset(glowX.dp.toPx(), glowY.dp.toPx())
alpha = 0.55f,
) fun radial(cx: Float, cy: Float, r: Float, color: Color): Brush =
drawRect( Brush.radialGradient(
brush = radial(w * 0.70f + glowOffset.x, h * 0.35f + glowOffset.y, r = maxOf(w, h) * 0.70f, color = Color(0xFFFF008A).copy(alpha = 0.12f)), colors = listOf(color, Color.Transparent),
blendMode = BlendMode.Screen, center = Offset(cx, cy),
alpha = 0.55f, radius = r,
) )
drawRect(
brush = radial(w * 0.55f + glowOffset.x, h * 0.75f + glowOffset.y, r = maxOf(w, h) * 0.85f, color = Color(0xFF00D1FF).copy(alpha = 0.10f)), drawRect(
blendMode = BlendMode.Screen, brush = radial(w * 0.30f + glowOffset.x, h * 0.30f + glowOffset.y, r = maxOf(w, h) * 0.75f, color = Color(0xFF2A71FF).copy(alpha = 0.16f)),
alpha = 0.55f, blendMode = BlendMode.Screen,
) alpha = 0.55f,
)
drawRect(
brush = radial(w * 0.70f + glowOffset.x, h * 0.35f + glowOffset.y, r = maxOf(w, h) * 0.70f, color = Color(0xFFFF008A).copy(alpha = 0.12f)),
blendMode = BlendMode.Screen,
alpha = 0.55f,
)
drawRect(
brush = radial(w * 0.55f + glowOffset.x, h * 0.75f + glowOffset.y, r = maxOf(w, h) * 0.85f, color = Color(0xFF00D1FF).copy(alpha = 0.10f)),
blendMode = BlendMode.Screen,
alpha = 0.55f,
)
}
} }
} }