colour-rgba
v1.0.5
Published
A module for creating RGBA Colour objects and manipulating, un/packing and de/serializing them.
Downloads
34
Readme
Colour RGBA
A module for creating RGBA Colour objects and manipulating, un/packing and de/serializing them.
Usage
const Colour = require("colour-rgba");
// create a new colour
const myColour = new Colour(86, 75, 30, 99);
// or use a pre-defined colour
const red = Colour.LimeGreen;
// convert a colour to an array excluding the alpha channel
const colourArray = myColour.toArray(false);
// pack a colour object into a 32-bit number
const packedNumber = myColour.pack();
// unpack a colour from a 32-bit number
const unpackedColour = Colour.unpack(packedNumber);
// serialize a colour object into a buffer and include the alpha channel
const serializedColour = myColour.serialize(true);
// de-serialize a colour object from a buffer
const deserializedColour = Colour.deserialize(serializedColour);
Installation
To install this module:
npm install colour-rgba