Skip to content

Commit

Permalink
better docs intro
Browse files Browse the repository at this point in the history
  • Loading branch information
loucadufault committed Jan 7, 2022
1 parent 30a3faf commit 27acf31
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 11 deletions.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
A lightweight package to generate unique and uniformly sampled colors from UUIDs.

Since the color space is only 255^3 whereas the uuid space is much larger, it is impossible to create a complete bijection, and collisions in the generated color space are more likely to happen.
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.

Since the color space is only 255^3 whereas the UUID space is much larger (5.3 x 10^36 possible UUIDs), it is impossible to create a complete bijection, and collisions in the generated color space are more likely to happen.

# Installation:

Expand Down Expand Up @@ -58,4 +60,4 @@ The generated color as a CSS `<color>` notation string

#### Defined in

[index.ts:64](https://github.com/loucadufault/uuid-color/blob/79f3e41/src/index.ts#L64)
[index.ts:64](https://github.com/loucadufault/uuid-color/blob/30a3faf/src/index.ts#L64)
2 changes: 1 addition & 1 deletion docs/build/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,4 @@ The generated color as a CSS `<color>` notation string

#### Defined in

[index.ts:64](https://github.com/loucadufault/uuid-color/blob/79f3e41/src/index.ts#L64)
[index.ts:64](https://github.com/loucadufault/uuid-color/blob/30a3faf/src/index.ts#L64)
8 changes: 4 additions & 4 deletions docs/build/interfaces/Options.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@ Colors are returned as strings in the CSS <color> data type hexadecimal or funct

#### Defined in

[index.ts:40](https://github.com/loucadufault/uuid-color/blob/79f3e41/src/index.ts#L40)
[index.ts:40](https://github.com/loucadufault/uuid-color/blob/30a3faf/src/index.ts#L40)

___

### raw

`Optional` **raw**: `boolean`

Determines whether the generated color components will be rounded.
Determines whether to skip rounding the generated color components.

**`remarks`**
Only applies when the specified format is `"hsl"`, as this is the only output format that involves a lossy conversion (from RGB model components).
Expand All @@ -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/79f3e41/src/index.ts#L30)
[index.ts:30](https://github.com/loucadufault/uuid-color/blob/30a3faf/src/index.ts#L30)

___

Expand All @@ -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/79f3e41/src/index.ts#L49)
[index.ts:49](https://github.com/loucadufault/uuid-color/blob/30a3faf/src/index.ts#L49)
4 changes: 2 additions & 2 deletions docs/build/modules/internal_.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

#### Defined in

[index.ts:15](https://github.com/loucadufault/uuid-color/blob/79f3e41/src/index.ts#L15)
[index.ts:15](https://github.com/loucadufault/uuid-color/blob/30a3faf/src/index.ts#L15)

___

Expand All @@ -35,4 +35,4 @@ ___

#### Defined in

[index.ts:13](https://github.com/loucadufault/uuid-color/blob/79f3e41/src/index.ts#L13)
[index.ts:13](https://github.com/loucadufault/uuid-color/blob/30a3faf/src/index.ts#L13)
4 changes: 3 additions & 1 deletion docs/public/README.template.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
A lightweight package to generate unique and uniformly sampled colors from UUIDs.

Since the color space is only 255^3 whereas the uuid space is much larger, it is impossible to create a complete bijection, and collisions in the generated color space are more likely to happen.
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.

Since the color space is only 255^3 whereas the UUID space is much larger (5.3 x 10^36 possible UUIDs), it is impossible to create a complete bijection, and collisions in the generated color space are more likely to happen.

# Installation:

Expand Down
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ type Receivers = {

export interface Options {
/**
* Determines whether the generated color components will be rounded.
* Determines whether to skip rounding the generated color components.
*
* @remarks
* Only applies when the specified format is `"hsl"`, as this is the only output format that involves a lossy conversion (from RGB model components).
Expand Down

0 comments on commit 27acf31

Please sign in to comment.