라이브 룰렛 색상 변경
AS-IS : 10가지 색상 순서 대로 표시 TO-BE : 10가지 색상 중 랜덤 으로 표시
This commit is contained in:
parent
3d231ea8be
commit
5da644a607
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue