Compare commits

..

11 Commits

Author SHA1 Message Date
greenkeeper[bot]
ae71646442 fix(package): update twgl.js to version 4.5.0 2018-09-28 02:02:53 +00:00
DD Liu
834c5eb984 Merge pull request #351 from fsih/updateSvgRender 2018-09-26 11:33:11 -04:00
DD
ef91583603 Also update webpack cli because it's breaking travis 2018-09-26 11:23:02 -04:00
DD
3e084dfe26 Update scratch svg render 2018-09-26 11:16:03 -04:00
Ray Schamp
24737982f0 Merge pull request #347 from rschamp/snapshots
Add ability to get a snapshot of the next frame
2018-09-18 16:06:46 -04:00
Ray Schamp
cfaadfcc75 Merge pull request #348 from rschamp/get-canvas
Add getter for the renderer's canvas
2018-09-18 16:01:53 -04:00
Ray Schamp
997062c851 Add JSDoc for requestSnapshot 2018-09-18 15:55:49 -04:00
Ray Schamp
90b1c47c3e Add getter for the renderer's canvas
Resolves #309
2018-09-18 15:21:01 -04:00
Ray Schamp
550cd7aacf Add ability to get a snapshot of the next frame 2018-09-18 15:01:22 -04:00
DD Liu
9b5a33ce3c Merge pull request #343 from LLK/greenkeeper/scratch-svg-renderer-0.2.0-prerelease.20180907141232
Update scratch-svg-renderer to the latest version 🚀
2018-09-07 10:38:13 -04:00
greenkeeper[bot]
2eca0a8326 fix(package): update scratch-svg-renderer to version 0.2.0-prerelease.20180907141232 2018-09-07 14:15:07 +00:00
2 changed files with 31 additions and 4 deletions

View File

@@ -26,7 +26,7 @@
"devDependencies": {
"babel-core": "^6.23.1",
"babel-eslint": "^8.2.1",
"babel-loader": "^8.0.0",
"babel-loader": "^7.1.4",
"babel-polyfill": "^6.22.0",
"babel-preset-env": "^1.6.1",
"chromeless": "^1.5.1",
@@ -42,7 +42,7 @@
"travis-after-all": "^1.4.4",
"uglifyjs-webpack-plugin": "^1.2.5",
"webpack": "^4.8.0",
"webpack-cli": "^2.0.15",
"webpack-cli": "^3.1.0",
"webpack-dev-server": "^3.1.4"
},
"dependencies": {
@@ -53,7 +53,7 @@
"minilog": "3.1.0",
"raw-loader": "^0.5.1",
"scratch-storage": "^1.0.0",
"scratch-svg-renderer": "0.2.0-prerelease.20180817005452",
"twgl.js": "4.4.0"
"scratch-svg-renderer": "0.2.0-prerelease.20180926143036",
"twgl.js": "4.5.0"
}
}

View File

@@ -178,6 +178,9 @@ class RenderWebGL extends EventEmitter {
/** @type {function} */
this._exitRegion = null;
/** @type {Array.<snapshotCallback>} */
this._snapshotCallbacks = [];
this._svgTextBubble = new SVGTextBubble();
this._createGeometry();
@@ -201,6 +204,13 @@ class RenderWebGL extends EventEmitter {
return this._gl;
}
/**
* @returns {HTMLCanvasElement} the canvas of the WebGL rendering context associated with this renderer.
*/
get canvas () {
return this._gl && this._gl.canvas;
}
/**
* Set the physical size of the stage in device-independent pixels.
* This will be multiplied by the device's pixel ratio on high-DPI displays.
@@ -589,6 +599,11 @@ class RenderWebGL extends EventEmitter {
gl.clear(gl.COLOR_BUFFER_BIT);
this._drawThese(this._drawList, ShaderManager.DRAW_MODE.default, this._projection);
if (this._snapshotCallbacks.length > 0) {
const snapshot = gl.canvas.toDataURL();
this._snapshotCallbacks.forEach(cb => cb(snapshot));
this._snapshotCallbacks = [];
}
}
/**
@@ -1704,6 +1719,18 @@ class RenderWebGL extends EventEmitter {
dst[2] += blendAlpha * 255;
return dst;
}
/**
* @callback RenderWebGL#snapshotCallback
* @param {string} dataURI Data URI of the snapshot of the renderer
*/
/**
* @param {snapshotCallback} callback Function called in the next frame with the snapshot data
*/
requestSnapshot (callback) {
this._snapshotCallbacks.push(callback);
}
}
// :3