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 参考手册

时间: 2024-08-06 20:03:39

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

HTML5 界面元素 Canvas 參考手冊

太阳火神的漂亮人生 (http://blog.csdn.net/opengl_es) 本文遵循"署名-非商业用途-保持一致"创作公用协议 转载请保留此句:太阳火神的漂亮人生 -  本博客专注于 敏捷开发及移动和物联设备研究:iOS.Android.Html5.Arduino.pcDuino,否则,出自本博客的文章拒绝转载或再转载,谢谢合作. HTML5 界面元素 Canvas 參考手冊HTML Canvas Reference 描写叙述Description The HTML5 <

HTML 5 Canvas 参考手册

HTML 5 Canvas 参考手册 HTML 视频/音频 HTML 文档类型 描述 HTML5 <canvas> 标签用于绘制图像(通过脚本,通常是 JavaScript). 不过,<canvas> 元素本身并没有绘制能力(它仅仅是图形的容器) - 您必须使用脚本来完成实际的绘图任务. getContext() 方法可返回一个对象,该对象提供了用于在画布上绘图的方法和属性. 本手册提供完整的 getContext("2d") 对象属性和方法,可用于在画布上绘制

《HTML参考手册》学习指南

<HTML 参考手册>是学习HTML过程中不可或缺的一个重要工具,配合W3Cschool首页的<HTML教程>相信你一定能很很快学会它的. 一.HTML是什么? HTML(Hyper Text Mark-up Language )即是超文本标记语言,是 WWW 的描述语言,由 Tim Berners-lee提出.通过使用标记标签来描述页面文档结构和表现形式的一种语言,再由浏览器进行解析,然后把结果展示在网页上.HTML标签是网页构成的基础,我们所见到的几乎所有网页都离不开HTML,

HTML 参考手册- (HTML5 标准)

HTML 参考手册- (HTML5 标准) 功能排序 New : HTML5 新标签 标签 描述 基础   <!DOCTYPE>  定义文档类型. <html> 定义一个 HTML 文档 <title> 为文档定义一个标题 <body> 定义文档的主体 <h1> to <h6> 定义 HTML 标题 <p> 定义一个段落 <br> 定义简单的折行. <hr> 定义水平线. <!--...--&

HTML5中的&lt;canvas&gt;画布:使用canvas元素在网页上绘制四分之一圆(3)

前几天自己做了个四分之一的圆,放到手机里面测试.效果不是很好.于是今天通过查资料,找到了canvas.自己研究了一天,发现可以使用canvas画圆.代码如下: 1 <!doctype html> 2 <html lang="en"> 3 <head> 4 <meta charset="UTF-8"> 5 <title></title> 6 7 </head> 8 <body&g

HTML5中的&lt;canvas&gt;画布:使用canvas元素在网页上绘制线条和圆(1)

什么是 Canvas? HTML5 的 canvas 元素使用 JavaScript 在网页上绘制图像. 画布是一个矩形区域,您可以控制其每一像素. canvas 拥有多种绘制路径.矩形.圆形.字符以及添加图像的方法. 创建 Canvas 元素 向 HTML5 页面添加 canvas 元素. 规定元素的 id.宽度和高度: 1 <canvas id="myCanvas" width="200" height="100"></ca

Android界面性能调优手册

转载:https://androidtest.org/android-graphics-performance-pattens/#11 界面是 Android 应用中直接影响用户体验最关键的部分.如果代码实现得不好,界面容易发生卡顿且导致应用占用大量内存. 我司这类做 ROM 的公司更不一样,预装的应用一定要非常流畅,这样给客户或用户的第一感觉就是快.又卡又慢的应用体验,会影响客户或用户对产品的信心和评价,所以不可忽视. 目录 一. Android渲染知识 1.1 绘制原理 1.2 掉帧 1.3

angular参考手册拷贝

AngularJS 参考手册 AngularJS 指令 本教程用到的 AngularJS 指令 : 指令 描述 ng-app 定义应用程序的根元素. ng-bind 绑定 HTML 元素到应用程序数据 ng-bind-html 绑定 HTML 元素的 innerHTML 到应用程序数据,并移除 HTML 字符串中危险字符 ng-bind-template 规定要使用模板替换的文本内容 ng-blur 规定 blur 事件的行为 ng-change 规定在内容改变时要执行的表达式 ng-check

小生总结:新手必看的jQuery参考手册主要API

本文整理了一些主要的jQuery API,其中包括jQuery 核心函数和方法.jQuery属性参考手册.jQuery CSS操作.jQuery选择器.jQuery文档操作.jQuery筛选操作.jQuery事件方法.jQuery效果.jQuery Ajax操作.jQuery工具函数.jQuery事件对象.jQuery延迟对象.jQuery回调函数,欢迎收藏使用. jquery核心函数 函数                                 描述 jQuery()    这个函数接