HTML5 资料 1 Canvas 教程 是一个新的用于通过脚本(通常是JavaScript)绘图的HTML 元素
例如,他可以用于绘图、制作图片的组合或者简单的动画(当然并不那么简单)
It can for instance be used to draw graphs, make photo compositions or do simple (and not so simple) animations
1 基本用法 Basic usage 元素 Let's start this tutorial by looking at the element itself
让我们从元素的定义开始吧
This looks a lot like the element, the only difference is that it doesn't have the src and alt attributes
看起来很像,唯一不同就是它不含 src 和 alt 属性
The element has only two attributes - width and height
These are both optional and can also be set using DOM properties or CSS rules
它只有两个属性,width 和 height,两个都是可选的,并且都可以 DOM 或者 CSS 来设置
When no width and height attributes are specified, the canvas will initially be 300 pixels wide and 150 pixels high
如果不指定 width 和 height,默认的是宽 300 像素,高 150 像素