-
Notifications
You must be signed in to change notification settings - Fork 56
Colors
Color objects in several color spaces, so operations like mixing and brightening actually look right.
Mixing two colors as raw RGB gives muddy results, and "make this 20% brighter" in RGB isn't what your eye means by brighter. These classes convert between RGB, HSV, HSL, LAB, LUV, HCL, HCLV and XYZ, and every operation happens in the space you picked.
This is what makes the texture respriter produce usable palettes.
public static RGBColor modifyColor(RGBColor color) {
LABColor lab = color.asLAB();
LABColor pureRed = new RGBColor(1, 0, 0, 1).asLAB();
// mixing in LAB, which looks right, unlike mixing in RGB
lab.mixWith(pureRed, 0.2f);
lab.withLuminance(0.4f);
return lab.asRGB();
}Every class extends BaseColor and has the same shape: component accessors, withX(...),
mixWith, and asRGB() / asLAB() / ... to convert. Components are floats from 0 to 1.
Example: RGBColorExample
ColorUtils for packed int colors: pack and unpack, hex parsing (its codec accepts both
"#ff0000" and a number, which is what config and json color fields use), and the usual
conversions.
KMeans clusters a set of colors, used to reduce an image to a small palette.
Basics Platform Helpers Registration Networking Events Configs Config Screen
Resources Runtime Resource Packs Texture Manipulation Resource Helpers Block Set API
Client Custom Models Item Rendering Rendered Textures Post Shaders GUI Toolkit Colors
World Block and Item Interfaces Additional Item Placements Improved Entities Fake Levels World Data Dispenser Behaviors
Utilities Codec Utilities Misc Helpers Commands
Datapacks Villagers Soft Fluids Map Markers Spawn Boxes Global Datapack Folder