Slide 13
Slide 13 text
実践(コード)
override fun draw(canvas: Canvas) {
super.draw(canvas)
canvas.drawPath(clearPath, clearPaint)
}
/** 塗りつぶし(消去)用の Paintを作成 */
private val clearPaint = Paint().apply {
isAntiAlias = true
xfermode = PorterDuffXfermode(PorterDuff.Mode.CLEAR)
}
/** 矩形角丸範囲外を表す Pathを作成 */
private val clearPath
get() = Path().apply {
// Canvasサイズと縦横幅が同じで、角丸加工した RoundRectを設定
addRoundRect(canvasRect, cornerRadius, cornerRadius, Path.Direction.CW)
// RoundRectの範囲外部分を塗りつぶし対象とする
fillType = Path.FillType.INVERSE_WINDING
}
->