modifying diddy to get pixel of graphics object

Monkey Targets Forums/HTML5/modifying diddy to get pixel of graphics object

Yoda(Posted 2012) [#1]
is there any way to modify that diddy function so it returns the pixel color of a graphics-object i pass to the function instead of the game-canvas?

diddy.getPixel=function(x, y){
var tcanvas=document.getElementById("GameCanvas").getContext("2d")
if (tcanvas==null)
return 0;
var img = tcanvas.getImageData(x, y, 1, 1);
var pix = img.data;
// game_console.value = "alpha="+pix[3]+"\n"
return (pix[3]<<24) | (pix[0]<<16) | (pix[1]<<8) | pix[2];
};


therevills(Posted 2012) [#2]
It is possible, but you have to alter mojo too:

http://www.monkeycoder.co.nz/Community/post.php?topic=1853&post=18134


impixi(Posted 2012) [#3]
@Yoda: What do you mean by 'graphics-object'? An image? If you're coding for HTML5 only, it's possible to bypass Mojo and load HTML5 images natively, read / manipulate the data, and then render them directly to the canvas. If this is the case, I can code an example for you...