marangi
v0.1.0
Published
Marangi is a lightweight utility library for working with colors.
Readme
Marangi
Marangi is a lightweight utility library for working with colors.
Design
- Normalized representation: all channels (
r,g,b,a) are floats in[0, 1] - Dual API surface
- Instance methods for in-place mutation
- Static methods for non-mutating operations
- Value semantics: explicit
copy/clone, no implicit duplication - Iterable: colors can be destructured or iterated as
[r, g, b, a]
Features
Core
Colorstoresr,g,b,ain linear RGBA color space- Direct construction and mutation via
set - Explicit duplication via
copyandclone
Arithmetic & Transforms
add: component-wise additionlighten/darken: scalar adjustmentslerp: linear interpolation between colorsrandom: randomized color generation
Static Utilities
- Non-mutating equivalents for common operations
- Suitable for functional-style pipelines
Constants
Predefined color constants:
blackwhiteredgreenblueyellowpurplecyan
Example
import { Color } from 'marangi';
const a = new Color(1, 0, 0, 1); // red
const b = new Color(0, 0, 1, 1); // blue
// interpolate (mutates a)
a.lerp(b, 0.5);
// clone
const c = a.clone();
// iterate
for (const channel of c) {
console.log(channel);
}Usage
TODO
Notes
- All operations assume normalized input; values are not implicitly clamped.
- Prefer static methods when immutability is required.
