# Interface: Canvas

Canvas()

# Properties

# height

height: number

画布的高度

Returns: number


# toTempFilePath

toTempFilePath: AsyncMethodToTempFilePathParams, ToTempFilePathSuccessCallbackParams

将当前 Canvas 保存为一个临时文件。 如果使用了开放数据域,则生成后的文件仅能被用于以下接口:mogs.saveImageToPhotosAlbum、mogs.shareAppMessage、mogs.onShareAppMessage

todo 对于 mogs 上面的文档说明是否成立?

Returns: AsyncMethodToTempFilePathParams, ToTempFilePathSuccessCallbackParams


# width

width: number

画布的宽度

Returns: number

# Methods

# getContext

getContext(contextType: "2d"): CanvasRenderingContext2D

获取画布对象的绘图上下文

# 参数:

属性 类型 描述
contextType "2d"

# 返回值:

CanvasRenderingContext2D

getContext(contextType: "webgl", contextAttributes?: Readonly‹object›): WebGLRenderingContext

获取画布对象的绘图上下文

# 参数:

属性 类型 描述
contextType "webgl" -
contextAttributes? Readonly‹object› webgl 上下文属性,仅当 contextType 为 webgl 时有效

# 返回值:

WebGLRenderingContext


# toDataURL

toDataURL(): string

把画布上的绘制内容以一个 data URI 的格式返回

# 返回值:

string

data URI 格式的字符串


# toTempFilePathSync

toTempFilePathSync(): string

Canvas.toTempFilePath 的同步版本

# 返回值:

string

canvas 生成的临时文件路径 (本地路径)