https://github.com/skratchdot/color-matrix
Apply filters to colors to simulate things like color blindness and night vision.
https://github.com/skratchdot/color-matrix
Last synced: about 1 year ago
JSON representation
Apply filters to colors to simulate things like color blindness and night vision.
- Host: GitHub
- URL: https://github.com/skratchdot/color-matrix
- Owner: skratchdot
- License: mit
- Created: 2015-10-03T00:10:56.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2016-09-21T05:48:48.000Z (over 9 years ago)
- Last Synced: 2025-03-18T21:50:51.795Z (over 1 year ago)
- Language: JavaScript
- Size: 17.3 MB
- Stars: 24
- Watchers: 2
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE-MIT
Awesome Lists containing this project
README
# color-matrix
[](http://badge.fury.io/js/color-matrix)
[](https://travis-ci.org/skratchdot/color-matrix)
[](https://codeclimate.com/github/skratchdot/color-matrix)
[](https://david-dm.org/skratchdot/color-matrix)
[](https://david-dm.org/skratchdot/color-matrix#info=devDependencies)
[](https://npmjs.org/package/color-matrix)
## Description
Apply filters to colors to simulate things like color blindness and night vision. This
library tries to simulate the behavior of the svg filter effect
[feColorMatrix](https://developer.mozilla.org/en-US/docs/Web/SVG/Element/feColorMatrix).
It comes in 2 formats: [a node.js library](#getting-started) and a
[command line tool](#command-line-tool).
## Examples
Usage and output examples can be found here:
- http://projects.skratchdot.com/color-matrix/examples.html
## Node.js Library
### Getting Started
Install the module with: `npm install color-matrix`
```javascript
var ColorMatrix = require('color-matrix').ColorMatrix;
var matrix = new ColorMatrix();
// simulate color-blindness
matrix.transform([222, 0, 173, 255], 'deuteranopia'); // returns [139, 155, 121, 1]
```
***NOTE:*** For a better "color blindness" library, see:
[color-blind](http://github.com/skratchdot/color-blind). This library is just a port
of the old "color matrix" code for use in node. It does allow you to pass in custom
filters (which is why I published it, instead of throwing it away).
### API Documentation
Read the [API Docs](http://projects.skratchdot.com/color-matrix/api.html)
by using this link:
- http://projects.skratchdot.com/color-matrix/api.html
## Command Line Tool
### Installation
The `color-matrix` tool can be installed globally by running:
```bash
npm install -g color-matrix
```
### Usage
```bash
Usage: color-matrix [options]
Options:
-h, --help output usage information
-V, --version output the version number
-i, --input input image file
-o, --output output image file
-f, --filter filter name to use
-v, --value value for the selected operation type
-l, --list list all the filter names
```
## See Also
- [MDN: feColorMatrix](https://developer.mozilla.org/en-US/docs/Web/SVG/Element/feColorMatrix)
- [w3c spec: feColorMatrix](http://www.w3.org/TR/SVG/filters.html#feColorMatrixElement)
- [color-js source code](https://color-js.googlecode.com/svn/trunk/src/Color.matrix.js)
- [Original Color Matrix Library](http://web.archive.org/web/20081014161121/http://www.colorjack.com/labs/colormatrix/)
- [StackOverflow: RGB filters for different forms of color blindness](http://stackoverflow.com/questions/87146/rgb-filters-for-different-forms-of-color-blindness)
- [Fun with the colormatrix](http://hirntier.blogspot.com/2008/09/fun-with-colormatrix.html)
## License
Copyright (c) 2014 skratchdot
Licensed under the MIT license.