egret.sys.globalFunction
公共方法
方法 |
---|
createCanvas(width:number,height:number):HTMLCanvasElement |
createCanvasRenderBufferSurface(defaultFunc:(width?:number,height?:number)=>HTMLCanvasElement,width:number,height:number,root:boolean):HTMLCanvasElement 为CanvasRenderBuffer创建一个canvas |
createTexture(renderContext:egret.sys.RenderContext,bitmapData:egret.BitmapData |
drawTextureElements(renderContext:egret.sys.RenderContext,data:any,offset:number):number 画texture |
getContext2d(surface:HTMLCanvasElement):CanvasRenderingContext2D |
getContextWebGL(surface:HTMLCanvasElement):WebGLRenderingContext 获得系统的渲染运行时 |
mainCanvas(width:number,height:number):HTMLCanvasElement 创建一个canvas |
measureTextWith(context:CanvasRenderingContext2D,text:string):number 测量文本的宽度 |
registerFontMapping(name:string,path:string):void |
resizeCanvasRenderBuffer(renderContext:egret.sys.RenderContext,width:number,height:number,useMaxSize:boolean):void 改变渲染缓冲的大小并清空缓冲区 |
resizeContext(renderContext:egret.sys.RenderContext,width:number,height:number,useMaxSize:boolean):void 重新设置主canvas的大小 |
setRenderMode(renderMode:string):void |
方法详细信息
createCanvas()
public createCanvas(width:number,height:number):HTMLCanvasElement
createCanvasRenderBufferSurface()
public createCanvasRenderBufferSurface(defaultFunc:(width?:number,height?:number)=>HTMLCanvasElement,width:number,height:number,root:boolean):HTMLCanvasElement
为CanvasRenderBuffer创建一个canvas
- 支持版本:all
- 运行平台:Web,Native
- 参数
createTexture()
public createTexture(renderContext:egret.sys.RenderContext,bitmapData:egret.BitmapData|HTMLCanvasElement):WebGLTexture
仅通过bitmapData创建纹理
- 支持版本:all
- 运行平台:Web,Native
- 参数
- renderContext:egret.sys.RenderContext
- bitmapData:egret.BitmapData|HTMLCanvasElement
drawTextureElements()
public drawTextureElements(renderContext:egret.sys.RenderContext,data:any,offset:number):number
画texture
- 支持版本:all
- 运行平台:Web,Native
- 参数
- renderContext:egret.sys.RenderContext
- data:any
- offset:number
getContext2d()
public getContext2d(surface:HTMLCanvasElement):CanvasRenderingContext2D
- 支持版本:all
- 运行平台:Web,Native
- 参数
- surface:HTMLCanvasElement
getContextWebGL()
public getContextWebGL(surface:HTMLCanvasElement):WebGLRenderingContext
获得系统的渲染运行时
- 支持版本:all
- 运行平台:Web,Native
- 参数
- surface:HTMLCanvasElement
mainCanvas()
public mainCanvas(width:number,height:number):HTMLCanvasElement
创建一个canvas。
measureTextWith()
public measureTextWith(context:CanvasRenderingContext2D,text:string):number
测量文本的宽度
- 支持版本:all
- 运行平台:Web,Native
- 参数
- context:CanvasRenderingContext2D - context
- text:string - text
registerFontMapping()
public registerFontMapping(name:string,path:string):void
resizeCanvasRenderBuffer()
public resizeCanvasRenderBuffer(renderContext:egret.sys.RenderContext,width:number,height:number,useMaxSize:boolean):void
改变渲染缓冲的大小并清空缓冲区
- 支持版本:all
- 运行平台:Web,Native
- 参数
- renderContext:egret.sys.RenderContext - renderContext
- width:number - width
- height:number - height
- useMaxSize:boolean - useMaxSize
resizeContext()
public resizeContext(renderContext:egret.sys.RenderContext,width:number,height:number,useMaxSize:boolean):void
重新设置主canvas的大小
- 支持版本:all
- 运行平台:Web,Native
- 参数
- renderContext:egret.sys.RenderContext
- width:number
- height:number
- useMaxSize:boolean
setRenderMode()
public setRenderMode(renderMode:string):void
- 支持版本:all
- 运行平台:Web,Native
- 参数
- renderMode:string