Skip to content

Instantly share code, notes, and snippets.

@NikolaDespotoski
Created March 12, 2024 12:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save NikolaDespotoski/700f705639072d213114c19460859ad9 to your computer and use it in GitHub Desktop.
Save NikolaDespotoski/700f705639072d213114c19460859ad9 to your computer and use it in GitHub Desktop.
fun Modifier.curve(
curveColors: CurveColors,
stroke: Stroke,
enabled: Boolean,
points: SnapshotStateList<Point>,
thumbSize: Dp
): Modifier = this then composed {
val fillColor = curveColors.fillColor(enabled = enabled)
val lineColor = curveColors.lineColor(enabled = enabled)
val backgroundColor = Theme.colorScheme.background
val path = remember { Path() }
drawBehind {
if (!path.isEmpty) {
path.reset()
}
path.drawSomething(
stroke = stroke, size = size, points = points.toList()
)
drawPath(path = path, color = lineColor.value, style = stroke)
drawPath(path = path, color = fillColor.value, alpha = 0.4f)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment