You can use the HSL color format to fill your text
HSL lets you focus on the Hue (Hue==color) of your fill and make the color change through the R,G,B color range.
You specify fill using HSL like this: ctx.fillStyle='hsl(255,100%,50%)'
. The first value in HSL is the hue and you can vary the hue using integers from 0 to 255.
Here's example code and a demo that animates the text hue through R,G,B and back again:
var canvas=document.getElementById("canvas");
var ctx=canvas.getContext("2d");
var cw=canvas.width;
var ch=canvas.height;
ctx.font='25px Verdana';
var hue=0;
var direction=1;
requestAnimationFrame(animate);
function animate(time){
ctx.fillStyle='black';
ctx.fillRect(0,0,cw,ch);
ctx.fillStyle='hsl('+hue+',100%,50%)';
ctx.fillText('Use the Hue!',50,75);
requestAnimationFrame(animate);
hue+=direction;
if(hue>255){direction*=-1;hue=255;}
if(hue<0){direction*=-1;hue=0;}
}
<canvas id="canvas" width=300 height=300></canvas>