https://github.com/skratchdot/color-quantize
Convert colors to websafe / websmart values
https://github.com/skratchdot/color-quantize
Last synced: 3 months ago
JSON representation
Convert colors to websafe / websmart values
- Host: GitHub
- URL: https://github.com/skratchdot/color-quantize
- Owner: skratchdot
- License: mit
- Created: 2014-06-21T23:59:49.000Z (about 11 years ago)
- Default Branch: master
- Last Pushed: 2016-08-28T10:49:48.000Z (almost 9 years ago)
- Last Synced: 2025-03-20T22:08:20.455Z (4 months ago)
- Language: JavaScript
- Size: 5.86 KB
- Stars: 4
- Watchers: 3
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE-MIT
Awesome Lists containing this project
README
# color-quantize
[](http://badge.fury.io/js/color-quantize)
[](https://travis-ci.org/skratchdot/color-quantize)
[](https://codeclimate.com/github/skratchdot/color-quantize)
[](https://coveralls.io/r/skratchdot/color-quantize)
[](https://david-dm.org/skratchdot/color-quantize)
[](https://david-dm.org/skratchdot/color-quantize#info=devDependencies)[](https://npmjs.org/package/color-quantize)
## Description
Convert colors to websafe / websmart values
## Getting Started
Install the module with: `npm install color-quantize`
```javascript
var colorQuantize = require('color-quantize');
colorQuantize.websafe('#cd1289'); // "#CC0099"
colorQuantize.websmart('#cd1289'); // "#CC1188"
```## Documentation
This library uses the [onecolor](https://github.com/One-com/one-color) parser,
so colorString can in many different formats (i.e. #ff00cc, rgb(13,42,255), etc).#### colorQuantize.websafe(colorString)
Return a hex code from the 216 web-safe color palette.
colorString can be in any format supported by [onecolor](https://github.com/One-com/one-color).
Same as calling: `colorQuantize.quantize(colorString, 51)`
#### colorQuantize.websmart(colorString)
Return a hex code from the 4096 web-smart color palette.
colorString can be in any format supported by [onecolor](https://github.com/One-com/one-color).
Same as calling: `colorQuantize.quantize(colorString, 17)`
#### colorQuantize.quantize(colorString, quantizeAmount)
Quantize a colorString by the given quantizeAmount.
colorString can be in any format supported by [onecolor](https://github.com/One-com/one-color).
quantizeAmount must be an integer.
## Additional Links
- [4096 Web Smart Colors](http://cloford.com/resources/colours/websmart1.htm)
- [Original Inspiration](http://mudcu.be/sphere/)## Release History
#### v0.1.0 - Released June 21, 2014
- initial release
## License
Copyright (c) 2014 skratchdot
Licensed under the MIT license.