Skip to content

Commit 3358241

Browse files
update GooeyEffectDemo
1 parent 85cba1d commit 3358241

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

app/src/main/java/com/smarttoolfactory/composeprogressindicator/GooeyEffectDemo.kt

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import androidx.compose.ui.graphics.drawscope.Stroke
1515
import androidx.compose.ui.input.pointer.pointerInput
1616
import androidx.compose.ui.unit.dp
1717

18-
18+
// TODO Add bezier curves to have shake/wobble effect when circles are separated
1919
@Composable
2020
fun GooeyEffectSampleStroke(
2121
modifier: Modifier = Modifier
@@ -50,6 +50,9 @@ fun GooeyEffectSampleStroke(
5050
}
5151
.fillMaxSize()
5252

53+
val cornerPathEffect = remember {
54+
PathEffect.cornerPathEffect(50f)
55+
}
5356

5457
Canvas(modifier = drawModifier) {
5558

@@ -67,34 +70,31 @@ fun GooeyEffectSampleStroke(
6770
)
6871
)
6972

70-
pathStatic.reset()
71-
pathStatic.addOval(
72-
Rect(
73-
center = Offset(center.x, center.y),
74-
radius = 100f
73+
if(pathStatic.isEmpty){
74+
pathStatic.addOval(
75+
Rect(
76+
center = Offset(center.x, center.y),
77+
radius = 100f
78+
)
7579
)
76-
)
80+
}
7781

82+
pathMeasure.setPath(pathDynamic, true)
7883
val discretePathEffect = DiscretePathEffect(pathMeasure.length / segmentCount, 0f)
79-
val cornerPathEffect = PathEffect.cornerPathEffect(50f)
80-
8184

8285
val chainPathEffect = PathEffect.chainPathEffect(
8386
outer = cornerPathEffect,
8487
inner = discretePathEffect.toComposePathEffect()
8588
)
8689

8790
pathDynamic.op(pathDynamic, pathStatic, PathOperation.Union)
88-
pathMeasure.setPath(pathDynamic, true)
8991

9092
drawPath(
9193
path = pathDynamic,
9294
brush = brush,
9395
style = Stroke(4.dp.toPx(), pathEffect = chainPathEffect)
9496
)
95-
9697
}
97-
9898
}
9999

100100
@Composable

0 commit comments

Comments
 (0)