colorguard / 0.2.0 last updated a year ago created on Jul 7th 2014
Install
npm install --save colorguard
Clone
git clone git@github.com:SlexAxton/css-colorguard.git
dependencies
show all 22
| main |
|
color-diff | 0.1.3 | BSD 4-Clause |
|
|
pipetteur | 1.0.1 | MIT | |
|
|
rework-walk | 1.0.0 | MIT | |
|
|
yargs | 1.3.1 | MIT | |
|
|
rework | 1.0.0 | MIT |
maintainers
versions
10 total
| 0.2.0 | a year ago | slexaxton |
| 0.1.8 | a year ago | slexaxton |
| 0.1.7 | a year ago | slexaxton |
| 0.1.6 | a year ago | slexaxton |
| 0.1.5 | a year ago | slexaxton |
| 0.1.4 | a year ago | slexaxton |
| 0.1.3 | a year ago | slexaxton |
| 0.1.2 | a year ago | slexaxton |
| 0.1.1 | a year ago | slexaxton |
| 0.1.0 | a year ago | slexaxton |
readme
CSS Colorguard
Every CSS project starts out with good intentions, but inevitably, one too many people eye-dropper colors into nooks and crannies that you never knew existed. CSS Colorguard helps you maintain the color set that you want, and warns you when colors you've added are too similar to ones that already exist. Naturally, it's all configurable to your tastes.
Usage
Generally, you'll want to do this after you've run things through your css preprocessor, so variables and other preprocessor specific things are out of the way.
Command Line
Example output
Programmatic
Build Time
CSS Colorguard can also be used in conjunction with other javascript build systems, such as:
The Output
You'll get warnings back (as an object via js or if the format is set to json), as well as some
additional color stats. Those are just for fun or whatever.
How it works
Colorguard uses the CIEDE2000 algorithm to determine the similarity of each of the colors in your CSS file. This algorithm is quite complex, but is used in the broadcasting community as the best approximation of human ability to discern differences in color. RGB on the other hand, is pretty bad at representing differences in color purely based on the numerical difference of the hex values.
Luckily, someone else already implemented CIEDE2000, so I didn't have to. Tight. Cause this thing is mathy as hell.

Alpha Transparency
Currently, alpha transparency is just stripped from the colors. So rgb(0, 0, 0) exactly matches
rgba(0,0,0,0.5). This is usually fine unless someone is alphatransparency-happy and uses it for
darkening and lightening colors too often. It could probably be it's own check in the future that
there aren't too many different alpha transparencies of the same color. This is not currently a
thing though.
Thanks
- Stripe - They let me build this at work
- reworkcss - Makes this work
- @markusn - Best CIEDE2000 implementation ever
License
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.