# webgl-context
[![stable](http://badges.github.io/stability-badges/dist/stable.svg)](http://github.com/badges/stability-badges)
Grabs a WebGLRenderingContext, returning null if it doesn't exist. Similar to [2d-context](https://nodei.co/npm/2d-context/).
```js
//get a webgl context, will be null if not found
var gl = require('webgl-context')()
if (gl) {
document.body.appendChild(gl.canvas)
//do something...
}
```
Or, with options:
```js
//or with optional settings...
var gl = require('webgl-context')({
canvas: canvas, //the canvas DOM element to use
width: 400, //resizes the canvas..
height: 200,
antialias: true //can specify custom attributes here
})
```
## Usage
[![NPM](https://nodei.co/npm/webgl-context.png)](https://nodei.co/npm/webgl-context/)
#### `ctx = require('webgl-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 `antialias`
You can then get a reference of the canvas element with `ctx.canvas`.
## See Also
- [get-canvas-context](https://www.npmjs.com/package/get-canvas-context)
- [2d-context](https://www.npmjs.com/package/2d-context)
## License
MIT, see [LICENSE.md](http://github.com/mattdesl/webgl-context/blob/master/LICENSE.md) for details.
洋林
- 粉丝: 38
- 资源: 4574
最新资源
- 毕设和企业适用springboot区域电商平台类及物流信息平台源码+论文+视频.zip
- 毕设和企业适用springboot区域电商平台类及在线教育互动平台源码+论文+视频.zip
- 毕设和企业适用springboot区域电商平台类及智慧社区管理平台源码+论文+视频.zip
- 毕设和企业适用springboot人工智能类及企业数字资产管理平台源码+论文+视频.zip
- 毕设和企业适用springboot人工智能类及气象数据管理系统源码+论文+视频.zip
- 毕设和企业适用springboot人工智能类及企业风险监控平台源码+论文+视频.zip
- 毕设和企业适用springboot商城类及智能农业解决方案源码+论文+视频.zip
- 毕设和企业适用springboot社交电商类及VR互动平台源码+论文+视频.zip
- 毕设和企业适用springboot社交电商类及大数据存储平台源码+论文+视频.zip
- 毕设和企业适用springboot社交电商类及大数据实时处理系统源码+论文+视频.zip
- 毕设和企业适用springboot社交电商类及大数据云平台源码+论文+视频.zip
- 毕设和企业适用springboot全渠道电商平台类及电商产品推荐平台源码+论文+视频.zip
- 毕设和企业适用springboot区域电商平台类及智能云平台源码+论文+视频.zip
- 毕设和企业适用springboot区域电商平台类及自动化控制系统源码+论文+视频.zip
- 毕设和企业适用springboot全渠道电商平台类及个性化广告平台源码+论文+视频.zip
- 毕设和企业适用springboot全渠道电商平台类及酒店管理平台源码+论文+视频.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