Skip to content

Commit

Permalink
Reuse and rewind the same path for the wave
Browse files Browse the repository at this point in the history
Resolves #4
  • Loading branch information
mahozad committed Jul 10, 2024
1 parent dfba104 commit ed409af
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ data class WaveAnimationSpecs(
*/
typealias WaveVelocity = Pair<Dp, WaveDirection>

private val wavyPath = Path()
internal val defaultIncremental = false
internal val defaultWaveLength = 20.dp
internal val defaultWaveHeight = 6.dp
Expand Down Expand Up @@ -177,7 +178,8 @@ internal inline fun DrawScope.createWavyPath(
waveSpread: Float,
waveShift: Dp,
incremental: Boolean
): Path = Path().apply {
): Path = wavyPath.apply {
rewind()
val waveShiftPx = waveShift.toPx()
val waveLengthPx = waveLength.toPx()
val waveHeightPx = waveHeight.toPx().absoluteValue
Expand Down

0 comments on commit ed409af

Please sign in to comment.