Skip to content

Commit 6da01e7

Browse files
authored
Merge pull request #2 from zacharyarney/v0.1.0
README and publishing prep
2 parents 754bf27 + 6151bce commit 6da01e7

File tree

6 files changed

+1635
-472
lines changed

6 files changed

+1635
-472
lines changed

.eslintrc.cjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ module.exports = {
66
'plugin:@typescript-eslint/strict-type-checked',
77
'plugin:@typescript-eslint/stylistic-type-checked',
88
],
9-
ignorePatterns: ['dist', '.eslintrc.cjs', 'vite.config.ts', '*.config.js'],
9+
ignorePatterns: ['dist', '.eslintrc.cjs', '*.config.ts', '*.config.js'],
1010
parser: '@typescript-eslint/parser',
1111
parserOptions: {
1212
ecmaVersion: 'latest',

README.md

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,47 @@
11
# clancy
2-
A library for deriving non-image data from image files
2+
3+
A library for deriving non-image data from image files.
4+
5+
## Installation
6+
7+
```npm install clancy```
8+
9+
## Usage
10+
11+
Loading a color palette is an asynchronous operation. You can either await the `loadHistogram` method or use `then` to
12+
access the palette once it has been loaded.
13+
14+
```javascript
15+
const { ColorPalette } = require('clancy');
16+
17+
async function getPalette() {
18+
const palette = new ColorPalette('path/to/image');
19+
await palette.loadHistogram();
20+
21+
return palette.histogram;
22+
}
23+
```
24+
25+
### Histogram
26+
27+
The histogram algorithm sorts the pixels in an image into sectors in a 3D grid based on their RGB values. The output is
28+
the average RGB value for each sector in order of sector density.
29+
30+
Some reasonable default parameters are provided for the histogram generation process. The number of sectors can be
31+
increased using the `dimensionscs` parameter for greater color accuracy and the size of the color palette can be
32+
adjusted with the `paletteSize` parameter.
33+
34+
## Todo
35+
36+
- [ ] Add more palette generation algorithms (k-means, median cut, etc.)
37+
- [ ] Add support for transparency/alpha channels
38+
- [ ] Add image to ASCII conversion
39+
- [ ] Add browser support
40+
41+
## Notes
42+
43+
- Currently requires Node.js runtime. Browser support is on the todo list.
44+
- Doesn't yet support transparency and will ignore alpha channels when generating color palette, meaning that the color
45+
palette will include RGB values for transparent pixels.
46+
- The palette is stored as an array of objects with `r`, `g`, and `b` properties. This may be subject to change in the
47+
future.

0 commit comments

Comments
 (0)