HTML5 界面元素 Canvas 參考手冊

太阳火神的漂亮人生 (http://blog.csdn.net/opengl_es)

本文遵循“署名-非商业用途-保持一致”创作公用协议

转载请保留此句:太阳火神的漂亮人生 -  本博客专注于 敏捷开发及移动和物联设备研究:iOS、Android、Html5、Arduino、pcDuino,否则,出自本博客的文章拒绝转载或再转载,谢谢合作。

HTML5 界面元素 Canvas 參考手冊
HTML Canvas Reference

描写叙述
Description

The HTML5 <canvas> tag is used to draw graphics, on the fly, via scripting (usually JavaScript).

However, the <canvas> element has no drawing abilities of its own (it is only a container for graphics) - you must use a script to actually draw the graphics.

The getContext() method returns an object that provides methods and properties for drawing on the canvas.

This reference will cover the properties and methods of the getContext("2d") object, which can be used to draw text, lines, boxes, circles, and more - on the canvas.

浏览器支持
Browser Support

Internet Explorer 9, Firefox, Opera, Chrome, and Safari support <canvas> and its properties and methods.

Note: Internet Explorer 8 and earlier versions, do not support the <canvas> element.

颜色、样式和阴影
Colors, Styles, and Shadows

Property

Description

fillStyle

Sets or returns the color, gradient, or pattern used to fill the drawing

strokeStyle

Sets or returns the color, gradient, or pattern used for strokes

shadowColor

Sets or returns the color to use for shadows

shadowBlur

Sets or returns the blur level for shadows

shadowOffsetX

Sets or returns the horizontal distance of the shadow from the shape

shadowOffsetY

Sets or returns the vertical distance of the shadow from the shape

Method

Description

createLinearGradient()

Creates a linear gradient (to use on canvas content)

createPattern()

Repeats a specified element in the specified direction

createRadialGradient()

Creates a radial/circular gradient (to use on canvas content)

addColorStop()

Specifies the colors and stop positions in a gradient object

线条样式
Line Styles

Property

Description

lineCap

Sets or returns the style of the end caps for a line

lineJoin

Sets or returns the type of corner created, when two lines meet

lineWidth

Sets or returns the current line width

miterLimit

Sets or returns the maximum miter length

矩形
Rectangles

Method

Description

rect()

Creates a rectangle

fillRect()

Draws a "filled" rectangle

strokeRect()

Draws a rectangle (no fill)

clearRect()

Clears the specified pixels within a given rectangle

路径
Paths

Method

Description

fill()

Fills the current drawing (path)

stroke()

Actually draws the path you have defined

beginPath()

Begins a path, or resets the current path

moveTo()

Moves the path to the specified point in the canvas, without creating a line

closePath()

Creates a path from the current point back to the starting point

lineTo()

Adds a new point and creates a line from that point to the last specified point in the canvas

clip()

Clips a region of any shape and size from the original canvas

quadraticCurveTo()

Creates a quadratic Bézier curve

bezierCurveTo()

Creates a cubic Bézier curve

arc()

Creates an arc/curve (used to create circles, or parts of circles)

arcTo()

Creates an arc/curve between two tangents

isPointInPath()

Returns true if the specified point is in the current path, otherwise false

转换
Transformations

Method

Description

scale()

Scales the current drawing bigger or smaller

rotate()

Rotates the current drawing

translate()

Remaps the (0,0) position on the canvas

transform()

Replaces the current transformation matrix for the drawing

setTransform()

Resets the current transform to the identity matrix. Then runs transform()

文本
Text

Property

Description

font

Sets or returns the current font properties for text content

textAlign

Sets or returns the current alignment for text content

textBaseline

Sets or returns the current text baseline used when drawing text

Method

Description

fillText()

Draws "filled" text on the canvas

strokeText()

Draws text on the canvas (no fill)

measureText()

Returns an object that contains the width of the specified text

图像绘制
Image Drawing

Method

Description

drawImage()

Draws an image, canvas, or video onto the canvas

像素操作
Pixel Manipulation

Property

Description

width

Returns the width of an ImageData object

height

Returns the height of an ImageData object

data

Returns an object that contains image data of a specified ImageData object

Method

Description

createImageData()

Creates a new, blank ImageData object

getImageData()

Returns an ImageData object that copies the pixel data for the specified rectangle on a canvas

putImageData()

Puts the image data (from a specified ImageData object) back onto the canvas

混合
Compositing

Property

Description

globalAlpha

Sets or returns the current alpha or transparency value of the drawing

globalCompositeOperation

Sets or returns how a new image are drawn onto an existing image

其他
Other

Method

Description

save()

Saves the state of the current context

restore()

Returns previously saved path state and attributes

createEvent()

getContext()

toDataURL()

HTML5 界面元素 Canvas 參考手冊的更多相关文章

  1. 6. GC 调优(工具篇) - GC參考手冊

    进行GC性能调优时, 须要明白了解, 当前的GC行为对系统和用户有多大的影响. 有多种监控GC的工具和方法, 本章将逐一介绍经常使用的工具. 您应该已经阅读了前面的章节: 垃圾收集简单介绍 - GC參 ...

  2. ANTLR4权威參考手冊(一)

    写在前面的话: 此文档是对伟大的Terence Parr的著作<the definitive antlr4 reference>的翻译本.致敬!欢迎转载,请注明原地址,请尊重劳动成果.翻译 ...

  3. Hadoop 2.6.0分布式部署參考手冊

    Hadoop 2.6.0分布式部署參考手冊 关于本參考手冊的word文档.能够到例如以下地址下载:http://download.csdn.net/detail/u012875880/8291493 ...

  4. 刚開始学习的人非常有用之chm结尾的參考手冊打开后无法正常显示

    从网上下载了struts2的參考手冊.chm(本文适用全部已.chm结尾的文件)不能正常打开使用. 如图: watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQv/ ...

  5. MySQL中文參考手冊

    非常好的中文手冊: 链接:http://www.sdau.edu.cn/support/mysq_doc/manual_toc.html

  6. bash參考手冊之六(Bash特性)

    6 Bash 特性 这部分描写叙述Bash独有的特性. *  调用Bash : Bash能够接受的命令行选项. *  Bash启动文件 : Bash何时及怎样运行脚本. *  交互Shell : 什么 ...

  7. bash參考手冊之五(shell变量)续三

    LINENO 当前在运行的脚本或者shell函数的行号. LINES 命令select用来确定打印选择列表的列宽.收到SIGWINCH后,自己主动设置. MACHTYPE 是一个字符串,描写叙述了正在 ...

  8. (十)unity4.6学习Ugui中文文档-------參考-UGUI Canvas Components

     大家好,我是孙广东.   转载请注明出处:http://write.blog.csdn.net/postedit/38922399 更全的内容请看我的游戏蛮牛地址:http://www.unit ...

  9. 早来的圣诞礼物!--android 逆向菜鸟速參手冊完蛋版

    我的说明: 让老皮特整理了这么长时间这个手冊,心里挺过意不去的,回头我去深圳带着他女儿去游乐场玩玩得了,辛苦了.peter! 太多的话语,也描写叙述不出这样的感觉了,得找个时间.不醉不归... 注:下 ...

随机推荐

  1. poi操作excel2007(读取、生成、编辑)

    因为现在再写excel2003版的比较low,所以我在这就不介绍了,直接介绍2007,我所用的编程软件是IDEA poi操作office总共有6个jar包,在pom.xml文件中配置如下,也可下载后直 ...

  2. CSVHelper读出乱码 解决方案

    using (FileStream fileStream = new FileStream(path, FileMode.Open, FileAccess.Read)) using (StreamRe ...

  3. [BZOJ1975]HH去散步 图论+矩阵

    ###[BZOJ1975]HH去散步 图论+矩阵 题目大意 要求出在一个m条边,n个点的图中,相邻两次走的边不能相同,求在t时间时从起点A走到终点B的路径方案总数.将答案mod45989 输入格式: ...

  4. Android应用常规开发技巧——善用组件生命周期

    数据管理 对于仅仅读数据.一种经常使用的管理模式是在onCreate函数中进行数据的载入,直到组件的onDestory函数被调用时在进行释放. // 缓存仅仅读的数据 private Object r ...

  5. 外网主机如何将数据包发送到共用一个公网IP的局域网某特定主机上的

    内网的一台电脑要上因特网对外开放服务或接收数据.都须要port映射.port映射分为动态和静态. 动态port映射:内网中的一台电脑要訪问站点.会向NAT网关发送数据包.包头中包含对方站点IP.por ...

  6. Restful技术

    一.概述 Restful技术是一种架构风格(Representational State Transfer)表现层状态转化,而不是一种编程标准. 之前前后端混在一起,前端通过mapping映射找到后端 ...

  7. web前端project师知识汇总

    分类: Web开发应用  一.何为Web前端project师?           前端project师,也叫Web前端开发project师.他是随着web发展.细分出来的行业.Web前端开发proj ...

  8. UVA 11077 Find the Permutations 递推置换

                               Find the Permutations Sorting is one of the most used operations in real ...

  9. 88.NODE.JS加密模块CRYPTO常用方法介绍

    转自:https://www.jb51.net/article/50668.htm 使用require('crypto')调用加密模块. 加密模块需要底层系统提供OpenSSL的支持.它提供了一种安全 ...

  10. [jzoj NOIP2018模拟11.02]

    嗯T1忘记取模了,100到20 嗯T2忘记了那啥定理,暴力也写炸了,这题我认 嗯T3线段树合并分裂没有写炸,考场上就知道妥妥的70分.但是,分数出的时候听到有人说暴力也是70分,我???脸黑,枉我敲了 ...