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