xcolor-rgb-convert
v1.0.0
Published
Framework-agnostic color parsers/converters and deterministic RGB to xcolor expression conversion
Maintainers
Readme
xcolor-rgb-convert
Framework-agnostic color parsing and conversion utilities, plus deterministic RGB to LaTeX xcolor expression conversion.
Install
npm install xcolor-rgb-convertAPI
import {
rgbToXcolorExpression,
parseColorInput,
hslToRgb,
hsvToRgb,
rgbToHex,
hexToRgb,
XCOLOR_BASE_COLORS
} from "xcolor-rgb-convert";rgbToXcolorExpression(target, options)
Converts RGB byte color input to an xcolor expression.
- deterministic output for identical inputs/options
mode: "drag" | "release"for speed/accuracy tradeoff- supports up to three mixes (with optional white-tail exact mode)
parseColorInput(raw)
Parses generic color text to RGB + hex.
Supported forms:
- hex:
#rgb,#rgba,#rrggbb,#rrggbbaa - function syntax:
rgb(...),rgba(...),hsl(...),hsla(...),hsv(...),hsva(...),hsb(...),hsba(...) - bare triplets:
255 128 0,255,128,0
Alpha channels are accepted but ignored and returned with a warning.
Utility helpers
hslToRgb(h, s, l)hsvToRgb(h, s, v)rgbToHex({r,g,b})hexToRgb(raw)
Notes
- This package is intentionally generic and non-TikZ-semantic.
- TikZ/xcolor alias resolution,
\definecolormodel handling, and style semantics are out of scope for v1.
Playground
- A static demo lives in
playground/. - It demonstrates both:
rgbToXcolorExpressioninteractive conversion flowparseColorInputand helper conversions (rgbToHex,hexToRgb,hslToRgb,hsvToRgb)
- Repository: github.com/DominikPeters/xcolor-rgb-convert
- GitHub Pages demo URL: dominikpeters.github.io/xcolor-rgb-convert/playground/
