Skip to content

Commit ed409af

Browse files
committed
Reuse and rewind the same path for the wave
Resolves #4
1 parent dfba104 commit ed409af

File tree

1 file changed

+3
-1
lines changed
  • library/src/commonMain/kotlin/ir/mahozad/multiplatform/wavyslider

1 file changed

+3
-1
lines changed

library/src/commonMain/kotlin/ir/mahozad/multiplatform/wavyslider/Core.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ data class WaveAnimationSpecs(
107107
*/
108108
typealias WaveVelocity = Pair<Dp, WaveDirection>
109109

110+
private val wavyPath = Path()
110111
internal val defaultIncremental = false
111112
internal val defaultWaveLength = 20.dp
112113
internal val defaultWaveHeight = 6.dp
@@ -177,7 +178,8 @@ internal inline fun DrawScope.createWavyPath(
177178
waveSpread: Float,
178179
waveShift: Dp,
179180
incremental: Boolean
180-
): Path = Path().apply {
181+
): Path = wavyPath.apply {
182+
rewind()
181183
val waveShiftPx = waveShift.toPx()
182184
val waveLengthPx = waveLength.toPx()
183185
val waveHeightPx = waveHeight.toPx().absoluteValue

0 commit comments

Comments
 (0)