canvas 绘图
canvas
<canvas id="drawing" width="200" height="200">xxx</canvas> <script>var drawing = document.getElementById('drawing')//傳入 2d 就可以獲得 2D 上下文drawing.getContent('2d')//保存圖片,添加到頁面中var imgURL = drawing.toDataURL('image/png')var img = document.createElement('img')img.src = imgURLdocument.body.appendChild(img)//矩形填充context.fillStyle = '#0000ff'context.fillRect(10,10,50,50)//矩形描邊context.strokeStyle = 'red';context.strokeRect(10,60,50,50)//清除矩形context.clearRect(20,20,10,10)//保存和調用上下文ctx.fillStyle='#ff0000'ctx.save()ctx.fillStyle='#00ff00'ctx.translate(100,100)ctx.save()ctx.fillStyle='#000000'ctx.translate(200,200)ctx.save()ctx.fillStyle='#0000ff'ctx.fillRect(0,0,100,200)ctx.restore()ctx.fillRect(10,10,100,200)ctx.restore()ctx.fillRect(0,0,100,200)ctx.restore()ctx.fillRect(20,20,100,200)</script>canvas必須先設置width和height
總結
- 上一篇: Vsftpd文件传输服务(本地用户访问)
- 下一篇: 基于Walle的多渠道快速打包自动脚本