Release 0.1.3 with the aperture startup animation
All checks were successful
Validate and publish Kaleido / android (push) Successful in 2m15s

The cold-start splash is now an iris: the closed aperture gathers light,
twists open with light leaking through its gaps, a sheen crosses the mark
and the wordmark slides out from behind it. The exit flies through the
aperture's center into the app instead of crossfading. The iris holds while
startup data arrives so cold-start hitches never land mid-motion.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Elijah 2026-10-24 10:58:15 -07:00
parent 430616330b
commit 4c56eb3755
9 changed files with 256 additions and 73 deletions

View file

@ -4,6 +4,7 @@ package tv.kaleido.app
import androidx.activity.compose.BackHandler
import androidx.compose.animation.Crossfade
import androidx.compose.animation.core.Animatable
import androidx.compose.animation.core.LinearEasing
import androidx.compose.animation.core.tween
import androidx.compose.animation.core.animateFloatAsState
import androidx.compose.foundation.*
@ -64,11 +65,11 @@ import java.io.File
// A restored Activity after process eviction still needs the cold-start cover.
var startup by remember{mutableStateOf(true)}
var brandReady by remember{mutableStateOf(false)}
val splash=remember{Animatable(1f)}
val splashExit=remember{Animatable(0f)}
LaunchedEffect(brandReady){
if(startup&&brandReady){
withTimeoutOrNull(600){snapshotFlow{!vm.busy}.first{it}}
splash.animateTo(0f,tween(360));startup=false
splashExit.animateTo(1f,tween(StartupExitMillis,easing=LinearEasing));startup=false
}
}
BackHandler(enabled=vm.linkingAccount||vm.playing!=null||vm.pages.size>1||vm.page.kind!="home"){
@ -76,6 +77,8 @@ import java.io.File
}
NavigationSounds(vm.navigationSounds&&!startup) {
Box(Modifier.fillMaxSize().background(Ink).onPreviewKeyEvent{startup}) {
// The app settles into place behind the splash as its aperture opens.
Box(Modifier.fillMaxSize().then(if(startup)Modifier.graphicsLayer{val s=startupArrivalScale(splashExit.value);scaleX=s;scaleY=s}else Modifier)) {
if(vm.servers.isNotEmpty()) ServerPicker(vm) else if(vm.session==null||vm.linkingAccount) SignIn(vm) else {
Column(Modifier.fillMaxSize().graphicsLayer{
alpha=.18f+.82f*entrance.value
@ -94,10 +97,11 @@ import java.io.File
}
if(immersive)TopBar(vm,discoveryFocus)
}
}
if(vm.busy) LinearProgressIndicator(Modifier.fillMaxWidth().height(2.dp).align(Alignment.TopCenter),color=Accent,trackColor=Color.Transparent)
if(vm.error!=null) ErrorDialog(vm.error!!,{vm.dismissError()},{vm.retry()})
vm.playing?.let {item-> androidx.compose.runtime.key(item.id) {PlaybackScreen(vm,item)} }
if(startup)StartupSplash(splash.value){brandReady=true}
if(startup)StartupSplash({splashExit.value},{!vm.busy}){brandReady=true}
}
}
}

View file

