https://github.com/dominicegginton/hex-color-converter
Lightweight module for converting RGB(A) values to hexadecimal colors
https://github.com/dominicegginton/hex-color-converter
Last synced: 3 months ago
JSON representation
Lightweight module for converting RGB(A) values to hexadecimal colors
- Host: GitHub
- URL: https://github.com/dominicegginton/hex-color-converter
- Owner: dominicegginton
- License: mit
- Created: 2021-02-22T15:25:22.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2023-09-12T15:20:45.000Z (almost 2 years ago)
- Last Synced: 2025-02-23T09:23:19.694Z (4 months ago)
- Language: JavaScript
- Homepage:
- Size: 26.4 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# hex-color-converter
[](https://github.com/dominicegginton/hex-color-converter/actions)
[](https://codeclimate.com/github/dominicegginton/hex-color-converter)
[](https://www.npmjs.com/package/hex-color-converter)
[](http://standardjs.com)> Lightweight module for converting RGB(A) values to hexadecimal colors
## Install
``` shell
npm i hex-color-converter
```## Usage
``` js
const converter = require('hex-color-converter')const hex = converter('rgba(255, 255, 255, 0.5)')
console.log(hex) // => #FFFFFF80
```## Documentation
### Convert RGB values to hexadecimal color values
To convert RGB values to a hexadecimal color value pass the RGB string to `converter` function. RGB strings should be formatted as `rgb(255, 255, 255)`
``` js
converter('rgb(255, 255, 255)')
```### Convert RGBA values to hexadecimal color values
To convert RGBA values to a hexadecimal color value pass the RGBA string to `converter` function. RGBA strings should be formatted as `rgba(255, 255, 255, 0.5)`
``` js
converter('rgb(255, 255, 255, 0.5)')
```## Contributing
Contributors are welcome, feel free to submit a new [pull request](https://github.com/dominicegginton/hex-color-converter/pulls) to help improve **hex-color-converter**.