添加了strokeStyle但是颜色没变化
来源:3-2 canvas画直线(2)
cjq6502
2019-06-30 00:15:28
var c = document.getElementById('c');
var cx = c.getContext('2d');
c.width = 100;
c.height = 100;
console.log(cx);
cx.moveTo(50,10);
cx.lineTo(70,80);
cx.strokeStyle = '#eee';
cx.stroke();
cx.moveTo(70,80);
cx.lineTo(30,80);
cx.strokeStyle = '#aaa';
cx.stroke();
cx.moveTo(30,80);
cx.lineTo(50,10);
cx.strokeStyle = '#000';
cx.stroke();没报错,而且控制台查看cx.strokeStyle也确实改变了,但是三角形都是黑色边框的
1回答
你好同学,因为它们是绘制的一条路径,所以最后黑色的会把前面的重新绘制一下。在本节课中老师讲解了这个问题,建议同学继续往下看,把本节的视频看完,后面有讲解解决方式哦。
祝学习愉快,望采纳。
相似问题