1 / 108
文档名称:

[HTML资料]Canvas教程.docx

格式:docx   大小:74KB   页数:108页
下载后只包含 1 个 DOCX 格式的文档,没有任何的图纸或源代码,查看文件列表

如果您已付费下载过本站文档,您可以点这里二次下载

[HTML资料]Canvas教程.docx

上传人:jianjian401 2018/5/14 文件大小:74 KB

下载得到文件列表

[HTML资料]Canvas教程.docx

相关文档

文档介绍

文档介绍:HTML5资料
Canvas教程
<canvas>是一个新的用于通过脚本(通常是JavaScript)绘图的HTML元素。例如,他可以用于绘图、制作图片的组合或者简单的动画(当然并不那么简单)。It can for instance be used to draw graphs, make positions or do simple (and not so simple) animations.
基本用法
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 ,width 和 height,两个都是可选的,并且都可以 DOM 或者 CSS 来设置。 When no width and height attributes are specified, the canvas will initially be 300 pixels wide and 150 pixels 和 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实际生成的图像产生什么影响。下面我们会看

最近更新

幼师实习心得体会范文集合五篇(通用4篇) 7页

广西壮族自治区桂林市青狮中学高三数学文模拟.. 6页

广西壮族自治区梧州市初级中学高一英语联考试.. 5页

年会领导讲话稿万能范文7篇 7页

广西壮族自治区梧州市苍梧中学高三化学模拟试.. 7页

工程地质实习报告(精选15篇) 81页

广西壮族自治区河池市四把中学高三物理下学期.. 5页

广西壮族自治区河池市宜州第三中学2020-2021学.. 5页

小学学习心得体会(通用15篇) 31页

寓言小学作文(精选3篇) 4页

实习保证书(精选12篇) 14页

广西壮族自治区玉林市北流第六中学2021年高三.. 8页

广西壮族自治区玉林市实验中学高三数学理模拟.. 8页

姐姐—作文(通用3篇) 2页

广西壮族自治区百色市那坡县民族初级中学 202.. 4页

广西壮族自治区贵港市古樟高级中学高二英语期.. 5页

餐饮业厨师培训师劳动合同3篇 96页

因结婚辞职报告(精选2篇) 3页

呵护心灵作文(通用3篇) 4页

广西壮族自治区贵港市育才中学2021-2022学年高.. 7页

广西壮族自治区贺州市昭平县黄姚中学2020-202.. 5页

医院卫生管理制度(通用4篇) 6页

募捐倡议书(通用8篇) 12页

广西壮族自治区钦州市新港中学2022年高一数学.. 6页

广西壮族自治区钦州市灵海学校2020-2021学年高.. 9页

广西壮族自治区钦州市长滩中学2020年高三语文.. 10页

写菊花作文(通用5篇) 6页

2025-2030年中国手动打凸字机行业深度研究分析.. 27页

关于感恩节感言(精选4篇) 6页

关于大学军训的心得体会(通用9篇) 11页