라이브 룰렛 색상 변경

AS-IS : 10가지 색상 순서 대로 표시
TO-BE : 10가지 색상 중 랜덤 으로 표시
This commit is contained in:
klaus 2023-12-26 21:57:31 +09:00
parent 3d231ea8be
commit 5da644a607
1 changed files with 2 additions and 1 deletions

View File

@ -77,9 +77,10 @@ class RouletteView @JvmOverloads constructor(
val totalWeight = items.asSequence().map { it.weight }.sum()
var startAngle = -90f
val shuffledColors = colors.shuffled()
items.forEachIndexed { index, (option, weight) ->
val sweepAngle = (weight / totalWeight.toFloat()) * 360f
fillPaint.color = colors[index]
fillPaint.color = shuffledColors[index]
canvas.drawArc(rect, startAngle, sweepAngle, true, fillPaint)
drawOptionText(canvas, option, startAngle, sweepAngle)