html5的canvas教程
HTML5资料
1 Canvas教程
<canvas>是一个新的用于通过脚本(通常是JavaScript)绘图的HTML元素。例如,他可以用于绘图、制作图片的组合或者简单的动画(当然并不那么简单)。It can for instance be used to draw graphs, make photo compositions or do simple (and not so simple) animations.
1.1 基本用法
Basic usage
<canvas>元素
Let's start this tutorial by looking at the <canvas> element itself. 让我们从<canvas>元素的定义开始吧。
<canvas id="tutorial" width="150" height="150"></canvas>
This looks a lot like the <img> element, the only difference is that it doesn't have the src and alt attributes. <canvas>看起来很像<img>,唯一不同就是它不含 src 和 alt 属性。The <canvas> 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像素。The element can be sized arbitrarily by CSS, but during rendering the image is scaled to fit its layout size. (If your renderings seem distorted, try specifying your width and height attributes explicitly in the <canvas> attributes, and not with CSS.)虽然可以通过 CSS 来调整canvas的大小,但渲染图像会缩放来适应布局的(如果你发现渲染结果看上去变形了,不必一味依赖CSS,可以尝试显式指定canvas的width 和 height 属性值)。
The id attribute isn't specific to the <canvas> element but is one of default HTML attributes which can be applied to (almost) every HTML element (like class for instance). It's always a good idea to supply an id because this makes it much easier to identify it in our script.
id 属性不是<canvas>专享的,就像标准的HTLM标签一样,任何一个HTML元素都可以指定其 id 值。一般,为元素指定 id 是个不错的主意,这样使得在脚本中应用更加方便。
The <canvas> element can be styled just like any normal image (margin, border, background, etc). These rules however don't affect the actual drawing on the canvas. We'll see how this is done later in this
tutorial. When no styling rules are applied to the canvas it will initially be fully transparent. <canvas>元素可以像普通图片一样指定其样式(边距,边框,背景等等)。然而这些样式并不会对canvas实际
html5基础教程_canvas标签介绍_计算机软件及应用_IT/计算机_专业资料。html视频教程,专注html教程,提供专业的html视频教程下载。html基础教程-零基础学习html-html...
[HTML5资料]Canvas教程_日语学习_外语学习_教育专区 暂无评价0人阅读0次下载举报文档 [HTML5资料]Canvas教程_日语学习_外语学习_教育专区。HTML 学习资料...
HTML5 canvas基础教程_互联网_IT/计算机_专业资料。这是我自己在学习canvas时总结的一份基础教程测试IE 下能否正常使用 canvas 说明 低版本的 IE 不能有效的...
html5基础教程_canvas实例2-太阳系2 课件_其它语言学习_外语学习_教育专区。... HTML5 canvas基础教程 66页 1下载券 [HTML5资料]Canvas教程 49页 4下载券 ...
HTML5.Canvas.教程_计算机软件及应用_IT/计算机_专业资料。方便各位学习新技术,web前端开发HTML5 Canvas 教程原作者:Eric Rowell 原文地址:http://www.html5...
HTML5 Canvas 2D API 规... 30页 免费 [HTML5资料]Canvas教程 80页 免费...HTML5 canvas 初级入门教程 HTML5 canvas 即 HTML5 画布,是一个现代浏览器都...
HTML5 Canvas 属性、定义及方法_IT/计算机_专业资料。HTML5 Canvas 属性、... roid-HTML5-Canvas教程 397页 2下载券 html5 canvas基础实例 7页 免费...
HTML5教程_IT/计算机_专业资料。HTML5教程特别说明此资料来自豆丁网(http://... HTML5 Canvas教程 84页 1下载券 HTML5基础教程之HTML5基... 2页 免费...
HTML5 canvas全解析_互联网_IT/计算机_专业资料。HTML5 canvas全解析... [HTML5资料]Canvas教程 80页 免费 HTML5应用介绍 35页 免费 adobe edge ...
23页 免费 html5 canvas基础实例 7页 免费 html5 canvas 基础 10页 2财富值 [HTML5资料]Canvas教程 80页 免费 HTML5-Canvas简介 11页 1财富值...
热门文档