Skip to content

Commit

Permalink
fix(legacy): All gradient colors being shown. (CCBlueX#4265)
Browse files Browse the repository at this point in the history
  • Loading branch information
mems01 authored Oct 26, 2024
1 parent 855028d commit 0c142d4
Showing 1 changed file with 18 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,22 @@ class ColorSettingsInteger(
private val string = if (name == null) "" else "$name-"
private val max = if (applyMax) 255 else 0

private var red = IntegerValue("${string}R${index ?: ""}", max, 0..255) { generalApply() && (!zeroAlphaCheck || a > 0) }
private var green = IntegerValue("${string}G${index ?: ""}", max, 0..255) { generalApply() && (!zeroAlphaCheck || a > 0) }
private var blue = IntegerValue("${string}B${index ?: ""}", max, 0..255) { generalApply() && (!zeroAlphaCheck || a > 0) }
private var alpha = IntegerValue("${string}Alpha${index ?: ""}", 255, 0..255) { alphaApply ?: generalApply() && withAlpha }
private var red = IntegerValue("${string}R${index ?: ""}",
max,
0..255
) { generalApply() && (!zeroAlphaCheck || a > 0) }
private var green = IntegerValue("${string}G${index ?: ""}",
max,
0..255
) { generalApply() && (!zeroAlphaCheck || a > 0) }
private var blue = IntegerValue("${string}B${index ?: ""}",
max,
0..255
) { generalApply() && (!zeroAlphaCheck || a > 0) }
private var alpha = IntegerValue("${string}Alpha${index ?: ""}",
255,
0..255
) { alphaApply ?: generalApply() && withAlpha }

private var r by red
private var g by green
Expand Down Expand Up @@ -104,12 +116,12 @@ class ColorSettingsInteger(
}
}

fun List<ColorSettingsFloat>.toColorArray(max: Int) = (0 until MAX_GRADIENT_COLORS).map {
fun List<ColorSettingsFloat>.toColorArray(max: Int) = (0 until max).map {
val colors = this[it].color()

floatArrayOf(colors.red.toFloat() / 255f,
colors.green.toFloat() / 255f,
colors.blue.toFloat() / 255f,
if (it > max - 1) 0f else 1f
1f
)
}

0 comments on commit 0c142d4

Please sign in to comment.