https://github.com/justjavac/deno_x256
Find the nearest xterm 256 color index for an rgb
https://github.com/justjavac/deno_x256
color colors deno deno-mod deno-module x256 xterm xterm-256color xterm256
Last synced: about 2 months ago
JSON representation
Find the nearest xterm 256 color index for an rgb
- Host: GitHub
- URL: https://github.com/justjavac/deno_x256
- Owner: justjavac
- License: mit
- Created: 2020-08-11T05:41:04.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2020-09-05T15:51:36.000Z (almost 6 years ago)
- Last Synced: 2025-03-05T09:17:15.304Z (over 1 year ago)
- Topics: color, colors, deno, deno-mod, deno-module, x256, xterm, xterm-256color, xterm256
- Language: TypeScript
- Homepage:
- Size: 10.7 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# deno_x256
[](https://github.com/justjavac/deno_x256/releases)
[](https://github.com/justjavac/deno_x256/actions)
[](https://github.com/justjavac/deno_x256/blob/master/LICENSE)
Find the nearest [xterm 256 color](http://www.frexx.de/xterm-256-notes/) index for an rgb.
colors data source https://cdn.jsdelivr.net/gh/substack/node-x256@master/colors.json
## Usage
All xterm 256 colors:
```ts
import color from "https://deno.land/x/x256/color.ts";
console.log(color)
```
output:
```ts
[
"000000",
"800000",
"008000",
"808000",
"000080",
"800080",
...
...
```
Get the nearest xterm 256 color code for rgb inputs.:
```ts
import x256 from "https://deno.land/x/x256/mod.ts";
const c = x256(220,40,150);
console.log(c); // 162
```
Use raw ansi escape codes:
Check if the language code is valid:
```ts
import x256 from "https://deno.land/x/x256/mod.ts";
const c = x256(220,40,150);
console.log(`\x1b[38;5;${c}mBEEEEEP`);
```
### License
[deno_x256](https://github.com/justjavac/deno_x256) is released under the MIT License. See the bundled [LICENSE](./LICENSE) file for details.