Created
June 20, 2014 02:20
-
-
Save wastemobile/e57ae5bcd5a1c2688164 to your computer and use it in GitHub Desktop.
摸清楚
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<script type="text/javascript"> | |
var gCanvas; | |
var gCtx; | |
function load(){ | |
console.log("loaded"); | |
gCanvas = document.getElementById("mcanvas"); | |
if (gCanvas.getContext){ | |
gCtx = gCanvas.getContext("2d"); | |
} else console.log("no Canvas?"); | |
} | |
function doProcess(f){ | |
var o=[]; | |
var reader = new FileReader(); | |
reader.onload = (function(theFile) { | |
var img = new Image(); | |
img.src = theFile; | |
img.onload = function(){ | |
gCtx.clearRect(0, 0, gCanvas.width, gCanvas.height); | |
gCtx.drawImage(img,0,0); | |
} | |
return; | |
})(f); | |
console.log(reader); | |
reader.readAsDataURL(f); | |
} | |
</script> | |
</head> | |
<body onload="load()"> | |
<input type="text" onClick="doProcess('https://www.google.com.br/logos/2012/clara_schuman-2012-hp.jpg')" /> | |
<canvas id="mcanvas" height="500" width="500"></canvas> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment