0
我有此代码绘制一个三角帆布。但我无法设法使填充颜色变成黑色。它声明与ctx.fillStyle一起工作,但事实并非如此。我必须在代码中丢失一些东西,你们可以看看吗?画布填充颜色,保持黑色
function drawShape(){
// get the canvas element using the DOM
var canvas = document.getElementById('balkboven');
// Make sure we don't execute when canvas isn't supported
if (canvas.getContext){
// use getContext to use the canvas for drawing
var ctx = canvas.getContext('2d');
var ctxwidth = window.innerWidth;
// Filled triangle
ctx.canvas.width = window.innerWidth;
ctx.beginPath();
ctx.moveTo(0,0);
ctx.lineTo(ctxwidth,0);
ctx.lineTo(0,105);
ctx.fill();
ctx.fillStyle="red"
}
}
谢谢它的工作原理,以为我想这虽然。 – Jurriaan