An open API service indexing awesome lists of open source software.

https://github.com/ianfabs/cs-rcg

A small, and fast random color generator. Generates hex, hsl, hsla, rgb, and rgba colors (and also hex-alpha).
https://github.com/ianfabs/cs-rcg

cli colors deno javascript node rgba typescript

Last synced: 3 months ago
JSON representation

A small, and fast random color generator. Generates hex, hsl, hsla, rgb, and rgba colors (and also hex-alpha).

Awesome Lists containing this project

README

          

[![Gitpod ready-to-code](https://img.shields.io/badge/Gitpod-ready--to--code-blue?logo=gitpod)](https://gitpod.io/#https://github.com/ianfabs/rcg) ![Node.js Package](https://github.com/ianfabs/rcg/workflows/Node.js%20Package/badge.svg?event=release)

# CS-RCG
#### *Cryptographically-Secure Random Color Generator*

A tiny, and fast random color generator. Generates hex, rgb, and hsl colors (Optionally with alpha-values). I got the idea from my implementation of nanoid for Deno. The way the random values are generated ensures (mostly) true randomness. I also like using/learning new Web APIs, and Web Crypto is pretty cool.

# Usage

## Code
```ts
import {hex, rgb, hsl} from "https://deno.land/x/cs-rcg/mod.ts";

hex() // 1b69af
hex(true) // 1b69af91

rgb() // [12, 102, 67]
rgb(true) // [12, 102, 67, 0.32]

hsl() // [217, 48.12, 91.55]
hsl(true) // [217, 48.12%, 91.55%, 0.78]

// You get the idea...
```

## CLI
RCG offers a simple cli for generating colors too.

### Installation

```sh
$ deno install --allow-read --name rcg https://deno.land/x/cs-rcg/cli.ts
```

### Usage

```sh
$ rcg
3c5f67
```

```sh
$ rcg hsl -fa
hsl(161, 28%, 71%, 0.53)
```