npm.io
1.1.0 • Published 7 years ago

@react-vertex/hex-webgl

Licence
MIT
Version
1.1.0
Deps
2
Size
5 kB
Vulns
0
Weekly
0
Stars
1.2K
DeprecatedThis package is deprecated

@react-vertex/hex-webgl

license bundlephobia npm version

Documentation and Examples

Simple helper function to convert hex colors to a WebGL friendly format.

import convertHex from '@react-vertex/hex-webgl'

convertHex('#fff')
// [1, 1, 1, 1]

convertHex('#0006')
// [0, 0, 0, 0.4]

convertHex('#4183c4')
// [0.2549019607843137, 0.5137254901960784, 0.7686274509803922, 1]

convertHex('#4183c4', true) // Drop the alpha by passing true as a second param 
// [0.2549019607843137, 0.5137254901960784, 0.7686274509803922]

gl.clearColor(...convertHex('#323334'))

Keywords