首页 HTML5_Canvas_技巧手册

HTML5_Canvas_技巧手册

举报
开通vip

HTML5_Canvas_技巧手册 http://blog.nihilogic.dk/ Canvas element Attributes Name Type Default width unsigned long 300 height unsigned long 150 Methods Return Name string toDataURL( [Optional] string type, [Variadic] any args) Object getContext( string contextId) ...

HTML5_Canvas_技巧手册
http://blog.nihilogic.dk/ Canvas element Attributes Name Type Default width unsigned long 300 height unsigned long 150 Methods Return Name string toDataURL( [Optional] string type, [Variadic] any args) Object getContext( string contextId) 2D Context Attributes Name Type canvas HTMLCanvasObject [readonly] Methods Return Name void save( ) void restore( ) Transformation Methods Return Name void scale( float x, float y) void rotate( float angle) void translate( float x, float y) void transform( float m11, float m12, float m21, float m22, float dx, float dy) void setTransform( float m11, float m12, float m21, float m22, float dx, float dy) Image drawing Methods Return Name void 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) Compositing Attributes Name Type Default globalAlpha float 1.0 globalCompositeOperation string source-over Supports any of the following values: source-over source-in source-out source-atop destination-over destination-in destination-out destination-atop lighter copy xor Line styles Attributes Name Type Default lineWidth float 1.0 lineCap string butt Supports any of the following values: butt round square lineJoin string miter Supports any of the following values: round bevel miter miterLimit float 10 HTML5 Canvas Cheat Sheet v1.1 Colors, styles and shadows Attributes Name Type Default strokeStyle any black fillStyle any black shadowOffsetX float 0.0 shadowOffsetY float 0.0 shadowBlur float 0.0 shadowColor string transparent black Methods Return Name CanvasGradient 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] CanvasGradient interface void addColorStop( float offset, string color) CanvasPattern interface No attributes or methods. Paths Methods Return Name void beginPath( ) void closePath( ) void fill( ) void stroke( ) void clip( ) void moveTo( float x, float y) void lineTo( float x, float y) void quadraticCurveTo( float cpx, float cpy, float x, float y ) void bezierCurveTo( float cp1x, float cp1y, float cp2x, float cp2y, float x, float y ) void arcTo( float x1, float y1, float x2, float y2, float radius ) void arc( float x, float y, float radius, float startAngle, float endAngle, boolean anticlockwise ) void rect( float x, float y, float w, float h) boolean isPointInPath( float x, float y) Text Attributes Name Type Default font string 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 Name void fillText( string text, float x, float y, [Optional] float maxWidth) void strokeText( string text, float x, float y, [Optional] float maxWidth) TextMetrics measureText( string text) TextMetrics interface width float [readonly] Rectangles Methods Return Name void clearRect( float x, float y, float w, float h) void fillRect( float x, float y, float w, float h) void strokeRect( float x, float y, float w, float h) Pixel manipulation Methods Return Name ImageData createImageData( float sw, float sh) ImageData createImageData( ImageData imagedata) ImageData getImageData( float sx, float sy, float sw, float sh) void putImageData( ImageData imagedata, float dx, float dy, [Optional] float dirtyX, float dirtyY, float dirtyWidth, float dirtyHeight) ImageData interface width unsigned long [readonly] height unsigned long [readonly] data CanvasPixelArray [readonly] CanvasPixelArray interface length unsigned long [readonly] Source: http://www.whatwg.org/specs/web-apps/current-work/ (2009-05-04)
本文档为【HTML5_Canvas_技巧手册】,请使用软件OFFICE或WPS软件打开。作品中的文字与图均可以修改和编辑, 图片更改请在作品中右键图片并更换,文字修改请直接点击文字进行修改,也可以新增和删除文档中的内容。
该文档来自用户分享,如有侵权行为请发邮件ishare@vip.sina.com联系网站客服,我们会及时删除。
[版权声明] 本站所有资料为用户分享产生,若发现您的权利被侵害,请联系客服邮件isharekefu@iask.cn,我们尽快处理。
本作品所展示的图片、画像、字体、音乐的版权可能需版权方额外授权,请谨慎使用。
网站提供的党政主题相关内容(国旗、国徽、党徽..)目的在于配合国家政策宣传,仅限个人学习分享使用,禁止用于任何广告和商用目的。
下载需要: 免费 已有0 人下载
最新资料
资料动态
专题动态
is_104319
暂无简介~
格式:pdf
大小:147KB
软件:PDF阅读器
页数:2
分类:互联网
上传时间:2011-12-02
浏览量:34