There's a bit of a hack for this, since the HTML5 canvas is required to parse color values when certain properties like strokeStyle
and fillStyle
are set:
var ctx = document.createElement('canvas').getContext('2d');
ctx.strokeStyle = 'rgb(64, 128, 192)';
var hexColor = ctx.strokeStyle;