Skip to content

Commit 38d8251

Browse files
committed
Clear canvas for toImage call
1 parent a3cf740 commit 38d8251

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/plots/gl2d/scene2d.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ var Registry = require('../../registry');
1313
var Axes = require('../../plots/cartesian/axes');
1414
var Fx = require('../../components/fx');
1515

16-
var createPlot2D = require('gl-plot2d');
16+
var createPlot2D = require('../../../../gl-plot2d');
1717
var createSpikes = require('gl-spikes2d');
1818
var createSelectBox = require('gl-select-box');
1919
var getContext = require('webgl-context');
@@ -182,20 +182,24 @@ proto.toImage = function(format) {
182182
if(!format) format = 'png';
183183

184184
this.stopped = true;
185+
185186
if(this.staticPlot) this.container.appendChild(STATIC_CANVAS);
186187

187188
// update canvas size
188189
this.updateSize(this.canvas);
189190

190-
// force redraw
191-
this.glplot.setDirty();
192-
this.glplot.draw();
193191

194192
// grab context and yank out pixels
195193
var gl = this.glplot.gl,
196194
w = gl.drawingBufferWidth,
197195
h = gl.drawingBufferHeight;
198196

197+
// force redraw
198+
gl.clearColor(1, 1, 1, 0);
199+
gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
200+
this.glplot.setDirty();
201+
this.glplot.draw();
202+
199203
gl.bindFramebuffer(gl.FRAMEBUFFER, null);
200204

201205
var pixels = new Uint8Array(w * h * 4);

0 commit comments

Comments
 (0)