Skip to content

Instantly share code, notes, and snippets.

@aqua30
Created March 6, 2022 19:15
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 aqua30/3c70a6d7dd5e3462094139ab64be3624 to your computer and use it in GitHub Desktop.
Save aqua30/3c70a6d7dd5e3462094139ab64be3624 to your computer and use it in GitHub Desktop.
Function of view class
override fun onSizeChanged(w: Int, h: Int, oldw: Int, oldh: Int) {
super.onSizeChanged(w, h, oldw, oldh)
/* curve from P1 to P2 */
leftArc.set(
0f,
0f,
xAxisOffset,
yAxisOffset
)
path.addArc(leftArc, 180f, 90f)
/* line from P2 to P3 */
path.lineTo(w.toFloat() - (xAxisOffset * 0.5f), 0f)
/* curve from P3 to P4 */
rightArc.set(
w.toFloat() - (xAxisOffset),
0f,
w.toFloat(),
yAxisOffset
)
path.addArc(rightArc, 270f, 90f)
/* line from P4 to P5 */
path.lineTo(w.toFloat(), h.toFloat())
/* line from P5 to P6 */
path.lineTo(0f, h.toFloat())
/* line from P6 to P1 */
path.lineTo(0f, yAxisOffset - (yAxisOffset / 2))
path.close()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment