Skip to content

Commit

Permalink
feat: colorvalue
Browse files Browse the repository at this point in the history
  • Loading branch information
opZywl committed Dec 30, 2024
1 parent 6ac0ad9 commit 0902cf5
Showing 1 changed file with 37 additions and 1 deletion.
38 changes: 37 additions & 1 deletion src/main/java/net/ccbluex/liquidbounce/config/Value.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
*/
package net.ccbluex.liquidbounce.config

import com.google.gson.JsonArray
import com.google.gson.JsonElement
import com.google.gson.JsonObject
import com.google.gson.JsonPrimitive
Expand All @@ -17,6 +16,7 @@ import net.ccbluex.liquidbounce.utils.client.ClientUtils.LOGGER
import net.ccbluex.liquidbounce.utils.kotlin.RandomUtils.nextFloat
import net.ccbluex.liquidbounce.utils.kotlin.RandomUtils.nextInt
import net.minecraft.client.gui.FontRenderer
import java.awt.Color
import kotlin.properties.ReadWriteProperty
import kotlin.reflect.KProperty

Expand Down Expand Up @@ -419,6 +419,42 @@ open class NumberValue(
}
}

class ColorValue(
val nameVal: String,
initialColor: Color,
val module: Any?
) {
var hue = 0f
var saturation = 1f
var brightness = 1f
var alpha = 1f
var rainbow = false

init {
set(initialColor)
}

fun get(): Color {
val base = Color.getHSBColor(hue, saturation, brightness)
val finalAlpha = (alpha * 255).toInt().coerceIn(0, 255)
return Color(base.red, base.green, base.blue, finalAlpha)
}

fun set(color: Color) {
val hsb = Color.RGBtoHSB(color.red, color.green, color.blue, null)
hue = hsb[0]
saturation = hsb[1]
brightness = hsb[2]
alpha = color.alpha / 255f
}
}

val customBgColorValue = ColorValue(
"CustomBG",
Color(32, 32, 64),
null
)


fun int(
name: String,
Expand Down

0 comments on commit 0902cf5

Please sign in to comment.