diff options
author | Pushkar Joshi | 2012-03-27 12:43:50 -0700 |
---|---|---|
committer | Pushkar Joshi | 2012-03-27 12:43:50 -0700 |
commit | 02a34df0ec3201199d209d43f621898b5607c150 (patch) | |
tree | d520b35afb0a8154abe417dce232c263a89794ce /js/tools | |
parent | 903b01b9d0501e6f974034273385a0517107b1e3 (diff) | |
parent | 675fffb08f570783f055471501f94fc273de2b9e (diff) | |
download | ninja-02a34df0ec3201199d209d43f621898b5607c150.tar.gz |
Merge branch 'master' into brushtool
Diffstat (limited to 'js/tools')
-rwxr-xr-x | js/tools/EyedropperTool.js | 28 |
1 files changed, 22 insertions, 6 deletions
diff --git a/js/tools/EyedropperTool.js b/js/tools/EyedropperTool.js index 927b86cf..d627f03b 100755 --- a/js/tools/EyedropperTool.js +++ b/js/tools/EyedropperTool.js | |||
@@ -148,7 +148,11 @@ exports.EyedropperTool = Montage.create(toolBase, { | |||
148 | c = this._getColorFromElement(obj, event); | 148 | c = this._getColorFromElement(obj, event); |
149 | } | 149 | } |
150 | 150 | ||
151 | if(typeof(c) === "string") | 151 | if(!c) |
152 | { | ||
153 | color = null; | ||
154 | } | ||
155 | else if(typeof(c) === "string") | ||
152 | { | 156 | { |
153 | color = this.application.ninja.colorController.getColorObjFromCss(c); | 157 | color = this.application.ninja.colorController.getColorObjFromCss(c); |
154 | } | 158 | } |
@@ -368,7 +372,7 @@ exports.EyedropperTool = Montage.create(toolBase, { | |||
368 | this._imageDataContext = this._imageDataCanvas.getContext("2d"); | 372 | this._imageDataContext = this._imageDataCanvas.getContext("2d"); |
369 | if(isWebGl) | 373 | if(isWebGl) |
370 | { | 374 | { |
371 | var worldData = elt.elementModel.shapeModel.GLWorld.export(); | 375 | var worldData = elt.elementModel.shapeModel.GLWorld.exportJSON(); |
372 | if(worldData) | 376 | if(worldData) |
373 | { | 377 | { |
374 | this._webGlDataCanvas = njModule.NJUtils.makeNJElement("canvas", "Canvas", "shape", {"data-RDGE-id": njModule.NJUtils.generateRandom()}, true); | 378 | this._webGlDataCanvas = njModule.NJUtils.makeNJElement("canvas", "Canvas", "shape", {"data-RDGE-id": njModule.NJUtils.generateRandom()}, true); |
@@ -379,12 +383,24 @@ exports.EyedropperTool = Montage.create(toolBase, { | |||
379 | this._webGlDataCanvas.width = w; | 383 | this._webGlDataCanvas.width = w; |
380 | this._webGlDataCanvas.height = h; | 384 | this._webGlDataCanvas.height = h; |
381 | this._webGlWorld = new World(this._webGlDataCanvas, true, true); | 385 | this._webGlWorld = new World(this._webGlDataCanvas, true, true); |
382 | this._webGlWorld.import(worldData); | 386 | |
387 | var index = worldData.indexOf( ';' ); | ||
388 | if ((worldData[0] === 'v') && (index < 24)) | ||
389 | { | ||
390 | // JSON format. separate the version info from the JSON info | ||
391 | var jStr = worldData.substr( index+1 ); | ||
392 | worldData = JSON.parse( jStr ); | ||
393 | } | ||
394 | |||
395 | this._webGlWorld.importJSON(worldData); | ||
383 | this._webGlWorld.render(); | 396 | this._webGlWorld.render(); |
384 | setTimeout(function() { | 397 | setTimeout(function() { |
385 | this._webGlWorld.draw(); | 398 | if(this._webGlWorld) |
386 | this._imageDataContext.drawImage(this._webGlDataCanvas, 0, 0); | 399 | { |
387 | return this._getColorFromCanvas(this._imageDataContext, tmpPt, true); | 400 | this._webGlWorld.draw(); |
401 | this._imageDataContext.drawImage(this._webGlDataCanvas, 0, 0); | ||
402 | return this._getColorFromCanvas(this._imageDataContext, tmpPt, true); | ||
403 | } | ||
388 | }.bind(this), 250); | 404 | }.bind(this), 250); |
389 | } | 405 | } |
390 | } | 406 | } |