https://github.com/alexcambose/ahex
Alpha hexadecimal
https://github.com/alexcambose/ahex
alpha color converter css hexadecimal opacity
Last synced: about 1 month ago
JSON representation
Alpha hexadecimal
- Host: GitHub
- URL: https://github.com/alexcambose/ahex
- Owner: alexcambose
- Created: 2017-08-27T14:36:42.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2017-08-28T11:00:53.000Z (almost 9 years ago)
- Last Synced: 2025-09-21T09:22:24.370Z (9 months ago)
- Topics: alpha, color, converter, css, hexadecimal, opacity
- Language: JavaScript
- Size: 2.93 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# ahex
Alpha hexadecimal
## Install
```
npm install -S ahex
```
[npm](https://www.npmjs.com/package/ahex)
## Usage
```js
const ahex = require('ahex');
// RGB format
console.log(ahex('#0f0'));
// rgb(0, 255, 0)
// RGBA format
console.log(ahex('#0f0d'));
// rgba(0, 255, 0, 0.87)
// RGBAA format
console.log(ahex('#0f0dd'));
// rgba(0, 255, 0, 0.87)
// RRGGBB format
console.log(ahex('#00ff00'));
// rgba(0, 255, 0)
// RRGGBBA format
console.log(ahex('#00ff00d'));
// rgba(0, 255, 0, 0.87)
// RRGGBBAA format
console.log(ahex('#00ff00dd'));
// rgba(0, 255, 0, 0.87)
```
if the second parameter is set to `true` the returned result will be an object
```js
console.log(ahex('#00ff00dd', true));
// { r: 0, g: 255, b: 0, a: '0.87' }
```