I’m trying to convert color names into appropriate hex strings for a google calendar apps script I’m building. The idea is it should take “pink puppy class” and create a calendar whose color is Pink, or whatever.
So far I’m doing the brute force approach as originally posted in Javascript function to convert color names to hex codes, since I only need a dozen or so color names, but I liked the alternate methods, especially the elegant looking answer by JayB.
But I’m unable to transmorgrify
function standardize_color(str){
var ctx = document.createElement('canvas').getContext('2d');
ctx.fillStyle = str;
return ctx.fillStyle;
}
Into something that google’s jscript will work with. Can anybody help me here, or point me in a new direction?