Color Holder
An immutable holder of an ARGB color value. The return type of ValidatedColor, which can be used directly in code or shortcutted with helper functions in ValdiatedColor to get Int or Hex String values instead.
Author
fzzyhmstrs
Since
0.2.0
Parameters
int value of r component (0..255)
int value of g component (0..255)
int value of b component (0..255)
int value of a component (0..255)
whether this color holder supports transparency
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
}
Constructors
Properties
Functions
Copies the provided input as deeply as possible.
Specialized equals
method for determining if a newly deserialized value is effectively equal to its old counterpart.
converts this color holder into a new one representing the color integer passed. AlphaMode is maintained
Creates a deep copy of this color holder and wraps it
Generates a MutableColor from this color holder
converts this color holder to a hex string (without prefix)
If this color holder supports transparency