@daeinc/color
Advanced tools
Comparing version 0.2.3 to 0.2.4
{ | ||
"name": "@daeinc/color", | ||
"version": "0.2.3", | ||
"version": "0.2.4", | ||
"description": "Color utilities", | ||
@@ -5,0 +5,0 @@ "types": "./dist/index.d.ts", |
107
README.md
@@ -5,36 +5,20 @@ # @daeinc/color | ||
`npm i @daeinc/color` | ||
```sh | ||
npm i @daeinc/color | ||
``` | ||
then, | ||
```ts | ||
import { hsv2rgb, ... } from "@daeinc/color" | ||
``` | ||
## Functions | ||
### hsv2rgb | ||
```ts | ||
/** | ||
* convert normalized grayscale value to RGB | ||
* @param val grayscale value 0..1 | ||
* @returns RGB color array[3] in 0..255 | ||
*/ | ||
export declare function hsv2rgb(val: number): number[]; | ||
/** | ||
* convert normalized HSB color to RGB | ||
* @param arr [h, s, v] or [h, s, v, a] | ||
* @returns RGB color array[3 or 4] in 0..255 | ||
*/ | ||
export declare function hsv2rgb(arr: number[]): number[]; | ||
/** | ||
* convert normalized HSB color to RGB | ||
* @param h normalized hue 0..1 (wrapped) | ||
* @param s normalized saturation 0..1 (clamped) | ||
* @param v normalized brightness 0..1 (clamped) | ||
* @returns RGB color array[3] in 0..255 | ||
*/ | ||
export declare function hsv2rgb(h: number, s: number, v: number): number[]; | ||
/** | ||
* convert normalized HSB color to RGB | ||
* @param h normalized hue 0..1 (wrapped) | ||
* @param s normalized saturation 0..1 (clamped) | ||
* @param v normalized brightness 0..1 (clamped) | ||
* @param a alpha 0..1 passed-through | ||
* @returns RGB color array[4] in 0..255 | ||
*/ | ||
export declare function hsv2rgb( | ||
function hsv2rgb(val: number): number[]; | ||
function hsv2rgb(arr: number[]): number[]; | ||
function hsv2rgb(h: number, s: number, v: number): number[]; | ||
function hsv2rgb( | ||
h: number, | ||
@@ -45,26 +29,24 @@ s: number, | ||
): number[]; | ||
export declare const hsb2rgb: typeof hsv2rgb; | ||
/** | ||
* convert RGB color to normalized HSV | ||
* @param arr [r, g, b] or [r, g, b, a] | ||
* @returns HSV color array[3 or 4] in 0..1 | ||
*/ | ||
export declare function rgb2hsv(arr: number[]): number[]; | ||
/** | ||
* convert RGB color to normalized HSV | ||
* @param r red 0..255 | ||
* @param g green 0..255 | ||
* @param b blue 0..255 | ||
* @returns HSV color array[3] in 0..1 | ||
*/ | ||
export declare function rgb2hsv(r: number, g: number, b: number): number[]; | ||
/** | ||
* convert RGB color to normalized HSV | ||
* @param r red 0..255 | ||
* @param g green 0..255 | ||
* @param b blue 0..255 | ||
* @param a alpha 0..1 | ||
* @returns HSV color array[4] in 0..1 | ||
*/ | ||
export declare function rgb2hsv( | ||
``` | ||
Converts HSV/HSB color to RGB. Each channel of the input HSV color must be normalized to `[0, 1]` range. | ||
A typical usage is as follows: | ||
```ts | ||
ctx.strokeStyle = `rgb(${hsv2rgb(0, 1, 1)})` // red | ||
``` | ||
### hsb2rgb | ||
```ts | ||
const hsb2rgb: typeof hsv2rgb; | ||
``` | ||
Alias for `hsv2rgb`. | ||
### rgb2hsv | ||
```ts | ||
function rgb2hsv(arr: number[]): number[]; | ||
function rgb2hsv(r: number, g: number, b: number): number[]; | ||
function rgb2hsv( | ||
r: number, | ||
@@ -75,13 +57,12 @@ g: number, | ||
): number[]; | ||
/** | ||
* converts hexadecimal color to RGB/RGBA. | ||
* | ||
* It also supports shorthand hex color with alpha - ex. #f0ac (last char is alpha) | ||
* @param hex hex color string. ex. `#f0a`, `#ccfa`, `#ff00cc` or `#aacc99ff` | ||
* @returns [r, g, b] or [r, g, b, a] | ||
*/ | ||
export declare function hex2rgb(hex: string): number[]; | ||
//# sourceMappingURL=index.d.ts.map | ||
``` | ||
Converts RGB color to HSV. The out color is normalized to `[0, 1]` range. | ||
### hex2rgb | ||
```ts | ||
function hex2rgb(hex: string): number[]; | ||
``` | ||
Converts HEX color string to RGB color. | ||
## To dos | ||
@@ -88,0 +69,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
13870
77