2d-context 中文文档教程

发布于 9年前 浏览 26 项目主页 更新于 3年前

2d-context

获取 CanvasRenderingContext2D,如果不存在则返回 null。 类似于 webgl-context

var context = require('2d-context')()
var canvas = context.canvas

var canvas = document.createElement('canvas')

var context = require('2d-context')({
    canvas: canvas,
    alpha: true,
    width: 256,
    height: 256    
})

Usage

NPM< /a>

ctx = require('2d-context')([opt])

获取带有可选参数的新画布上下文:

  • canvas a canvas element to use, otherwise creates a new element
  • width a width to set, otherwise no change
  • height a height to set, otherwise no change
  • other attributes are passed to the getContext call, like alpha and storage

然后您可以使用 ctx.canvas 获取画布元素的引用。

License

麻省理工学院,详见 LICENSE.md

2d-context

Grabs a CanvasRenderingContext2D, returning null if it doesn't exist. Similar to webgl-context.

var context = require('2d-context')()
var canvas = context.canvas

or

var canvas = document.createElement('canvas')

var context = require('2d-context')({
    canvas: canvas,
    alpha: true,
    width: 256,
    height: 256    
})

Usage

NPM

ctx = require('2d-context')([opt])

Gets a new canvas context with optional parameters:

  • canvas a canvas element to use, otherwise creates a new element
  • width a width to set, otherwise no change
  • height a height to set, otherwise no change
  • other attributes are passed to the getContext call, like alpha and storage

You can then get a reference of the canvas element with ctx.canvas.

License

MIT, see LICENSE.md for details.

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文