<canvas id="canvasOne" style="display:none;" width="500" height="500"></canvas>
<img id="img"/>
<script>
function canvasSupport(){
return Modernizr.canvas;
}
function callCanvasApps(){
var canvasOne=document.getElementById("canvasOne");
//if(!canvasSupport())
//return;
var d=canvasOne.getd("2d");
d.fillStyle = "#ffffaa";
d.fillRect(0, 0, 500, 300);
d.fillStyle = "#000000";
d.font = "20px Sans-Serif";
d.textBaseline = "top";
d.fillText ("23232",195,80);
//console.log(canvasOne.toDataURL());
return canvasOne.toDataURL();
//这句生成快照,可以将结果直接拷贝放到浏览器的URL里回车看到结果,这个以后做PNG图片似乎不需要美工了么 ,O(∩_∩)O哈哈~
}
if(window.addEventListener){
window.addEventListener("load",callCanvasApps,false);
}else{
window.onload=callCanvasApps;
}
document.getElementById("img").src=callCanvasApps();
</script>