Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/retraigo/colors
Color conversion and stuff in TypeScript
https://github.com/retraigo/colors
Last synced: about 2 months ago
JSON representation
Color conversion and stuff in TypeScript
- Host: GitHub
- URL: https://github.com/retraigo/colors
- Owner: retraigo
- License: mit
- Created: 2022-12-10T10:16:28.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2024-09-14T03:57:43.000Z (3 months ago)
- Last Synced: 2024-10-11T20:57:11.221Z (2 months ago)
- Language: TypeScript
- Size: 77.1 KB
- Stars: 5
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-deno - colors - Color conversions and operations in TypeScript. (Modules / Utils)
README
# colors
Color conversion, shade/tint generation, color quantization, and more in TypeScript
**Note: All methods either accept RGB/RGBA colors as parameters or give RGB/RGBA colors as results. In order to work with other color spaces (eg. XYZ), convert them to RGB first.**
## Installation
If you are using NodeJS, an extra installation step is required.
```sh
# NPM
$ npx jsr add @retraigo/colors
# PNPM
$ pnpm dlx jsr add @retraigo/colors
```## Usage
For browser usage, use a bundler.
For Node/Deno usage, refer below.
```ts
// Deno /x
import { rgbaFromHex, xyz, lab } from "https://deno.land/x/colors/mod.ts";// Deno JSR
import { rgbaFromHex, xyz, lab } from "jsr:@retraigo/colors";// Node JSR (after installation)
import { rgbaFromHex, xyz, lab } from "jsr:@retraigo/colors";const color = rgbaFromHex("#fceff1");
// CIE XYZ color space
console.log(xyz(color));// CIE LAB color space
console.log(lab(color));// Conversion of color into all supported spaces
console.log(json(color));
```Refer [jsr:@retraigo/colors](https://jsr.io/@retraigo/colors) for documentation.