@ -1,96 +1,261 @@
package tv.kaleido.app
import androidx.compose.animation.core.Animatable
import androidx.compose.animation.core.FastOutSlowInEasing
import androidx.compose.animation.core.CubicBezierEasing
import androidx.compose.animation.core.LinearEasing
import androidx.compose.animation.core.tween
import androidx.compose.foundation.Canvas
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.*
import androidx.compose.material3.Text
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.runtime.*
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.geometry.Offset
import androidx.compose.ui.geometry.Rect
import androidx.compose.ui.geometry.Size
import androidx.compose.ui.graphics.BlendMode
import androidx.compose.ui.graphics.Brush
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.Path
import androidx.compose.ui.graphics.PathFillType
import androidx.compose.ui.graphics.drawscope.clipPath
import androidx.compose.ui.graphics.drawscope.clipRect
import androidx.compose.ui.graphics.drawscope.withTransform
import androidx.compose.ui.graphics.graphicsLayer
import androidx.compose.ui.graphics.vector.PathParser
import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.semantics.clearAndSetSemantics
import androidx.compose.ui.semantics.contentDescription
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.drawText
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.dp
import androidx.compose.ui.text.rememberTextMeasurer
import androidx.compose.ui.unit.sp
import kotlinx.coroutines.flow.first
import kotlinx.coroutines.withTimeoutOrNull
import kotlin.math.PI
import kotlin.math.cos
import kotlin.math.exp
import kotlin.math.ln
import kotlin.math.sin
private data class ApertureFacet(val path:Path,val color:Color,val center:Offset)
private class ApertureFacet(val points:List<Offset>,val color:Color,val normal:Offset)
// Exact geometry and colors from brand_mark.xml. The six pieces move independently
// into the existing aperture; the completed mark is never rotated or redesigned.
// Exact geometry and colors from brand_mark.xml, centered on its 64-unit viewport.
// Each facet carries the outward normal of its hexagon edge for the iris motion.
private val apertureFacets=listOf(
Triple("M33,4 L55.5,17 L42.5,24.5 L33,19 Z",0xFFC3E8D3,Offset(43f,14f)),
Triple("M56.5,19 L56.5,45 L43.5,37.5 L43.5,26.5 Z",0xFF71B9B0,Offset(50f,32f)),
Triple("M55.5,47 L33,60 L33,45 L42.5,39.5 Z",0xFF3D7C7B,Offset(43f,50f)),
Triple("M31,60 L8.5,47 L21.5,39.5 L31,45 Z",0xFFD0A977,Offset(21f,50f)),
Triple("M7.5,45 L7.5,19 L20.5,26.5 L20.5,37.5 Z",0xFFE9D8AE,Offset(14f,32f)),
Triple("M8.5,17 L31,4 L31,19 L21.5,24.5 Z",0xFFEEF2DD,Offset(21f,14f))
).map{(path,color,center)->ApertureFacet(PathParser().parsePathString(path).toPath(),Color(color),center)}
floatArrayOf(33f,4f,55.5f,17f,42.5f,24.5f,33f,19f) to 0xFFC3E8D3,
floatArrayOf(56.5f,19f,56.5f,45f,43.5f,37.5f,43.5f,26.5f) to 0xFF71B9B0,
floatArrayOf(55.5f,47f,33f,60f,33f,45f,42.5f,39.5f) to 0xFF3D7C7B,
floatArrayOf(31f,60f,8.5f,47f,21.5f,39.5f,31f,45f) to 0xFFD0A977,
floatArrayOf(7.5f,45f,7.5f,19f,20.5f,26.5f,20.5f,37.5f) to 0xFFE9D8AE,
floatArrayOf(8.5f,17f,31f,4f,31f,19f,21.5f,24.5f) to 0xFFEEF2DD
).mapIndexed { index,(points,color) ->
val angle=(-60.0+60*index)*PI/180
ApertureFacet(points.toList().chunked(2){Offset(it[0]-32f,it[1]-32f)},Color(color),Offset(cos(angle).toFloat(),sin(angle).toFloat()))
}
// Inner hexagon traced by the facets' inner edges: the aperture the exit flies through.
private const val InnerRadius=13.6f
private const val InnerApothem=11.8f
private const val IntroBox=132f
// The settled lockup is the header Brand() scaled up, so it reads as the same mark.
private const val LockScale=2.75f
private const val LockBox=29f*LockScale
private const val LockGap=7f*LockScale
// Opening timeline in ms, paused at GatherEnd until startup is ready. Completion is reported at IntroEnd; the timeline keeps
// running to TimelineEnd only for the slow settle while the exit plays or startup loads.
private const val GatherEnd=260f
private const val IntroEnd=2260f
private const val TimelineEnd=2900f
const val StartupExitMillis=640
private val Emphasized=CubicBezierEasing(.2f,0f,0f,1f)
private val EmphasizedDecelerate=CubicBezierEasing(.05f,.7f,.1f,1f)
private val Standard=CubicBezierEasing(.4f,0f,.2f,1f)
private val InOut=CubicBezierEasing(.45f,0f,.55f,1f)
// A mechanical iris: the blades gather, snap open, and overshoot slightly as they lock.
private val IrisOpen=CubicBezierEasing(.55f,0f,.15f,1f)
private val IrisTwist=CubicBezierEasing(.5f,0f,.18f,1.1f)
// Applied in log space: a brief pull back, then an accelerating flight.
private val Flight=CubicBezierEasing(.55f,-.06f,.8f,.36f)
private val SeaGlass=Color(0xFF71B9B0)
private fun phase(time:Float,start:Float,end:Float)=((time-start)/(end-start)).coerceIn(0f,1f)
private fun mix(from:Float,to:Float,amount:Float)=from+(to-from)*amount
/** One finite brand sequence, followed by a settled mark while startup data loads. */
@Composable fun StartupSplash(alpha:Float,onComplete:()->Unit) {
private class Iris(val inward:Float,val theta:Float,val grow:Float)
private fun irisAt(time:Float):Iris {
val progress=phase(time,140f,1180f)
return Iris(InnerApothem*(1f-IrisOpen.transform(progress)),(-44f*(1f-IrisTwist.transform(progress))*PI/180).toFloat(),
mix(.64f,1f,Emphasized.transform(progress)))
}
private fun Path.facet(facet:ApertureFacet,iris:Iris,unit:Float,center:Offset) {
val c=cos(iris.theta);val s=sin(iris.theta);val k=unit*iris.grow
facet.points.forEachIndexed { index,point ->
val x=point.x-facet.normal.x*iris.inward;val y=point.y-facet.normal.y*iris.inward
val px=center.x+(x*c-y*s)*k;val py=center.y+(x*s+y*c)*k
if(index==0)moveTo(px,py)else lineTo(px,py)
}
close()
}
private fun Path.hexagon(center:Offset,radius:Float) {
for(index in 0 until 6) {
val angle=(-90.0+60*index)*PI/180
val x=center.x+cos(angle).toFloat()*radius;val y=center.y+sin(angle).toFloat()*radius
if(index==0)moveTo(x,y)else lineTo(x,y)
}
close()
}
/** Scale for the screen behind the splash, so it settles into place as the aperture opens. */
fun startupArrivalScale(exit:Float)=mix(1.14f,1f,EmphasizedDecelerate.transform(phase(exit,.25f,1f)))
/**
* The cold-start brand sequence: a closed iris lit from behind twists open once [ready], light catches
* the facets, and the wordmark slides out of the mark. [exit] (0–1, linear) then flies
* the camera through the aperture's dark center, revealing the app drawn beneath.
*/
@Composable fun StartupSplash(exit:()->Float,ready:()->Boolean,onComplete:()->Unit) {
val timeline=remember{Animatable(0f)}
val complete by rememberUpdatedState(onComplete)
LaunchedEffect(Unit){
// Animatable honors Android's animation duration scale, including animations off.
timeline.animateTo(1f,tween(2600,easing=LinearEasing))
// Light gathers on the closed iris straight away. It is nearly still, so the first
// cold-start frames can hitch there without being noticed.
timeline.animateTo(GatherEnd,tween(GatherEnd.toInt(),easing=LinearEasing))
// Startup data arriving composes the app beneath the splash in one long frame. Hold
// until that has happened and frames arrive steadily again (at most 700 ms), so
// the iris never opens through it.
withTimeoutOrNull(700){
snapshotFlow{ready()}.first{it}
var previous=withFrameNanos{it};var steady=0
while(steady<4){val now=withFrameNanos{it};steady=if(now-previous<24_000_000L)steady+1 else 0;previous=now}
}
timeline.animateTo(TimelineEnd,tween((TimelineEnd-GatherEnd).toInt(),easing=LinearEasing))
}
LaunchedEffect(Unit){
snapshotFlow{timeline.value>=IntroEnd}.first{it}
complete()
}
Box(Modifier.fillMaxSize().graphicsLayer{this.alpha=alpha}.background(Ink)
.clearAndSetSemantics{contentDescription="Kaleido starting"},contentAlignment=Alignment.Center) {
Canvas(Modifier.fillMaxSize()) {
val time=timeline.value
val origin=Offset(size.width/2,size.height/2-32.dp.toPx())
val unit=112.dp.toPx()/64f
val glow=sin(phase(time,0f,.88f)*Math.PI).toFloat().coerceAtLeast(0f)
drawCircle(Brush.radialGradient(listOf(Color(0xFF71B9B0).copy(alpha=.16f*glow),Color.Transparent),
center=origin,radius=230.dp.toPx()),radius=230.dp.toPx(),center=origin)
apertureFacets.forEachIndexed { index,facet ->
val start=.06f+index*.045f
val raw=phase(time,start,start+.34f)
val arrival=FastOutSlowInEasing.transform(raw)
val direction=(facet.center-Offset(32f,32f))/18f
val distance=190f*(1f-arrival)
// A tapered light trail leads each sea-glass/ivory facet inward.
if(raw>0f&&raw<1f) {
val head=origin+direction*((distance+23f)*unit)
val tail=head+direction*((20f+80f*(1f-arrival))*unit)
drawLine(Brush.linearGradient(listOf(facet.color.copy(alpha=.5f*sin(raw*Math.PI).toFloat()),Color.Transparent),head,tail),
head,tail,strokeWidth=1.3.dp.toPx())
}
withTransform({
translate(origin.x-32f*unit,origin.y-32f*unit)
scale(unit,unit,pivot=Offset.Zero)
translate(direction.x*distance,direction.y*distance)
scale(.72f+.28f*arrival,.72f+.28f*arrival,pivot=facet.center)
}) {
drawPath(facet.path,facet.color,alpha=phase(raw,0f,.42f))
val glint=sin(phase(time,.64f+index*.018f,.78f+index*.018f)*Math.PI).toFloat().coerceAtLeast(0f)
if(raw==1f)drawPath(facet.path,Color.White,alpha=.22f*glint)
val measurer=rememberTextMeasurer()
val density=LocalDensity.current
val style=TextStyle(color=Accent,fontSize=(19f*LockScale).sp,fontWeight=FontWeight.Bold)
val letters=remember(measurer,density){"KALEIDO".map{measurer.measure(it.toString(),style)}}
val letterX=remember(letters,density){
val tracking=with(density){(1.4f*LockScale).sp.toPx()}
letters.runningFold(0f){x,letter->x+letter.size.width+tracking}
}
val textWidth=letterX.last()-with(density){(1.4f*LockScale).sp.toPx()}
val capHeight=with(density){style.fontSize.toPx()}*.711f
val paths=remember{List(4){Path()}}
Canvas(Modifier.fillMaxSize().clearAndSetSemantics{contentDescription="Kaleido starting"}) {
val time=timeline.value
val q=exit()
val dp=density.density
val lockup=Emphasized.transform(phase(time,1250f,2000f))
val lockWidth=(LockBox+LockGap)*dp+textWidth
var box=mix(IntroBox,LockBox,lockup)*dp
// A slow push-in keeps the settled frame alive.
val drift=1f+.025f*InOut.transform(phase(time,1900f,2900f))
var cx=mix(center.x,center.x-lockWidth/2+LockBox*dp/2,lockup)
var cy=center.y
var zoom=1f;var textAlpha=1f;var textShift=0f;var hole=0f
if(q>0f) {
zoom=exp(ln(52f)*Flight.transform(q))
val recenter=Standard.transform((q/.75f).coerceAtMost(1f))
cx=mix(cx,center.x,recenter);cy=mix(cy,center.y,recenter)
textAlpha=1f-Standard.transform(phase(q,0f,.4f))
textShift=-14f*dp*Standard.transform(phase(q,0f,.4f))
hole=InOut.transform(phase(q,.12f,.5f))
}
val unit=box/64f*drift*zoom
val origin=Offset(cx,cy)
val (surface,aperture,facets,ray)=paths
// Splash surface: Ink everywhere, with the aperture's center cut away on exit.
if(hole<=0f)drawRect(Ink)
else {
surface.rewind();surface.fillType=PathFillType.EvenOdd
surface.addRect(Rect(Offset.Zero,size));surface.hexagon(origin,InnerRadius*unit)
drawPath(surface,Ink)
if(hole<1f){aperture.rewind();aperture.hexagon(origin,InnerRadius*unit);drawPath(aperture,Ink,alpha=1f-hole)}
}
val iris=irisAt(time)
val lightUp=EmphasizedDecelerate.transform(phase(time,0f,620f))
val light=lightUp*(1f-Standard.transform(phase(time,620f,1250f)))
val ambient=.03f*InOut.transform(phase(time,300f,900f))*(1f-Standard.transform(phase(time,1500f,2300f)))
// Light behind the blades: a soft bloom, a hot core, and rays leaking through
// the six gaps while the iris turns.
if(light>.001f||ambient>.001f) {
val bloom=250f*dp
drawCircle(Brush.radialGradient(0f to SeaGlass.copy(alpha=.16f*light+ambient),.45f to SeaGlass.copy(alpha=.04f*light+ambient*.3f),
1f to Color.Transparent,center=origin,radius=bloom),bloom,origin,blendMode=BlendMode.Plus)
val core=26f*unit/2.0625f*mix(.6f,1f,light)
if(light>.001f) {
drawCircle(Brush.radialGradient(0f to Color(1f,.98f,.925f,.95f*light),.35f to Color(0xFFEEF2DD).copy(alpha=.55f*light),
1f to Color.Transparent,center=origin,radius=core),core,origin,blendMode=BlendMode.Plus)
val rays=light*(IrisOpen.transform(phase(time,140f,1180f))*2.5f).coerceAtMost(1f)
for(index in 0 until 6) {
val angle=((-90.0+60*index)*PI/180).toFloat()+iris.theta
val length=mix(40f,250f,lightUp)*(.75f+.25f*sin(index*2.1f+1f))*dp
ray.rewind();ray.moveTo(origin.x,origin.y)
ray.lineTo(origin.x+cos(angle-.014f)*length,origin.y+sin(angle-.014f)*length)
ray.lineTo(origin.x+cos(angle+.014f)*length,origin.y+sin(angle+.014f)*length);ray.close()
drawPath(ray,Brush.linearGradient(0f to Color(1f,.973f,.902f,.42f*rays),.25f to Color(0xFFD6ECE2).copy(alpha=.12f*rays),
1f to Color.Transparent,start=origin,end=Offset(origin.x+cos(angle)*length,origin.y+sin(angle)*length)),blendMode=BlendMode.Plus)
}
}
}
Row(Modifier.offset(y=65.dp),horizontalArrangement=Arrangement.spacedBy(7.dp),verticalAlignment=Alignment.CenterVertically) {
"KALEIDO".forEachIndexed { index,letter ->
Text(letter.toString(),color=Color(0xFFEEF2DD),fontSize=28.sp,fontWeight=FontWeight.Medium,
modifier=Modifier.graphicsLayer {
val reveal=FastOutSlowInEasing.transform(phase(timeline.value,.48f+index*.025f,.66f+index*.025f))
this.alpha=reveal
translationY=14.dp.toPx()*(1f-reveal)
})
// Facets. Short echoes of earlier frames act as motion blur while the blades
// turn; they disappear beneath the facets once the iris is still.
fun facetAlpha(index:Int)=EmphasizedDecelerate.transform(phase(time,40f+index*34,380f+index*34))
if(time<1400f) for((delay,alpha) in listOf(84f to .07f,56f to .12f,28f to .2f)) {
val echo=irisAt(time-delay)
apertureFacets.forEachIndexed { index,facet ->
facets.rewind();facets.facet(facet,echo,unit,origin);drawPath(facets,facet.color,alpha=alpha*facetAlpha(index))
}
}
apertureFacets.forEachIndexed { index,facet ->
facets.rewind();facets.facet(facet,iris,unit,origin);drawPath(facets,facet.color,alpha=facetAlpha(index))
}
val sheen=phase(time,980f,1560f)
if(light>.01f||(sheen>0f&&sheen<1f)) {
facets.rewind();apertureFacets.forEach{facets.facet(it,iris,unit,origin)}
clipPath(facets) {
// Backlight tints the blades while the core is hot, so they read as glass.
if(light>.01f) {
val radius=36f*unit/2.0625f
drawCircle(Brush.radialGradient(0f to Color(1f,.988f,.94f,.26f*light),1f to Color.Transparent,center=origin,radius=radius),radius,origin)
}
// One diagonal band of light crosses the settled mark.
if(sheen>0f&&sheen<1f) {
val reach=34f*unit;val angle=36f*PI.toFloat()/180;val direction=Offset(cos(angle),sin(angle))
val position=mix(-1.25f,1.25f,InOut.transform(sheen))*reach;val width=10f*unit
val peak=.42f*sin((sheen*1.1f).coerceAtMost(1f)*PI.toFloat())
drawRect(Brush.linearGradient(0f to Color.Transparent,.5f to Color.White.copy(alpha=peak),1f to Color.Transparent,
start=origin+direction*(position-width),end=origin+direction*(position+width)),origin-Offset(reach,reach),Size(reach*2,reach*2))
}
}
}
// The wordmark slides out from behind the mark as it moves into the lockup.
if(time>=1400f&&textAlpha>0f) {
val scale=box/(LockBox*dp)*drift
val textLeft=cx-box*drift/2+(LockBox+LockGap)*dp*scale
val slide=EmphasizedDecelerate.transform(phase(time,1400f,2050f))
val baseline=cy+capHeight/2*scale
clipRect(left=cx+24.5f*unit+2f*dp*scale) {
letters.forEachIndexed { index,letter ->
val start=1460f+index*45
val reveal=Standard.transform(phase(time,start,start+320f))
if(reveal>0f) withTransform({
translate(textLeft+(letterX[index]-(1f-slide)*textWidth*.42f)*scale+textShift,baseline-letter.firstBaseline*scale)
scale(scale,scale,pivot=Offset.Zero)
}) {drawText(letter,alpha=reveal*textAlpha)}
}
}
}
}