ctx.fillStyle = "red";
ctx.strokeStyle = "#0F0";
ctx.fillStyle = 'RGB(100%,70%,50%)';
ctx.fillStyle = 'RGB(148,129,256)';
let red = 25;
let green = 150;
let blue = 150;
ctx.fillStyle = "RGB(" + red +","+ green+","+ blue + ")";
ctx.fillStyle = "hsl(3rad, 90%, 50%)";
ctx.fillRect(120,120,20,20);
for(let angle = 0; angle < 360; angle+= 30) {
ctx.fillStyle="hsl("+angle + ", 90%, 50%)";
ctx.fillRect(angle, 150,20, 20);
}
let x = 0;
for(let pct =0; pct < 100; pct+= 10) {
ctx.fillStyle="hsl(120deg, " + pct + "%, 50%)";
ctx.fillRect(x, 180,20, 20);
x += 30;
}
x = 0;
for(let pct =0; pct < 100; pct+= 10) {
ctx.fillStyle="hsl(200, 100%," +pct +"%)";
ctx.fillRect(x, 210,20, 20);
x += 30;
}
// reset the line dash
ctx.setLineDash( [0]);
// orange 40 pixel sans-serif text
ctx.strokeStyle = "orange";
ctx.font="40px sans-serif";
// measure how long, in pixels the string will be.
var text = ctx.measureText("Graphics");
// draw it.
ctx.strokeText("Graphics", 10, 300);
// change to a serif text in green
ctx.font="40px serif";
ctx.strokeStyle = "green";
// make sure to add the offset of the first word
ctx.strokeText(" is fun!", 10+text.width, 300);