搜索文档
首页
HTML/CSS
JavaScript
服务端开发
Java教程
移动端
数据库
当前位置:
首页
HTML/CSS
HTML5基础教程
HTML5 图形
源代码
清空
点击运行
<canvas id="ex5" width="500" height="250" style="border: 1px solid #cccccc;"> HTML5 Canvas not supported </canvas> <script> var canvas = document.getElementById("ex5"); var context = canvas.getContext("2d"); var x = 10; var y = 10; var width = 100; var height = 100 context.fillStyle = "#ff0000"; context.fillRect(x, y, width, height); context.scale(2,2); context.fillStyle = "#0000ff"; context.fillRect(x, y, width, height); </script>
运行结果