AsyncPicTransition
Sealed class controlling the reveal animation when an image finishes loading.
sealed class AsyncPicTransition {
object Standard : AsyncPicTransition()
data class ShaderReveal(
val type: RevealType = RevealType.DISSOLVE,
val durationMillis: Int = 1000
) : AsyncPicTransition()
}
AsyncPicTransition.Standard​
Default behavior — uses Coil's built-in crossfade. Works on all API levels.
transition = AsyncPicTransition.Standard
AsyncPicTransition.ShaderReveal​
GPU-accelerated AGSL shader transition. Requires Android 13 (API 33). Silently ignored on older versions.
transition = AsyncPicTransition.ShaderReveal(
type = RevealType.DISSOLVE,
durationMillis = 1000
)
| Field | Type | Default | Description |
|---|---|---|---|
type | RevealType | DISSOLVE | Which shader effect to use |
durationMillis | Int | 1000 | Duration of the animation in ms |
RevealType​
enum class RevealType {
DISSOLVE, // Noise-based particle dissolve
PIXELATE, // Block pixels that resolve to full image
WIPE // Left-to-right wipe
}
DISSOLVE​
Uses a fract(sin(...)) noise function to reveal the image one random pixel group at a time. The most organic-looking transition.
PIXELATE​
Starts at blockSize = 50px and shrinks to 0 as progress increases. Creates a retro pixel-art style reveal.
WIPE​
Linear left-to-right reveal: pixels left of progress * resolution.x are shown, pixels right are transparent.
AGSL Shader Source​
The three shaders are defined in AsyncPicShaders:
object AsyncPicShaders {
const val DISSOLVE_SHADER: String
const val PIXELATE_SHADER: String
const val WIPE_SHADER: String
}
Each shader receives a progress uniform (0.0 → 1.0) driven by animateFloatAsState. PIXELATE and WIPE additionally receive a resolution uniform (width, height in pixels).