🎨 ColorAPI
ColorAPI is an ultra-lightweight, high-performance mathematical and chromatic animation library designed for modern Minecraft Fabric (1.21.11+). It decouples pure color algebra and timing curves from complex rendering engines, providing a clean, reusable foundation for colored lighting, GUI widgets, particle systems, and cosmetic tinting.
⚡ Core Features
- 🌈 Comprehensive Color Spaces:
* Immutable
ColorRGBrecord supporting sRGB, Linear spaces, gamma correction, alpha channels, and packed ARGB/RGB conversions. *ColorHSVrecord with robust bidirectional RGB \(\leftrightarrow\) HSV mapping. - 🧮 Pure Chromatic Algebra (
ColorMath): * Weighted multi-source color blending (blendColors). * Clamped linear interpolation (lerp). * Photometric attenuation modulation (modulate). * Additive light accumulation (additiveAccumulate). - 📈 Rich Easing & Animation Engine (
EasingMath): * Easing curves: Linear, Ease In/Out, Ease In-Out, Quadratic, Cubic, Sine, Exponential, Bounce, Elastic, and Step. * Temporal transition controller (ColorTransition) for smooth tick-to-tick or frame-to-frame color fading. - 📦 Decoupled Data Structures:
* Standardized
Keyframe,Sequence, andProfilerecords for sequencing complex multi-stage color animations. - 🖼️ Texture & Asset Color Extraction: * Native utilities for calculating dominant/average colors from block sprites and textures.
💻 Developer Quick Start
Add ColorAPI to your build.gradle:
repositories {
mavenCentral()
// or mavenLocal() if building from source
}
dependencies {
modImplementation "mb.bartra:colorapi:1.0"
}
Basic Color Interpolation & Blending:
import mb.bartra.colorapi.ColorAPI;
import mb.bartra.colorapi.core.ColorRGB;
import mb.bartra.colorapi.core.ColorMath;
// 1. Simple Lerp between two hex colors
int startColor = 0xFF0000; // Red
int endColor = 0x0000FF; // Blue
int blended = ColorAPI.lerp(startColor, endColor, 0.5f); // Purple
// 2. Linear Color Modulation
ColorRGB light = ColorRGB.fromRgb(0xFFAA00);
ColorRGB shaded = light.toLinear().multiply(0.75f).toSrgb();
📄 License
ColorAPI is distributed under the open-source MIT License. Free for personal use, modpacks, and third-party mod integrations.

