Mutable Color
class MutableColor
A mutable color that automatically updates it's RGB and HSL values based on new inputs. Generally this should be created from a ColorHolder, not instantiated directly
Author
fzzyhmstrs
Since
0.2.0
Parameters
hex
ValidatedString - defines the correction used on the hex string internally.
alpha Mode
whether this classes parent supports transparency or not, passes this on to any new holders it creates
Samples
import me.fzzyhmstrs.fzzy_config.util.AllowableIdentifiers
import me.fzzyhmstrs.fzzy_config.util.EnumTranslatable
import me.fzzyhmstrs.fzzy_config.util.FcText.lit
import me.fzzyhmstrs.fzzy_config.util.ValidationResult
import me.fzzyhmstrs.fzzy_config.validation.collection.ValidatedList
import me.fzzyhmstrs.fzzy_config.validation.minecraft.ValidatedIdentifier
import me.fzzyhmstrs.fzzy_config.validation.minecraft.ValidatedRegistryType
import me.fzzyhmstrs.fzzy_config.validation.minecraft.ValidatedTagKey
import me.fzzyhmstrs.fzzy_config.validation.misc.*
import me.fzzyhmstrs.fzzy_config.validation.misc.ValidatedColor.Companion.validatedColor
import me.fzzyhmstrs.fzzy_config.validation.number.ValidatedInt
import net.minecraft.item.Items
import net.minecraft.item.SwordItem
import net.minecraft.registry.Registries
import net.minecraft.registry.tag.ItemTags
import net.minecraft.util.Identifier
import java.awt.Color
import java.util.function.Function
fun main() {
//sampleStart
//generate a color holder from a ValidatedColor wrapper
val validatedColor: ValidatedColor = ValidatedColor(255, 128, 0, 255)
// the wrapped ColorHolder
val holder: ValidatedColor.ColorHolder = validatedColor.get()
//we can get color values from it
val r: Int = holder.r //255
val g: Int = holder.g //128
val argb: Int = holder.argb()
//color holders are immutable, we can mutate them via a MutableColor though
val mutable: ValidatedColor.MutableColor = holder.mutable()
//update the RGB to something new
mutable.updateRGB(128, 0, 128)
//the colors HSL is automatically updated too
val h = mutable.h
val l = mutable.l
// once we are done, we can update our ValidatedColor
validatedColor.validateAndSet(mutable.createHolder())
//sampleEnd
}