
Research
Malicious npm Packages Impersonate Flashbots SDKs, Targeting Ethereum Wallet Credentials
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
Bidirectional conversions between different colors format like RGB, HSL, HSV and HEX
Colorsys is a simple javascript color conversion library that allows bidirectional color conversion. Lightweight, immutable. With support for RGB, HEX, HSV, HSL and CMYK and CSS strings.
With npm
npm install colorsys
Load on browser or copy paste into your code
<script src="https://unpkg.com/colorsys@1.0.11/colorsys.js"></script>
var colorsys = require('colorsys')
const hsl = colorsys.parseCss('hsl(0, 0%, 100%)') // { h: 0, s: 0, l: 100 }
colorsys.hsl2Hex(hsl) // '#ffffff'
const hsv = colorsys.rgb_to_hsv({r: 255, g: 255, b: 255 })
colorsys.stringify(hsv) // 'hsv(0, 0%, 100%)'
// Parsing an hex string will result in a RGB object!
colorsys.parseCss('#ff00ff') // { r: 255, g: 0, b: 255 }
For more examples please visit the tests
For any method the input arguments can be an object (r: 50, g: 100, b: 0}
or a set of integers 50, 100, 0
. You have aliases in both snake_case (hex_to_hsl
) or rgb2Hex
, hsv2Rgb
form.
colorsys.parseCss(color: string)
will parse a color string in an object with the same keys.colorsys.stringify(color: Object)
will output a valid css string.colorsys.rgb_to_hsl({ r: 255, g: 255, b: 255 }) => { h: 0 , s: 0 , l: 100 }
colorsys.rgb_to_hsv({ r: 255, g: 255, b: 255 }) => { h: 0 , s: 0 , v: 100 }
Try with any combination. Look at the source to double check!
colorsys.hslToRgb
colorsys.hsvToRgb
colorsys.rgbToHex
colorsys.hexToRgb
colorsys.hsvToHex
colorsys.hexToHsv
colorsys.hslToHex
colorsys.hexToHsl
colorsys.rgb2cmyk
colorsys.cmyk2rgb
Other methods:
colorsys.random()
colorsys.rotateHue(120, 120)
will output 240
.
You can also use HSL or HSV objects as rotateHue(hsv, 120)
will output
an object containing {h: 240}
.There are some formats missing like YIQ
, HWB
, ansii
and ansi16
. Please help us to complete this library making a pull request.
This repo is shared with :heart: from Netbeast. This package powers Yeti Smart Home and is used in production.
FAQs
Bidirectional conversions between different colors format like RGB, HSL, HSV and HEX
The npm package colorsys receives a total of 2,117 weekly downloads. As such, colorsys popularity was classified as popular.
We found that colorsys demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
Security News
Ruby maintainers from Bundler and rbenv teams are building rv to bring Python uv's speed and unified tooling approach to Ruby development.
Security News
Following last week’s supply chain attack, Nx published findings on the GitHub Actions exploit and moved npm publishing to Trusted Publishers.