1 decade ago by mkreitler
While porting one of my Impact games to Ejecta, I've run across the following bug: fillRect doesn't work when used in an offscreen buffer.
Here's a simple index.js demonstrating the problem:
Note that these same draw commands, when applied directly to the main buffer, work perfectly.
On a side note, clearRect() doesn't seem to work at all.
Has anyone else run across (and hopefully fixed) this problem?
Mark
Here's a simple index.js demonstrating the problem:
var mainCanvas = document.getElementById('canvas'); var mainCtx = mainCanvas.getContext('2d'); var bgCanvas = document.createElement('canvas'); var bgCtx = bgCanvas.getContext('2d'); // Draw a square bgCtx.fillStyle = '#88ff88'; bgCtx.strokeStyle = '#ffffff'; bgCtx.beginPath(); bgCtx.moveTo(50, 50); bgCtx.lineTo(100, 50); bgCtx.lineTo(100, 100); bgCtx.lineTo(50, 100); bgCtx.closePath(); bgCtx.fill(); // Comment out this line and the stroke will work. bgCtx.stroke(); mainCtx.drawImage(bgCtx, 0, 0);
Note that these same draw commands, when applied directly to the main buffer, work perfectly.
On a side note, clearRect() doesn't seem to work at all.
Has anyone else run across (and hopefully fixed) this problem?
Mark