Unofficial YouTube Music / Spotify Premium client for Android, built in Liquid Glass. Audio effects, Spotify Connect, listening history, 8 languages. Rust core on librespot.
Kotlin alternativeandroidandroid-applicationclientglassmorphisminnertubelibrespotliquid-glassspotifyspotify-connectspotifyapiyoutube-musicyoutube-playerytdlnis
The cover ends on its own blur, not on a panel
Lelonio75e842d0d23c
diff --git a/app/src/main/java/dev/lelonio/square/ui/SquareApp.kt b/app/src/main/java/dev/lelonio/square/ui/SquareApp.ktindex 7cbc4dc..2dbd0c2 100644--- a/app/src/main/java/dev/lelonio/square/ui/SquareApp.kt+++ b/app/src/main/java/dev/lelonio/square/ui/SquareApp.kt@@ -3257,9 +3257,17 @@ private fun AppBackdrop(.fillMaxSize().background(Brush.verticalGradient(- 0f to Color.Black.copy(alpha = 0.45f),- 0.5f to Color.Black.copy(alpha = 0.60f),- 1f to Color.Black.copy(alpha = 0.78f),+ // Light enough that the cover's colour survives it.+ //+ // At 0.45 to 0.78 the blurred artwork under the player+ // arrived as grey: a red sleeve gave a grey-green+ // field, which is neither the record's colour nor+ // anything the sharp copy above could dissolve into.+ // The glass over the controls does its own darkening,+ // and the hero's scrim adds the rest at the foot.+ 0f to Color.Black.copy(alpha = 0.18f),+ 0.5f to Color.Black.copy(alpha = 0.24f),+ 1f to Color.Black.copy(alpha = 0.34f),),),)diff --git a/app/src/main/java/dev/lelonio/square/ui/components/HeroBackdrop.kt b/app/src/main/java/dev/lelonio/square/ui/components/HeroBackdrop.ktindex bcc1ed2..760a663 100644--- a/app/src/main/java/dev/lelonio/square/ui/components/HeroBackdrop.kt+++ b/app/src/main/java/dev/lelonio/square/ui/components/HeroBackdrop.kt@@ -58,6 +58,20 @@ fun HeroBackdrop(/** Where the blurred copy starts and where it is complete, top to bottom. */softenFrom: Float = 0.42f,softenTo: Float = 0.72f,+ /**+ * Whether the picture ends on the page's colour, or on itself.+ *+ * A page is a picture with a page under it: the artwork gives way to the+ * tone taken from it, and everything below is flat. A player is not — the+ * reference fills the whole screen with the same picture, blurred and+ * enlarged, and lets the sharp copy dissolve into it. Nothing is covered,+ * so there is no line where the covering starts, and that is the whole of+ * why it reads as one image rather than as an image and a panel.+ *+ * With this false the blurred copy is left unmasked, and the colour stays a+ * scrim for legibility instead of taking over.+ */+ fadeToPage: Boolean = true,/*** The picture's own proportions, when it is to be shown at them.*@@ -70,8 +84,14 @@ fun HeroBackdrop(imageAspect: Float? = null,) {Box(modifier) {- if (imageAspect != null) {+ if (imageAspect != null && fadeToPage) {// The colour first, because the picture no longer covers the slot.+ //+ // Only where the picture is meant to end on it. On the player it is+ // not: an opaque panel here is precisely what the blend is against,+ // and it was hiding the blurred copy of the artwork that fills that+ // screen — which is the thing the sharp copy is supposed to+ // dissolve into.Box(Modifier.fillMaxSize().background(pageColor))}Box(@@ -84,7 +104,35 @@ fun HeroBackdrop(Modifier.fillMaxSize()},)- .align(Alignment.TopCenter),+ .align(Alignment.TopCenter)+ .then(+ // Where the picture ends on itself, the whole slot is what+ // fades — not just the sharp copy under the blurred one.+ //+ // Both copies used to stop dead at the slot's bottom edge,+ // and the screen-wide blur behind them is a different+ // enlargement of the same artwork, so the two met in a line+ // across the player. Erasing the slot before it ends hands+ // the picture over to that blur instead of butting against+ // it.+ if (fadeToPage) {+ Modifier+ } else {+ Modifier+ .graphicsLayer {+ compositingStrategy = CompositingStrategy.Offscreen+ }+ .drawWithContent {+ drawContent()+ drawRect(+ brush = Brush.verticalGradient(+ *fading(softenFrom, softenTo),+ ),+ blendMode = BlendMode.DstIn,+ )+ }+ },+ ),) {Artwork(url = artworkUrl,@@ -128,11 +176,31 @@ fun HeroBackdrop(.drawWithContent {drawContent()drawRect(+ // Eased rather than straight, and started well+ // before the colour does.+ //+ // A linear ramp between two stops is a band: the eye+ // finds both ends of it, and what should read as a+ // picture dissolving reads as a picture with a strip+ // over it. These are the same two ends with the+ // middle bent — slow to leave, quick through the+ // middle, slow to arrive — which is the shape a fade+ // has to have before it stops looking like a shape.brush = Brush.verticalGradient(- 0f to Color.Transparent,- softenFrom to Color.Transparent,- softenTo to Color.Black,- 1f to Color.Black,+ // Ahead of the slot's own fade where the+ // picture ends on itself: the copy that+ // dissolves has to be blurred *before* it+ // starts going, or what dissolves is a sharp+ // photograph and the eye follows it down.+ *if (fadeToPage) {+ softening(softenFrom, softenTo, Color.Black)+ } else {+ softening(+ (softenFrom - 0.16f).coerceAtLeast(0f),+ softenFrom + 0.03f,+ Color.Black,+ )+ },),blendMode = BlendMode.DstIn,)@@ -144,6 +212,7 @@ fun HeroBackdrop(// tone rather than on black: the last row of the picture and the first// row of the background are then the same colour, which is what leaves// no seam to find.+ if (fadeToPage) {Box(Modifier.fillMaxSize()@@ -157,22 +226,92 @@ fun HeroBackdrop(// legible.0f to Color.Black.copy(alpha = 0.22f),(softenFrom * 0.45f) to Color.Transparent,- softenFrom to pageColor.copy(alpha = 0.12f),- ((softenFrom + softenTo) / 2f) to pageColor.copy(alpha = 0.55f),+ // The colour comes up behind the blur rather than with+ // it, and on the same eased curve. The picture going+ // soft first is what makes the two read as one surface+ // blending into the page instead of an image being+ // covered by a panel.+ *softening(+ from = softenFrom + (softenTo - softenFrom) * COLOUR_LAG,+ to = softenTo,+ colour = pageColor,+ ),// Opaque at the end of the softening, not nearly// opaque: the last few percent of the picture were// showing through, and a picture that is still faintly// there has an edge — which is the seam this whole// gradient exists to remove.- softenTo to pageColor,1f to pageColor,),),)}+ }++ // Where the picture ends on itself, the scrim spans the *screen* and+ // not the picture.+ //+ // Kept inside the picture's own slot, it stopped at the slot's bottom+ // edge — and a shade that stops is a line, which is the one thing this+ // whole treatment exists to avoid. Measured on the frame it is drawn+ // in, so the picture's foot is wherever the phone actually put it.+ if (!fadeToPage) {+ Box(+ Modifier+ .fillMaxSize()+ .drawWithContent {+ val ends = imageAspect+ ?.let { (size.width / it / size.height).coerceIn(0f, 1f) }+ ?: 1f+ drawRect(+ brush = Brush.verticalGradient(+ 0f to Color.Black.copy(alpha = 0.20f),+ (ends * 0.45f) to Color.Transparent,+ (ends * 0.92f) to Color.Black.copy(alpha = 0.05f),+ ends to Color.Black.copy(alpha = 0.12f),+ 1f to Color.Black.copy(alpha = 0.30f),+ ),+ )+ },+ )+ }}}+/**+ * A fade drawn as a curve rather than as a line.+ *+ * Compose's gradients interpolate straight between the stops they are given, so+ * a ramp from nothing to everything in one step has a corner at each end and a+ * flat middle — visible as a band across the picture. These are the same two+ * ends sampled along a smoothstep, which starts and ends flat and does its work+ * in the middle: the picture leaves gradually, gives way quickly where nobody is+ * reading it, and settles without an edge.+ */+private fun softening(+ from: Float,+ to: Float,+ colour: Color,+): Array<Pair<Float, Color>> {+ val steps = 8+ return Array(steps + 1) { index ->+ val t = index.toFloat() / steps+ val at = from + (to - from) * t+ // smoothstep: 3t² − 2t³+ val eased = t * t * (3f - 2f * t)+ at to colour.copy(alpha = colour.alpha * eased)+ }+}++/**+ * How far into the softening the colour starts, as a fraction of it.+ *+ * The picture blurs first and the page's colour arrives behind it. Together+ * they read as one surface changing; started at the same moment they read as+ * two things happening at once, which is what a hard fade looks like.+ */+private const val COLOUR_LAG = 0.22f+/** How long a better copy of the same picture takes to arrive. */private const val SWAP_MS = 450@@ -181,3 +320,18 @@ private const val HERO_BLUR_PX = 240/** Soft enough to be a wash, sharp enough to keep the picture's shapes. */private val HeroBlur = BlurTransformation(radius = 10, passes = 2)++/**+ * The same curve as [softening], run the other way.+ *+ * What leaves rather than what arrives: opaque above [from], gone by [to], with+ * the middle bent so neither end is a line.+ */+private fun fading(from: Float, to: Float): Array<Pair<Float, Color>> {+ val steps = 8+ return Array(steps + 1) { index ->+ val t = index.toFloat() / steps+ val eased = t * t * (3f - 2f * t)+ (from + (to - from) * t) to Color.Black.copy(alpha = 1f - eased)+ }+}diff --git a/app/src/main/java/dev/lelonio/square/ui/player/PlayerScreen.kt b/app/src/main/java/dev/lelonio/square/ui/player/PlayerScreen.ktindex e39d73a..89be81a 100644--- a/app/src/main/java/dev/lelonio/square/ui/player/PlayerScreen.kt+++ b/app/src/main/java/dev/lelonio/square/ui/player/PlayerScreen.kt@@ -477,8 +477,12 @@ fun PlayerScreen(// for. This lands the colour a few percent early, so what// reaches the bottom of the frame is colour and nothing// else.- softenFrom = 0.84f,- softenTo = 0.96f,+ // A longer run than the numbers suggest they are: the+ // ramp between them is eased, so the first fifth of it is+ // barely there and the picture reads as sharp well past the+ // point it starts giving way. See softening.+ softenFrom = 0.82f,+ softenTo = 0.97f,// Three by four, whichever picture it is — the shape the// extended covers are drawn in, and the shape that reaches// down to the title with nothing empty in between.@@ -488,6 +492,11 @@ fun PlayerScreen(// screen is 1080, so what is cropped is real picture and// what is drawn is still smaller than the source.imageAspect = DETAIL_ASPECT,+ // The picture ends on itself here, not on the page's tone:+ // behind this whole screen is the same artwork, blurred and+ // filling it, so the sharp copy has its own blur to dissolve+ // into. See fadeToPage.+ fadeToPage = false,modifier = Modifier.fillMaxSize(),)// And the light still moves, in the cover's own colours: it is