HTML5 界面元素 Canvas 参考手册

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()

 

时间: 2024-09-16 15:50:37

HTML5 界面元素 Canvas 参考手册的相关文章

分享最好的HTML5编码教程和参考手册

原文:http://www.gbin1.com/technology/html/20101019bestreferencesandtutorialstostartcodingwithhtml5/index.html 原文:queness.com         编译:GBin1.com 今天我们介绍相关HTML5的参考手册,演讲稿,电子书和教程. HTML5是新兴的web技术,虽然不是完全的新技术但是已经有很多的相关文章介绍HTML5,特别是当我们谈论HTML5将成为Flash的替代品.现代浏览

分享HTML 5的参考手册,演讲稿,电子书和教程

今天我们介绍相关HTML5的参考手册,演讲稿,电子书和教程.HTML5是新兴的web技术,虽然不是完全的新技术但是已经有很多的相关文章介绍HTML5,特别是当我们谈论HTML5将成为Flash的替代品.现代浏览器的快速开发已经刺激用户相应发展.毫无质疑,现在是学习HTML5的好时间,大多数的公司例如Google,Youtube,Facebook都已经开始使用HTML5来建站了. 51CTO推荐专题:HTML 5 下一代Web开发标准详解 这篇文章我们将介绍最好的HTML5参考手册,电子书,教程.

css3手册: 实用的 CSS3 参考手册和代码生成工具

CSS3技术现在越来越成熟,通过CSS3的一些新特性(如box-sizing.边界半径.文字阴影.渐变等)创建的效果已经令前端开发者兴奋不已.使 用CSS3进行前端设计是未来的发展趋势.因此,如果你是一名前端设计师,就需要掌握这些最新的技术,否则就有可能会被淘汰. 一.参考手册 1.  Idiomatic CSS 编写统一.符合习惯的CSS的原则,有中文版本. 2.  CSS3 Click Chart 示例代码和CSS3特性支持情况表. 3.  CSS3 Selector CSS3 Select

CSS3参考手册和CSS3代码生成工具加速你学习网页制作

文章简介:通过CSS3的一些新特性(如box-sizing.边界半径.文字阴影.渐变等)创建的效果已经令前端开发者兴奋不已.使用CSS3进行前端设计是未来的发展趋势.因此,如果你是一名前端设计师,就需要掌握这些最新的技术,否则就有可能会被淘汰. CSS3技术现在越来越成熟,通过CSS3的一些新特性(如box-sizing.边界半径.文字阴影.渐变等)创建的效果已经令前端开发者兴奋不已.使用CSS3进行前端设计是未来的发展趋势.因此,如果你是一名前端设计师,就需要掌握这些最新的技术,否则就有可能会

利用HTML5的画布Canvas实现刮刮卡效果_javascript技巧

先给大家展示效果: 查看演示   源码下载 你玩过刮刮卡么?一不小心可以中奖的那种.今天我给大家分享一个基于HTML5技术实现的刮刮卡效果,在PC上只需按住鼠标,在手机上你只需按住指头,轻轻刮去图层就可以模拟真实的刮奖效果. 我们利用HTML5的画布Canvas,结合其提供的API,在Canvas元素上绘制一个灰色蒙层,然后通过检测用户鼠标移到和手势来绘制一个透明的图形,这样就能看到Canvas背景下的真实图片,就达到刮刮卡效果. HTML 我们只需要在页面中加入canvas标签元素,其他的就看

《版式设计——日本平面设计师参考手册》目录—导读

内容提要版式设计--日本平面设计师参考手册本书主要介绍了版式设计的基本原则.设计技巧以及软件相关技术,通过将具体的版式案例进行Before与After的对比,并举一反三地进一步分析讲解,鲜明而直观地呈现了极具学习价值的版式设计经验.全书共分为6部分,第1-2部分讲解版式设计软件InDesign和 Illustrator的基本操作:第3部分讲解版面构图的要点,包括构图的原则.分割线的设置和视觉化设计等:第4部分讲解如何编排文字,包括字体的运用.标题的运用等内容:第5部分讲解如何设置照片:第6部分讲

HTML参考手册

参考|参考手册 Basic tags 基 本 标 签 <html></html> Creates an HTML document 创 建 一 个HTML 文 档 <head></head> Sets off the title and other information that isn't displayed on the Web page itself 设 置 文 档 标 题 以 及 其 他 不 在WEB 网 页 上 显 示 的 信 息 <bod

非常详细的IMG,IFRAME的属性参考手册

参考|参考手册 I 元素 | i 对象 IMG 元素 | img 对象 DHTML 对象 IFRAME 元素 | iframe 对象 -------------------------------------------------------------------------------- 创建内嵌浮动框架. 成员表 下面的表格列出了 iframe 对象引出的成员.请单击左侧的标签来选择你想要查看的成员类型.  标签属性/属性   显示: 标签属性/属性 行为 集合 事件 滤镜 方法 对象

IFRAME的属性参考手册

参考|参考手册 IFRAME 元素 | iframe 对象 -------------------------------------------------- 创建内嵌浮动框架. 成员表 下面的表格列出了 iframe 对象引出的成员.请单击左侧的标签来选择你想要查看的成员类型. 标签属性/属性 显示: 标签属性/属性 行为 集合 事件 滤镜 方法 对象 样式 标签属性 属性 描述 ALIGN align 设置或获取表格排列. ALLOWTRANSPARENCY allowTransparen