以下のURLには、2本の線を引く小さなサンプルがあります。上の線は緑、下の線は青になると思います。しかし、それらは両方とも青です。なんで?
編集 以下のスクリプトも追加します。
var canvas = document.getElementById('canvas');
canvas.width = 500;
canvas.height = 500;
var ctx = canvas.getContext('2d');
ctx.globalAlpha = 1;
ctx.globalCompositeOperation = "source-over";
var x1=10, y1=10, width=100, height=100;
ctx.lineWidth = "5";
//draw green line
ctx.strokeStyle = "#00FF00";
ctx.moveTo(x1 + 1, y1 + 1);
ctx.lineTo(x1 + width - 2, y1 + 1);
ctx.stroke();
//draw blue line
ctx.strokeStyle = "#0000FF";
ctx.moveTo(x1 + 1, y1 + 10);
ctx.lineTo(x1 + width - 2, y1 + 10);
ctx.stroke();