Closed songololo closed 6 years ago
No immediate plans to support this, but here’s one implementation:
function hex(value) {
value = Math.max(0, Math.min(255, Math.round(value) || 0));
return (value < 16 ? "0" : "") + value.toString(16);
}
d3.rgb.prototype.toHexString = function() {
return "#" + hex(this.r) + hex(this.g) + hex(this.b);
};
Thanks, extending the prototype works fine for my case.
Any possibility / support for adding a convenience method to return the colour in hex format?