라이브 방 룰렛 - 컬러 변경
This commit is contained in:
parent
7da0e2509c
commit
fb9c138eb4
|
@ -910,7 +910,7 @@ class LiveRoomViewModel(
|
|||
|
||||
val rouletteItems = mutableListOf<String>()
|
||||
items.asSequence().forEach { item ->
|
||||
repeat(item.weight) {
|
||||
repeat(item.weight * 10) {
|
||||
rouletteItems.add(item.title)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,9 +32,9 @@ class RouletteInvertedTriangle @JvmOverloads constructor(
|
|||
|
||||
// Define the new path for the inverted triangle
|
||||
// Starting point (top of the triangle)
|
||||
trianglePath.moveTo((width / 2f) - 30, 10f)
|
||||
trianglePath.moveTo((width / 2f) - 30, -10f)
|
||||
// Line to bottom left of the triangle
|
||||
trianglePath.lineTo((width / 2f) + 30, 10f)
|
||||
trianglePath.lineTo((width / 2f) + 30, -10f)
|
||||
// Line to bottom right of the triangle
|
||||
trianglePath.lineTo(width / 2f, 10f + triangleSize)
|
||||
// Close the path to form a triangle
|
||||
|
|
|
@ -20,8 +20,6 @@ class RouletteView @JvmOverloads constructor(
|
|||
) : View(context, attrs, defStyleAttr) {
|
||||
private var rect = RectF()
|
||||
|
||||
|
||||
private val bgPaint = Paint()
|
||||
private val fillPaint = Paint()
|
||||
private val textPaint = Paint()
|
||||
private val strokePaint = Paint()
|
||||
|
@ -29,23 +27,17 @@ class RouletteView @JvmOverloads constructor(
|
|||
var items = listOf<RouletteItem>()
|
||||
|
||||
private val colors = listOf(
|
||||
Color.parseColor("#e6548f7d"),
|
||||
Color.parseColor("#e62d7390"),
|
||||
Color.parseColor("#e64d6aa4"),
|
||||
Color.parseColor("#e659548f"),
|
||||
Color.parseColor("#e6d38c38"),
|
||||
Color.parseColor("#e6d85e37"),
|
||||
Color.parseColor("#F5D55A"),
|
||||
Color.parseColor("#E4813B"),
|
||||
Color.parseColor("#E6AAC1"),
|
||||
Color.parseColor("#8FCEEA"),
|
||||
Color.parseColor("#CD5880"),
|
||||
Color.parseColor("#C2C85E"),
|
||||
)
|
||||
|
||||
init {
|
||||
bgPaint.apply {
|
||||
color = Color.WHITE
|
||||
style = Paint.Style.FILL
|
||||
isAntiAlias = true
|
||||
}
|
||||
|
||||
strokePaint.apply {
|
||||
color = Color.BLACK
|
||||
color = Color.WHITE
|
||||
style = Paint.Style.STROKE
|
||||
strokeWidth = 10f
|
||||
isAntiAlias = true
|
||||
|
@ -77,18 +69,17 @@ class RouletteView @JvmOverloads constructor(
|
|||
|
||||
override fun onDraw(canvas: Canvas) {
|
||||
super.onDraw(canvas)
|
||||
canvas.drawCircle(rect.centerX(), rect.centerY(), rect.width() / 2, bgPaint)
|
||||
|
||||
val totalWeight = items.asSequence().map { it.weight }.sum()
|
||||
var startAngle = -90f
|
||||
|
||||
items.forEachIndexed { index, (option, weight) ->
|
||||
val sweepAngle = (weight / totalWeight.toFloat()) * 360f - 1
|
||||
val sweepAngle = (weight / totalWeight.toFloat()) * 360f
|
||||
fillPaint.color = colors[index]
|
||||
canvas.drawArc(rect, startAngle, sweepAngle, true, fillPaint)
|
||||
|
||||
drawOptionText(canvas, option, startAngle, sweepAngle)
|
||||
startAngle += sweepAngle + 1
|
||||
startAngle += sweepAngle
|
||||
}
|
||||
|
||||
canvas.drawCircle(rect.centerX(), rect.centerY(), rect.width() / 2, strokePaint)
|
||||
|
|
Loading…
Reference in New Issue