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
npm install invert-color
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
291 Stars
120 Commits
21 Forks
2 Watching
1 Branches
3 Contributors
Updated on 26 Sept 2024
Minified
Minified + Gzipped
TypeScript (61.27%)
JavaScript (33.71%)
HTML (3.94%)
CSS (1.08%)
Cumulative downloads
Total Downloads
Last day
-5.4%
13,333
Compared to previous day
Last week
26.1%
86,260
Compared to previous week
Last month
9.9%
302,309
Compared to previous month
Last year
97.8%
3,000,152
Compared to previous year
© 2021, 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
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no SAST tool detected
Details
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
63 existing vulnerabilities detected
Details
Score
Last Scanned on 2024-11-18
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