Last active
September 24, 2022 11:49
-
-
Save mazzouzi/8566f4dee7c6a566f1c7fe59c0d267ad to your computer and use it in GitHub Desktop.
Bernstein polynomial form
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
. | |
. | |
Text( | |
text = "New York", | |
fontSize = 30.sp, | |
fontWeight = FontWeight.Bold, | |
modifier = Modifier | |
.graphicsLayer { | |
val collapseRange: Float = (headerHeightPx - toolbarHeightPx) | |
val collapseFraction: Float = (scroll.value / collapseRange).coerceIn(0f, 1f) | |
val titleY: Float = (1f-collapseFraction).pow(2) * | |
(headerHeightPx - titleHeightPx - paddingPx) + | |
2 * collapseFraction * (1-collapseFraction) * headerHeightPx / 2 + | |
collapseFraction.pow(2) * (toolbarHeightPx / 2 - titleHeightPx / 2) | |
val titleX: Float = | |
(1f-collapseFraction).pow(2) * (titlePaddingStartPx) + | |
2 * collapseFraction * (1-collapseFraction) * titlePaddingEndPx * | |
5 / 4 + collapseFraction.pow(2) * titlePaddingEndPx | |
translationY = titleY | |
translationX = titleX | |
} | |
.onGloballyPositioned { | |
titleHeightPx = it.size.height.toFloat() | |
} | |
) | |
. | |
. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment