https://github.com/iamsebastiandev/colrjs
ColrJS
https://github.com/iamsebastiandev/colrjs
Last synced: 12 months ago
JSON representation
ColrJS
- Host: GitHub
- URL: https://github.com/iamsebastiandev/colrjs
- Owner: IamSebastianDev
- License: mit
- Created: 2023-04-30T06:56:13.000Z (about 3 years ago)
- Default Branch: develop
- Last Pushed: 2023-05-22T16:51:36.000Z (about 3 years ago)
- Last Synced: 2025-04-08T03:44:38.913Z (about 1 year ago)
- Language: TypeScript
- Size: 3.86 MB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: contributing.md
- License: license.md
Awesome Lists containing this project
README
# ColrJS
[](https://www.npmjs.com/package/colrjs)[](https://npmjs.com/package/colrjs)[](https://npmjs.com/package/colrjs)[](https://github.com/ZktSn0w/ColrJS/tags)
A lightweight, modern, extendable Color Palette extractor that can be used in the browser or in a node.js context.
## Installing
To use **ColrJS** with node and/or a bundler such as webpack or rollup, install it via yarn or npm:
```bash
yarn add colrjs
# or use npm
npm install colrjs
```
You can also use it directly in the browser and include it via CDN or locally.
```html
...
...
```
## Getting started
Setting up the initial **ColrJS** instance is quick and requires only a configuration object. **ColrJS** provides functions to create one, to utilize editor autocompletion and type safety. For a more in depth guide on how to use **ColrJS**, take a look at the full [documentation](./docs/readme.md).
Start by importing or destructuring the required methods. You are free to use module or import syntax, **ColrJS** provides export for both standards. When included via CDN or locally, destructuring the globally accessible `ColrJS` property is the easiest way to access the API.
```js
// node require syntax
const { ColrJS, defineConfig } = require('colrjs');
// modern es6 style syntax
import { ColrJS, defineConfig } from 'colrjs';
// if added to the global namespace
const { ColrJS, defineConfig } = ColrJS;
```
### Creating a `ColrJS` instance
To use **ColrJS**, create a new instance and pass a configuration object containing a Processor to it as parameters.
> Note: The examples below assumes you're using es6.
```ts
import { defineConfig, ColrJS, Monochromatic } from 'colrjs';
// create a processor configuration
const config = defineConfig({
processors: {
mono: Monochromatic(5),
},
});
const colr = new ColrJS(config);
// You can now extract a Palette by using the extract Palette method.
const monochromaticPalette = await colr.extractPalette().mono();
```
## Contributing
If you would like to contribute, take a look at the [contribution guide](./contributing.md).
## License
**Vay** is licensed under the MIT License