Skip to content

Instantly share code, notes, and snippets.

@Ahmed-Sellami
Last active September 15, 2021 15:49
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 Ahmed-Sellami/28a86c03cf478b004706ec484014a4cd to your computer and use it in GitHub Desktop.
Save Ahmed-Sellami/28a86c03cf478b004706ec484014a4cd to your computer and use it in GitHub Desktop.
fun drawFunnel(upperRadius: Float, lowerRadius: Float, width: Float): Path {
return Path().apply {
// Top arc
arcTo(
rect = Rect(
left = -lowerRadius,
top = -upperRadius - lowerRadius,
right = width * 2 - lowerRadius,
bottom = upperRadius - lowerRadius
),
startAngleDegrees = 180.0f,
sweepAngleDegrees = -90.0f,
forceMoveTo = false
)
// Bottom arc
arcTo(
rect = Rect(
left = -lowerRadius,
top = upperRadius + lowerRadius,
right = width * 2 - lowerRadius,
bottom = upperRadius * 3 + lowerRadius
),
startAngleDegrees = 270.0f,
sweepAngleDegrees = -90.0f,
forceMoveTo = false
)
close()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment