canvas教程

HTML5 Canvas 技巧手册

字号+ 作者:H5之家 来源:H5之家 2015-09-29 19:05 我要评论( )

HTML5 Canvas Cheat Sheet v1.1Canvas elementAttributesName width height Type unsigned long unsigned long Default 300 150http://blog.nihilogic.dk/Compos


HTML5 Canvas Cheat Sheet v1.1
Canvas element
Attributes
Name width height Type unsigned long unsigned long Default 300 150



Compo


siting
Attributes
Name globalAlpha Type float Default 1.0

Methods
Return string Name toDataURL( [Optional] string type, [Variadic] any args) getContext( string contextId)

globalCompositeOperation string source-over Supports any of the following values:

Object

source-over

source-in

source-out

2D Context
Attributes
Name canvas Type HTMLCanvasObject [readonly] source-atop Name save( ) restore( ) destination-out destination-atop lighter destination-over destination-in

Methods
Return void void

Transformation
Methods
Return void void void void Name scale( float x, float y) rotate( float angle) translate( float x, float y) transform( float m11, float m12, float m21, float m22, float dx, float dy) setTransform( float m11, float m12, float m21, float m22, float dx, float dy)

copy

xor

Line styles
Attributes
Name lineWidth Type float Default 1.0

void

lineCap string butt Supports any of the following values: butt round square

Image drawing
Methods
Return void Name lineJoin string miter Supports any of the following values: round bevel miter drawImage( Object image, float dx, float dy, [Optional] float dw, float dh) Argument "image" can be of type HTMLImageElement, HTMLCanvasElement or HTMLVideoElement void drawImage( Object image, float sx, float sy, float sw, float sh, float dx, float dy, float dw, float dh)

miterLimit

float

10

Colors, styles and shadows
Attributes
Name strokeStyle fillStyle shadowOffsetX shadowOffsetY shadowBlur shadowColor Type any any float float float string Default black black 0.0 0.0 0.0 transparent black

Text
Attributes
Name font Type string Default 10px sans-serif

textAlign string start Supports any of the following values: [start, end, left, right, center] textBaseline string alphabetic Supports any of the following values: [top, hanging, middle, alphabetic, ideographic, bottom]

Methods
Return CanvasGradient Name createLinearGradient( float x0, float y0, float x1, float y1) CanvasGradient createRadialGradient( float x0, float y0, float r0, float x1, float y1, float r1) CanvasPattern createPattern( Object image, string repetition) Argument "image" can be of type HTMLImageElement, HTMLCanvasElement or HTMLVideoElement "repetition" supports any of the following values: [repeat (default), repeat-x, repeat-y, no-repeat]

Methods
Return void Name fillText( string text, float x, float y, [Optional] float maxWidth) strokeText( string text, float x, float y, [Optional] float maxWidth) measureText( string text)

void

TextMetrics

TextMetrics interface
width float [readonly]

CanvasGradient interface
void addColorStop( float offset, string color)

Rectangles
Methods
Return void Name clearRect( float x, float y, float w, float h) fillRect( float x, float y, float w, float h) strokeRect( float x, float y, float w, float h)

CanvasPattern interface
No attributes or methods.

Paths
Methods
Return void void void void void void void void Name beginPath( ) closePath( ) fill( ) stroke( ) clip( ) moveTo( float x, float y) lineTo( float x, float y) quadraticCurveTo( float cpx, float cpy, float x, float y ) bezierCurveTo( float cp1x, float cp1y, float cp2x, float cp2y, float x, float y ) arcTo( float x1, float y1, float x2, float y2, float radius ) arc( float x, float y, float radius, float startAngle, float endAngle, boolean anticlockwise ) rect( float x, float y, float w, float h) isPointInPath( float x, float y)

void void

Pixel manipulation
Methods
Return ImageData ImageData imagedata) ImageData void Name createImageData( float sw, float sh) createImageData( ImageData getImageData( float sx, float sy, float sw, float sh) putImageData( ImageData imagedata, float dx, float dy, [Optional] float dirtyX, float dirtyY, float dirtyWidth, float dirtyHeight)

void

void

ImageData interface
width height data unsigned long unsigned long CanvasPixelArray [readonly] [readonly] [readonly]

void

CanvasPixelArray interface
length unsigned long [readonly]

void boolean

Source: (2009-05-04)

HTML5 Canvas 技巧手册

HTML5 Canvas 技巧手册--文档资料共享网论文下载,说明书下载,Word文档下载,PPT文档,PDF文档,文库,坚持"用户需要的,就是我们关注的!"关注高价值的实用信息,争取提供更多实用下载资源。"



搜索更多“HTML5 Canvas 技巧手册”
下载《HTML5 Canvas 技巧手册》

 

1.本站遵循行业规范,任何转载的稿件都会明确标注作者和来源;2.本站的原创文章,请转载时务必注明文章作者和来源,不尊重原创的行为我们将追究责任;3.作者投稿可能会经我们编辑修改或补充。

相关文章
  • TP15 Canvas画图

    TP15 Canvas画图

    2016-12-03 11:04

  • Tkinter教程之Canvas篇(3)

    Tkinter教程之Canvas篇(3)

    2016-12-02 14:00

  • 相似辅助线作图技巧大比拼(讲义)王闫闫

    相似辅助线作图技巧大比拼(讲义)王闫闫

    2016-09-28 17:00

  • Android—BitMap与Canvas学习笔记

    Android—BitMap与Canvas学习笔记

    2015-11-21 19:17

网友点评