Skip to content

Commit

Permalink
chore: initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
mineejo committed Dec 12, 2023
0 parents commit 2213e9d
Show file tree
Hide file tree
Showing 189 changed files with 3,895 additions and 0 deletions.
27 changes: 27 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: ci

on: [ push, pull_request ]

permissions:
contents: write

jobs:
checks:
runs-on: ubuntu-latest
steps:
- name: clone repository
uses: actions/checkout@v3

- name: install deno
uses: denoland/setup-deno@v1
with:
deno-version: 1.X

- name: check format
run: deno fmt --check

- name: check linting
run: deno lint

- name: run tests
run: deno test
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/.npm
5 changes: 5 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions .idea/codeStyles/codeStyleConfig.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions .idea/color_convert.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/copyright/mit_license.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions .idea/copyright/profiles_settings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions .idea/deno.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/dictionaries/mineejo.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/inspectionProfiles/Project_Default.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

145 changes: 145 additions & 0 deletions .idea/watcherTasks.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2023 mineejo

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
51 changes: 51 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# Color convert

Color convert is a set of conversion functions and automated conversions of
color models and formats.

### About

Color convert does not rely on fragile practices, like converting ANSI16 to RGB.
Why is this fragile? RGB is 16 million colors, converting to ANSI16 we get the
code or ID of the color, not the color itself, so they are called system colors
and are reserved by the system, changing depending on the runtime environment.

- Quite a few conversions are planned for the future if anyone needs it.
- All percentages are specified in the range `0` to `100`, this is more readable
to the user.
- `HSV` and `HSB` are the same thing, but separated due to the frequent use of
both names.
- `LAB` refers to `CIELAB` and `RGB` refers to `sRGB`, these are the most
frequent variants of the models that have become the basis, so do not need
direct name clarification.

## Installation

`CommonJS` (script directory) and `ModuleJS` (esm directory) support for
`Node.js`, see [NPM page] for installation command. Also support for `Yarn` and
other package managers or CDNs like `UNPKG`. For `Deno` reference see
[module page], or use CDN like `esm.sh`.

[NPM page]: https://www.npmjs.com/package/@chalkpot/color_convert
[module page]: https://deno.land/x/chalkpot_color_convert

## Usage

```ts
const green = rgbToAnsi16(0, 255, 0)[0];
console.log(green); // 10
console.log(wrapAnsi16(green)); // [92, 102]

console.log(rgbToName(255, 0, 0)[0]); // red

console.log(rgbToLab(255, 100, 25)); // [62.03..., 56.12..., 66.05...]
```

## Contributing

Pull requests are welcome. For major changes, please open an issue first to
discuss what you would like to change.

## License

[MIT](https://choosealicense.com/licenses/mit/)
54 changes: 54 additions & 0 deletions _build_npm.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
// Copyright 2023 mineejo. All rights reserved. MIT license.

import { build, emptyDir } from "https://deno.land/x/[email protected]/mod.ts";

const outDir = "./.npm";

await emptyDir(outDir);

await build({
entryPoints: ["./mod.ts"],
outDir: outDir,
shims: {
deno: true,
},
test: true,
package: {
name: "@chalkpot/color_convert",
version: Deno.args[0],
description:
"Color convert is a set of conversion functions and automated conversions of color models and formats.",
author: "mineejo",
license: "MIT",
homepage: "https://github.com/chalkpot/color_convert#readme",
repository: {
type: "git",
url: "git+https://github.com/chalkpot/color_convert.git",
},
bugs: {
url: "https://github.com/chalkpot/color_convert/issues",
},
keywords: [
"chalkpot",
"color",
"convert",
"color-convert",
"ansi16",
"ansi256",
"cmy",
"cmyk",
"hex",
"hsb",
"hsl",
"hsv",
"lab",
"name",
"rgb",
"xyz",
],
},
postBuild() {
Deno.copyFileSync("LICENSE", `${outDir}/LICENSE`);
Deno.copyFileSync("README.md", `${outDir}/README.md`);
},
});
Loading

0 comments on commit 2213e9d

Please sign in to comment.