Compare commits

...

17 Commits

Author SHA1 Message Date
greenkeeper[bot]
4d4c72c028 chore(package): update gh-pages to version 2.0.1
Closes #346
2018-10-04 16:11:22 +00:00
Chris Willis-Ford
5f9ca5b4fa Merge pull request #349 from wdr-data/fix/infinite-bounds-loop
Fix bug when bounds would be infinite and cause never ending loop
2018-10-02 12:18:21 -07: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
Marcus Weiner
fdea47d31c Fix bug when bounds would be infinite and cause never ending loop 2018-09-22 22:29:23 +02: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
Karishma Chadha
7d55dec445 Merge pull request #337 from LLK/greenkeeper/scratch-storage-1.0.0
fix(package): update scratch-storage to version 1.0.0
2018-08-24 10:03:30 -04:00
Karishma Chadha
24c28cbb19 Merge pull request #336 from LLK/greenkeeper/scratch-vm-0.2.0-prerelease.20180824135031
chore(package): update scratch-vm to version 0.2.0-prerelease.20180824135031
2018-08-24 10:02:23 -04:00
greenkeeper[bot]
54a2aaf9ba chore(package): update scratch-vm to version 0.2.0-prerelease.20180824135031
Closes #330
2018-08-24 13:53:00 +00:00
greenkeeper[bot]
32bd87933a fix(package): update scratch-storage to version 1.0.0
Closes #298
2018-08-23 22:10:48 +00:00
2 changed files with 37 additions and 5 deletions

View File

@@ -34,15 +34,15 @@
"docdash": "^0.4.0",
"eslint": "^4.6.1",
"eslint-config-scratch": "^5.0.0",
"gh-pages": "^1.0.0",
"gh-pages": "^2.0.1",
"jsdoc": "^3.5.5",
"json": "^9.0.4",
"scratch-vm": "0.2.0-prerelease.20180802142248",
"scratch-vm": "0.2.0-prerelease.20180824135031",
"tap": "^11.0.0",
"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": {
@@ -52,8 +52,8 @@
"linebreak": "0.3.0",
"minilog": "3.1.0",
"raw-loader": "^0.5.1",
"scratch-storage": "^0.4.0",
"scratch-svg-renderer": "0.2.0-prerelease.20180817005452",
"scratch-storage": "^1.0.0",
"scratch-svg-renderer": "0.2.0-prerelease.20180926143036",
"twgl.js": "4.4.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 = [];
}
}
/**
@@ -953,7 +968,12 @@ class RenderWebGL extends EventEmitter {
if (candidateIDs.length === 0) {
return false;
}
const bounds = this.clientSpaceToScratchBounds(centerX, centerY, touchWidth, touchHeight);
if (bounds.left === -Infinity || bounds.bottom === -Infinity) {
return false;
}
const hits = [];
const worldPos = twgl.v3.create(0, 0, 0);
// Iterate over the scratch pixels and check if any candidate can be
@@ -1704,6 +1724,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