From 2de55f04745abb89ceb816e1e1cd22cd643e36ae Mon Sep 17 00:00:00 2001 From: Ray Schamp Date: Fri, 3 Mar 2017 09:18:20 -0500 Subject: [PATCH] Add scratchOffset data to extractDrawable Makes it easier to translate between canvas coordinates and scratch coordinates --- src/RenderWebGL.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/RenderWebGL.js b/src/RenderWebGL.js index 4d871aa..433fd09 100644 --- a/src/RenderWebGL.js +++ b/src/RenderWebGL.js @@ -675,6 +675,8 @@ class RenderWebGL extends EventEmitter { * @property {Uint8Array} data Raw pixel data for the drawable * @property {int} width Drawable bounding box width * @property {int} height Drawable bounding box height + * @property {Array} scratchOffset [x, y] offset in Scratch coordinates + * from the drawable position to the client x, y coordinate * @property {int} x The x coordinate relative to drawable bounding box * @property {int} y The y coordinate relative to drawable bounding box */ @@ -738,6 +740,10 @@ class RenderWebGL extends EventEmitter { data: data, width: bounds.width, height: bounds.height, + scratchOffset: [ + (this._nativeSize[0] / 2) - x + drawable._position[0], + (this._nativeSize[1] / 2) - y - drawable._position[1] + ], x: pickX, y: pickY };