1.0.16 • Published 5 years ago

hex-opacity v1.0.16

Weekly downloads
114
License
MIT
Repository
github
Last release
5 years ago

hex-opacity

Simple module for adding opacity to hexidecimal colour codes

Available on npm here

Setup

To install:

yarn add hex-opacity

or

npm i hex-opacity

Import

Then import into whichever file you intent to use it in with ES6 or CommonJS:

ES6: import hexOpacity from 'hex-opacity';

CJS: const hexOpacity = require('hex-opacity');

API:

There is one simple API method to add opacity to hex colours, with a configurable output for #RRGGBBAA (default) or #AARRGGBB (using prepend flag parameter) formats.

create (hex, opacity, prepend)

ParameterTypeDefault value
hexstring''
opacitynumber1
prependbooleanfalse

The create function creates a hex format colour value with opacity. The default format is that supported by modern web browers (#RRGGBBAA) however passing in the prepend flag will resolve to a different format for use in Anroid environments (#AARRGGBB).

Just pass in your full initial hex colour code and a floating point opacity value between 0 and 1 (just as you would with CSS)

Usage:

hexOpacity.create('#fff'); // Result = '#FFFFFFFF'
hexOpacity.create('#1144b2', .3); // Result = '#1144B24D'
hexOpacity.create('#1144b2', .3, true); // Result = '#4D1144B2'

Enjoy! (☉ ‿ ⚆)

1.0.16

5 years ago

1.0.15

5 years ago

1.0.14

5 years ago

1.0.13

5 years ago

1.0.11

5 years ago

1.0.10

5 years ago

1.0.7

5 years ago

1.0.6

5 years ago

1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago