canvas fill color, stays black -
i have code draw triangular canvas. can't manage fill color other black. it's stated work ctx.fillstyle doesn't. must missing in code can guys have look?
function drawshape(){ // canvas element using dom var canvas = document.getelementbyid('balkboven'); // make sure don't execute when canvas isn't supported if (canvas.getcontext){ // use getcontext use canvas 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" } }
fillstyle
, strokestyle
have set before draw object, not afterwards!
think of loading paint onto paintbrush. must before stroke brush!
Comments
Post a Comment