From 1d2a5c005bbd83c48b1eca3e12a14388889ee4e0 Mon Sep 17 00:00:00 2001 From: Louca Dufault <40028187+loucadufault@users.noreply.github.com> Date: Fri, 7 Jan 2022 16:03:47 -0500 Subject: [PATCH] improve readme and major bump --- README.md | 16 +++++++++++----- docs/build/README.md | 4 ++-- docs/build/interfaces/Options.md | 8 ++++---- docs/build/modules/internal_.md | 6 +++--- docs/public/README.template.md | 12 +++++++++--- package.json | 2 +- 6 files changed, 30 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index 8b3f532..b9dc07d 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,12 @@ -A lightweight package to generate unique and uniformly sampled colors from UUIDs. +A lightweight package to deterministically generate unique and uniformly sampled colors from UUIDs. -The RGB color space is represented and spanned by hexadecimal numbers in the 0x000000 to 0xffffff range. We can use a simple modulo hash function (`% (0xffffff + 0x000001)` i.e. `% 0x100000`) to return numbers in that range from the decimal representation of the UUID (a base 10 39-digit integer). We then extract the red, green, and blue components from the resulting hash (which represents a specific color in hexadecimal notation) using bit masks. +### How it works -Since the color space is only 255^3 whereas the UUID space is much larger ([approximtely 5.3 x 10^36 possible UUIDs](https://www.uuidtools.com/what-is-uuid#overview)), it is impossible to create a complete bijection between the spaces, and so collisions in the generated color space are more likely to happen. This package does guarantee that the color space is maximally utilized, assuming a uniform distribution of the input UUIDs in the UUID space. +The RGB color space is represented by hexadecimal numbers in the 0x000000 to 0xffffff range. We use a simple modulo hash function (`% (0xffffff + 0x000001)` i.e. `% 0x100000`) to produce numbers in that range from the decimal representation of the UUID (a base 10 39-digit integer). We then extract the red, green, and blue components from the resulting hash (which represents a specific color in hexadecimal notation) using bit masks. + +### Limitations + +Since the color space is only 256^3 whereas the UUID space is much larger ([approximtely 5.3 x 10^36 possible UUIDs](https://www.uuidtools.com/what-is-uuid#overview)), it is impossible to create a complete bijection between the spaces, and so collisions in the generated color space can occur. This package does however guarantee that the color space is maximally utilized, assuming a uniform distribution of the input UUIDs within the UUID space. # Installation: @@ -22,7 +26,9 @@ const myUuid = uuidv4(); const hexColor = colorFromUuid(myUuid); ``` -# Reference - v0.0.5 +[Live demo](https://codesandbox.io/s/uuid-color-usage-o0e4o) + +# Reference - v0.0.7 ## Table of contents @@ -60,4 +66,4 @@ The generated color as a CSS `` notation string #### Defined in -[index.ts:64](https://github.com/loucadufault/uuid-color/blob/2177a9e/src/index.ts#L64) +[index.ts:64](https://github.com/loucadufault/uuid-color/blob/f581a67/src/index.ts#L64) diff --git a/docs/build/README.md b/docs/build/README.md index e455876..a0c2781 100644 --- a/docs/build/README.md +++ b/docs/build/README.md @@ -1,4 +1,4 @@ -# Reference - v0.0.5 +# Reference - v0.0.7 ## Table of contents @@ -36,4 +36,4 @@ The generated color as a CSS `` notation string #### Defined in -[index.ts:64](https://github.com/loucadufault/uuid-color/blob/2177a9e/src/index.ts#L64) +[index.ts:64](https://github.com/loucadufault/uuid-color/blob/f581a67/src/index.ts#L64) diff --git a/docs/build/interfaces/Options.md b/docs/build/interfaces/Options.md index 0bd84c7..18969ad 100644 --- a/docs/build/interfaces/Options.md +++ b/docs/build/interfaces/Options.md @@ -1,4 +1,4 @@ -[Reference - v0.0.5](../README.md) / Options +[Reference - v0.0.7](../README.md) / Options # Interface: Options @@ -25,7 +25,7 @@ Colors are returned as strings in the CSS data type hexadecimal or funct #### Defined in -[index.ts:40](https://github.com/loucadufault/uuid-color/blob/2177a9e/src/index.ts#L40) +[index.ts:40](https://github.com/loucadufault/uuid-color/blob/f581a67/src/index.ts#L40) ___ @@ -42,7 +42,7 @@ Only applies when the specified format is `"hsl"`, as this is the only output fo #### Defined in -[index.ts:30](https://github.com/loucadufault/uuid-color/blob/2177a9e/src/index.ts#L30) +[index.ts:30](https://github.com/loucadufault/uuid-color/blob/f581a67/src/index.ts#L30) ___ @@ -58,4 +58,4 @@ See [the Receivers type](../modules/internal_.md#receivers) for more details. #### Defined in -[index.ts:49](https://github.com/loucadufault/uuid-color/blob/2177a9e/src/index.ts#L49) +[index.ts:49](https://github.com/loucadufault/uuid-color/blob/f581a67/src/index.ts#L49) diff --git a/docs/build/modules/internal_.md b/docs/build/modules/internal_.md index d8862a1..46ec9a8 100644 --- a/docs/build/modules/internal_.md +++ b/docs/build/modules/internal_.md @@ -1,4 +1,4 @@ -[Reference - v0.0.5](../README.md) / +[Reference - v0.0.7](../README.md) / # Namespace: @@ -25,7 +25,7 @@ #### Defined in -[index.ts:15](https://github.com/loucadufault/uuid-color/blob/2177a9e/src/index.ts#L15) +[index.ts:15](https://github.com/loucadufault/uuid-color/blob/f581a67/src/index.ts#L15) ___ @@ -35,4 +35,4 @@ ___ #### Defined in -[index.ts:13](https://github.com/loucadufault/uuid-color/blob/2177a9e/src/index.ts#L13) +[index.ts:13](https://github.com/loucadufault/uuid-color/blob/f581a67/src/index.ts#L13) diff --git a/docs/public/README.template.md b/docs/public/README.template.md index dc2550b..b367ebe 100644 --- a/docs/public/README.template.md +++ b/docs/public/README.template.md @@ -1,8 +1,12 @@ -A lightweight package to generate unique and uniformly sampled colors from UUIDs. +A lightweight package to deterministically generate unique and uniformly sampled colors from UUIDs. -The RGB color space is represented and spanned by hexadecimal numbers in the 0x000000 to 0xffffff range. We can use a simple modulo hash function (`% (0xffffff + 0x000001)` i.e. `% 0x100000`) to return numbers in that range from the decimal representation of the UUID (a base 10 39-digit integer). We then extract the red, green, and blue components from the resulting hash (which represents a specific color in hexadecimal notation) using bit masks. +### How it works -Since the color space is only 255^3 whereas the UUID space is much larger ([approximtely 5.3 x 10^36 possible UUIDs](https://www.uuidtools.com/what-is-uuid#overview)), it is impossible to create a complete bijection between the spaces, and so collisions in the generated color space are more likely to happen. This package does guarantee that the color space is maximally utilized, assuming a uniform distribution of the input UUIDs in the UUID space. +The RGB color space is represented by hexadecimal numbers in the 0x000000 to 0xffffff range. We use a simple modulo hash function (`% (0xffffff + 0x000001)` i.e. `% 0x100000`) to produce numbers in that range from the decimal representation of the UUID (a base 10 39-digit integer). We then extract the red, green, and blue components from the resulting hash (which represents a specific color in hexadecimal notation) using bit masks. + +### Limitations + +Since the color space is only 256^3 whereas the UUID space is much larger ([approximtely 5.3 x 10^36 possible UUIDs](https://www.uuidtools.com/what-is-uuid#overview)), it is impossible to create a complete bijection between the spaces, and so collisions in the generated color space can occur. This package does however guarantee that the color space is maximally utilized, assuming a uniform distribution of the input UUIDs within the UUID space. # Installation: @@ -22,4 +26,6 @@ const myUuid = uuidv4(); const hexColor = colorFromUuid(myUuid); ``` +[Live demo](https://codesandbox.io/s/uuid-color-usage-o0e4o) + {{/docs/build/README.md}} \ No newline at end of file diff --git a/package.json b/package.json index a0c1c4c..c8448ce 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "uuid-color", - "version": "0.0.7", + "version": "0.1.0", "description": "A lightweight package to generate unique and uniformly sampled colors from UUIDs.", "main": "lib/index.js", "scripts": {