Custom Drawing & AGSL Shaders
Allocation-free DrawScope with drawBehind, drawWithContent, Canvas, Brush gradients, and reactive Android AGSL ShaderBrush.
When standard containers and styles aren't enough, Crow UI exposes an allocation-free DrawScope and first-class Android AGSL runtime shaders — powered by the exact same reactive graph as everything else.
drawBehind, drawWithContent & Canvas
Attach custom vector drawing anywhere in a modifier chain, or create a dedicated Canvas leaf:
Canvas(Modifier.size(48.dp)) {
drawArc(
color = AccentViolet,
startAngle = -90f,
sweepAngle = progress.value * 360f,
useCenter = false,
style = DrawStyle.Stroke(4.dp.toPx(), cap = StrokeCap.Round),
)
}- Fine-grained draw tracking: Inside
drawBehind,drawWithContent, andCanvas, Crow UI wraps execution inreaction(). Reading a signal orAnimatableinside the draw block re-records only that single node's display list when the value changes — zero layout pass, zero tree traversal. - Chain-order accurate:
Modifier.drawBehind { }andModifier.drawWithContent { drawContent(); ... }execute at their exact position relative to padding, clip, and border.
Brushes & Reactive AGSL Shaders
Crow provides a Brush hierarchy (Brush.solid, Brush.linearGradient, Brush.radialGradient) plus Android's ShaderBrush for custom AGSL (RuntimeShader) programs with a mandatory graceful fallback for devices below API 33:
// Declaring `uniform float uTime;` in AGSL feeds elapsed seconds from Motion.clock automatically.
val auroraBrush = ShaderBrush(
agsl = AURORA_AGSL_SOURCE,
fallback = Brush.linearGradient(listOf(0xFF5B3DF5.toInt(), 0xFFB07CFF.toInt())),
uniforms = {
float2("uResolution", width, height)
float2("uTouch", touchX.value, touchY.value)
color("uAccent", theme.accent)
},
)
Box(
Modifier
.fillMaxWidth()
.height(220.dp)
.clip(RoundedCornerShape(24.dp))
.background(auroraBrush),
)Why Crow Shaders Feel Effortless
- Reactive uniforms: Reading signals or
Animatablevalues insideuniforms = { ... }tracks them directly in the draw phase — animating a shader uniform never triggers layout or recomposition. - Dormancy-aware
uTime: Reading the motion clock automatically pauses when a screen becomes dormant in the back stack or the app moves to the background. - Works everywhere: Pass any
BrushorShaderBrushtoModifier.background(brush)or anyDrawScopeprimitive (drawRect,drawRoundRect,drawCircle,drawArc).
How is this guide?
Styles, Overlays & Unstyled Components
Composable Style values with OKLab state transitions, Interaction bitmasks, unstyled bases, and the unified Overlay primitive.
Text Input & Crow Image
Direct InputConnection text editing with TextState, input/output transformations, and Coil-class hardware-bitmap image loading with crow-image.