正文

HTML5中设置直线颜色,只需在绘制直线时指定颜色即可。以下是一个简单的例子:使用`context.strokeStyle`属性来设置颜色,然后在`context.beginPath()`和`context.stroke()`方法之间绘制直线。例如:`context.strokeStyle = 'red'; context.beginPath();