<body> <div id="main"></div></div><script type="text/javascript">function GED(ele) {return document.getElementById(ele);}function load_source(url, w, h) { this.canvas = document.createElement('canvas'); this.canvas.width = w; this.canvas.height = h; this.ctx = this.canvas.getContext('2d'); this.img = new Image(); this.img.src = url; this.img.onload = function () { this.ctx.drawImage(this.img, 0, 0); }.bind(this); return this.canvas;}source = new load_source('http://htmljs.b0.upaiyun.com/uploads/1382542991440-2angles.png', 300, 100);canvas = document.createElement('canvas')canvas.id = 'ff'canvas.width = 300;canvas.height = 100;GED('main').appendChild(canvas);ctxs = GED('ff').getContext('2d'); ctxs.drawImage(source, 110, 110);</script>
添加回答
举报
0/150
提交
取消