Skip to content

wimaengine/marangi

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

  • Color stores r, g, b, a in linear RGBA color space
  • Direct construction and mutation via set
  • Explicit duplication via copy and clone

Arithmetic & Transforms

  • add: component-wise addition
  • lighten / darken: scalar adjustments
  • lerp: linear interpolation between colors
  • random: randomized color generation

Static Utilities

  • Non-mutating equivalents for common operations
  • Suitable for functional-style pipelines

Constants

Predefined color constants:

  • black
  • white
  • red
  • green
  • blue
  • yellow
  • purple
  • cyan

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.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors