我正在尝试在 HTML5 画布中绘制 2 条黑线:
JSFiddle: http: //jsfiddle.net/KFNt5/ Javascript:
var canvas = document.createElement('canvas');
canvas.height = 150;
canvas.width = 150;
var canvasContext = canvas.getContext('2d');
canvasContext.beginPath();
// Draw the red line.
canvasContext.strokeStyle = '#000';
canvasContext.moveTo(10, 0);
canvasContext.lineTo(10, 100);
canvasContext.stroke();
// Draw the green line.
canvasContext.moveTo(50, 0);
canvasContext.lineTo(50, 100);
canvasContext.stroke();
document.body.appendChild(canvas);
但是,右边的线是灰色的,这意味着它是半透明的。如何确保默认不透明度为 100(根本不透明)?