Gathering detailed insights and metrics for invert-color
Gathering detailed insights and metrics for invert-color
Gathering detailed insights and metrics for invert-color
Gathering detailed insights and metrics for invert-color
Generates inverted (opposite) version of the given color. (<1KB)
npm install invert-color
Typescript
Module System
Node Version
NPM Version
TypeScript (61.27%)
JavaScript (33.71%)
HTML (3.94%)
CSS (1.08%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
293 Stars
120 Commits
21 Forks
1 Watchers
1 Branches
3 Contributors
Updated on Jun 04, 2025
Latest Version
2.0.0
Package Id
invert-color@2.0.0
Unpacked Size
37.73 kB
Size
9.06 kB
File Count
10
NPM Version
6.4.1
Node Version
8.12.0
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
© 2018, Onur Yıldırım (@onury). MIT License.
Generates inverted (opposite) version of the given color. (<1KB)
This passes a long test suite of Adobe Photoshop CC inverted colors...
Generating exactly the same results with it.
npm i invert-color
1// Node, CommonJS 2const invert = require('invert-color'); 3// ES2015, JSNext 4import invert from 'invert-color'; 5// TypeScript 6import invert, { RGB, RgbArray, HexColor, BlackWhite } from 'invert-color';
For UMD in browser, use lib/invert.min.js
.
See other exports.
invert(color[, bw])
color
: String|Array|Object
bw
: Boolean|Object
#000000
) or white (#ffffff
), according to the luminance of the original color. You can set custom black/white values (and/or luminance threshold) by passing an object.1invert('#000') // —> #ffffff 2invert('#282b35') // —> #d7d4ca 3 4// input color as RGB array or object 5invert([69, 191, 189]) // —> #ba4042 6invert({ r: 249, g: 119, b: 121 }) // —> #068886 7 8// amplify to black or white 9invert('#282b35', true) // —> #ffffff 10 11// amplify to custom black or white color 12invert('#282b35', { black: '#3a3a3a', white: '#fafafa' }) // —> #fafafa 13 14// amplify with custom luminance threshold (default is invert.defaultThreshold = ~0.179) 15invert('#282b35', { black: '#3a3a3a', white: '#fafafa', threshold: 0.01 }) // —> #3a3a3a
invert.asRGB(color[, bw])
Invert and output result as RGB object.
1invert.asRGB('#fff') // —> { r: 0, g: 0, b: 0 }
invert.asRgbArray(color[, bw])
Invert and output result as RGB array.
1invert.asRgbArray('#000') // —> [255, 255, 255]
bw
option
This is useful in case, you need to create contrast (i.e. background vs foreground, for better readability). The animation at the top is a demonstration.
Clone original project:
1git clone https://github.com/onury/invert-color.git
Install (dev) dependencies:
1npm install
Add tests into test/unit.test.ts and run:
1npm run cover
Travis build should pass, coverage should not degrade.
main
, package.json
now also defines module
, jsnext:main
and browser
.threshold: number
to BlackWhite
options (interface). Fixes #16.invert.defaultThreshold
constant..asRGB()
- alias of .asRgbObject()
.MIT.
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
Found 0/30 approved changesets -- score normalized to 0
Reason
no SAST tool detected
Details
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
65 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-07-07
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More